documentation.d.ts 3.5 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953809548095580956809578095880959809608096180962809638096480965809668096780968809698097080971809728097380974809758097680977809788097980980809818098280983809848098580986809878098880989809908099180992809938099480995809968099780998809998100081001810028100381004810058100681007810088100981010810118101281013810148101581016810178101881019810208102181022810238102481025810268102781028810298103081031810328103381034810358103681037810388103981040810418104281043810448104581046810478104881049810508105181052810538105481055810568105781058810598106081061810628106381064810658106681067810688106981070810718107281073810748107581076810778107881079810808108181082810838108481085810868108781088810898109081091810928109381094810958109681097810988109981100811018110281103811048110581106811078110881109811108111181112811138111481115811168111781118811198112081121811228112381124811258112681127811288112981130811318113281133811348113581136811378113881139811408114181142811438114481145811468114781148811498115081151811528115381154811558115681157811588115981160811618116281163811648116581166811678116881169811708117181172811738117481175811768117781178811798118081181811828118381184811858118681187811888118981190811918119281193811948119581196811978119881199812008120181202812038120481205812068120781208812098121081211812128121381214812158121681217812188121981220812218122281223812248122581226812278122881229812308123181232812338123481235812368123781238812398124081241812428124381244812458124681247812488124981250812518125281253812548125581256812578125881259812608126181262812638126481265812668126781268812698127081271812728127381274812758127681277812788127981280812818128281283812848128581286812878128881289812908129181292812938129481295812968129781298812998130081301813028130381304813058130681307813088130981310813118131281313813148131581316813178131881319813208132181322813238132481325813268132781328813298133081331813328133381334813358133681337813388133981340813418134281343813448134581346813478134881349813508135181352813538135481355813568135781358813598136081361813628136381364813658136681367813688136981370813718137281373813748137581376813778137881379813808138181382813838138481385813868138781388813898139081391813928139381394813958139681397813988139981400814018140281403814048140581406814078140881409814108141181412814138141481415814168141781418814198142081421814228142381424814258142681427814288142981430814318143281433814348143581436814378143881439814408144181442814438144481445814468144781448814498145081451814528145381454814558145681457814588145981460814618146281463814648146581466814678146881469814708147181472814738147481475814768147781478814798148081481814828148381484814858148681487814888148981490814918149281493814948149581496814978149881499815008150181502815038150481505815068150781508815098151081511815128151381514815158151681517815188151981520815218152281523815248152581526815278152881529815308153181532815338153481535815368153781538815398154081541815428154381544815458154681547815488154981550815518155281553815548155581556815578155881559815608156181562815638156481565815668156781568815698157081571815728157381574815758157681577815788157981580815818158281583815848158581586815878158881589815908159181592815938159481595815968159781598815998160081601816028160381604816058160681607816088160981610816118161281613816148161581616816178161881619816208162181622816238162481625816268162781628816298163081631816328163381634816358163681637816388163981640816418164281643816448164581646816478164881649816508165181652816538165481655816568165781658816598166081661816628166381664816658166681667816688166981670816718167281673816748167581676816778167881679816808168181682816838168481685816868168781688816898169081691816928169381694816958169681697816988169981700817018170281703817048170581706817078170881709817108171181712817138171481715817168171781718817198172081721817228172381724817258172681727817288172981730817318173281733817348173581736817378173881739817408174181742817438174481745817468174781748817498175081751817528175381754817558175681757817588175981760817618176281763817648176581766817678176881769817708177181772817738177481775817768177781778817798178081781817828178381784817858178681787817888178981790817918179281793817948179581796817978179881799818008180181802818038180481805818068180781808818098181081811818128181381814818158181681817818188181981820818218182281823818248182581826818278182881829818308183181832818338183481835818368183781838818398184081841818428184381844818458184681847818488184981850818518185281853818548185581856818578185881859818608186181862818638186481865818668186781868818698187081871818728187381874818758187681877818788187981880818818188281883818848188581886818878188881889818908189181892818938189481895818968189781898818998190081901819028190381904819058190681907819088190981910819118191281913819148191581916819178191881919819208192181922819238192481925819268192781928819298193081931819328193381934819358193681937819388193981940819418194281943819448194581946819478194881949819508195181952819538195481955819568195781958819598196081961819628196381964819658196681967819688196981970819718197281973819748197581976819778197881979819808198181982819838198481985819868198781988819898199081991819928199381994819958199681997819988199982000820018200282003820048200582006820078200882009820108201182012820138201482015820168201782018820198202082021820228202382024820258202682027820288202982030820318203282033820348203582036820378203882039820408204182042820438204482045820468204782048820498205082051820528205382054820558205682057820588205982060820618206282063820648206582066820678206882069820708207182072820738207482075820768207782078820798208082081820828208382084820858208682087820888208982090820918209282093820948209582096820978209882099821008210182102821038210482105821068210782108821098211082111821128211382114821158211682117821188211982120821218212282123821248212582126821278212882129821308213182132821338213482135821368213782138821398214082141821428214382144821458214682147821488214982150821518215282153821548215582156821578215882159821608216182162821638216482165821668216782168821698217082171821728217382174821758217682177821788217982180821818218282183821848218582186821878218882189821908219182192821938219482195821968219782198821998220082201822028220382204822058220682207822088220982210822118221282213822148221582216822178221882219822208222182222822238222482225822268222782228822298223082231822328223382234822358223682237822388223982240822418224282243822448224582246822478224882249822508225182252822538225482255822568225782258822598226082261822628226382264822658226682267822688226982270822718227282273822748227582276822778227882279822808228182282822838228482285822868228782288822898229082291822928229382294822958229682297822988229982300823018230282303823048230582306823078230882309823108231182312823138231482315823168231782318823198232082321823228232382324823258232682327823288232982330823318233282333823348233582336823378233882339823408234182342823438234482345823468234782348823498235082351823528235382354823558235682357823588235982360823618236282363823648236582366823678236882369823708237182372823738237482375823768237782378823798238082381823828238382384823858238682387823888238982390823918239282393823948239582396823978239882399824008240182402824038240482405824068240782408824098241082411824128241382414824158241682417824188241982420824218242282423824248242582426824278242882429824308243182432824338243482435824368243782438824398244082441824428244382444824458244682447824488244982450824518245282453824548245582456824578245882459824608246182462824638246482465824668246782468824698247082471824728247382474824758247682477824788247982480824818248282483824848248582486824878248882489824908249182492824938249482495824968249782498824998250082501825028250382504825058250682507825088250982510825118251282513825148251582516825178251882519825208252182522825238252482525825268252782528825298253082531825328253382534825358253682537825388253982540825418254282543825448254582546825478254882549825508255182552825538255482555825568255782558825598256082561825628256382564825658256682567825688256982570825718257282573825748257582576825778257882579825808258182582825838258482585825868258782588825898259082591825928259382594825958259682597825988259982600826018260282603826048260582606826078260882609826108261182612826138261482615826168261782618826198262082621826228262382624826258262682627826288262982630826318263282633826348263582636826378263882639826408264182642826438264482645826468264782648826498265082651826528265382654826558265682657826588265982660826618266282663826648266582666826678266882669826708267182672826738267482675826768267782678826798268082681826828268382684826858268682687826888268982690826918269282693826948269582696826978269882699827008270182702827038270482705827068270782708827098271082711827128271382714827158271682717827188271982720827218272282723827248272582726827278272882729827308273182732827338273482735827368273782738827398274082741827428274382744827458274682747827488274982750827518275282753827548275582756827578275882759827608276182762827638276482765827668276782768827698277082771827728277382774827758277682777827788277982780827818278282783827848278582786827878278882789827908279182792827938279482795827968279782798827998280082801828028280382804828058280682807828088280982810828118281282813828148281582816828178281882819828208282182822828238282482825828268282782828828298283082831828328283382834828358283682837828388283982840828418284282843828448284582846828478284882849828508285182852828538285482855828568285782858828598286082861828628286382864828658286682867828688286982870828718287282873828748287582876828778287882879828808288182882828838288482885828868288782888828898289082891828928289382894828958289682897828988289982900829018290282903829048290582906829078290882909829108291182912829138291482915829168291782918829198292082921829228292382924829258292682927829288292982930829318293282933829348293582936829378293882939829408294182942829438294482945829468294782948829498295082951829528295382954829558295682957829588295982960829618296282963829648296582966829678296882969829708297182972829738297482975829768297782978829798298082981829828298382984829858298682987829888298982990829918299282993829948299582996829978299882999830008300183002830038300483005830068300783008830098301083011830128301383014830158301683017830188301983020830218302283023830248302583026830278302883029830308303183032830338303483035830368303783038830398304083041830428304383044830458304683047830488304983050830518305283053830548305583056830578305883059830608306183062830638306483065830668306783068830698307083071830728307383074830758307683077830788307983080830818308283083830848308583086830878308883089830908309183092830938309483095830968309783098830998310083101831028310383104831058310683107831088310983110831118311283113831148311583116831178311883119831208312183122831238312483125831268312783128831298313083131831328313383134831358313683137831388313983140831418314283143831448314583146831478314883149831508315183152831538315483155831568315783158831598316083161831628316383164831658316683167831688316983170831718317283173831748317583176831778317883179831808318183182831838318483185831868318783188831898319083191831928319383194831958319683197831988319983200832018320283203832048320583206832078320883209832108321183212832138321483215832168321783218832198322083221832228322383224832258322683227832288322983230832318323283233832348323583236832378323883239832408324183242832438324483245832468324783248832498325083251832528325383254832558325683257832588325983260832618326283263832648326583266832678326883269832708327183272832738327483275832768327783278832798328083281832828328383284832858328683287832888328983290832918329283293832948329583296832978329883299833008330183302833038330483305833068330783308833098331083311833128331383314833158331683317833188331983320833218332283323833248332583326833278332883329833308333183332833338333483335833368333783338833398334083341833428334383344833458334683347833488334983350833518335283353833548335583356833578335883359833608336183362833638336483365833668336783368833698337083371833728337383374833758337683377833788337983380833818338283383833848338583386833878338883389833908339183392833938339483395833968339783398833998340083401834028340383404834058340683407834088340983410834118341283413834148341583416834178341883419834208342183422834238342483425834268342783428834298343083431834328343383434834358343683437834388343983440834418344283443834448344583446834478344883449834508345183452834538345483455834568345783458834598346083461834628346383464834658346683467834688346983470834718347283473834748347583476834778347883479834808348183482834838348483485834868348783488834898349083491834928349383494834958349683497834988349983500835018350283503835048350583506835078350883509835108351183512835138351483515835168351783518835198352083521835228352383524835258352683527835288352983530835318353283533835348353583536835378353883539835408354183542835438354483545835468354783548835498355083551835528355383554835558355683557835588355983560835618356283563835648356583566835678356883569835708357183572835738357483575835768357783578835798358083581835828358383584835858358683587835888358983590835918359283593835948359583596835978359883599836008360183602836038360483605836068360783608836098361083611836128361383614836158361683617836188361983620836218362283623836248362583626836278362883629836308363183632836338363483635836368363783638836398364083641836428364383644836458364683647836488364983650836518365283653836548365583656836578365883659836608366183662836638366483665836668366783668836698367083671836728367383674836758367683677836788367983680836818368283683836848368583686836878368883689836908369183692836938369483695836968369783698836998370083701837028370383704837058370683707837088370983710837118371283713837148371583716837178371883719837208372183722837238372483725837268372783728837298373083731837328373383734837358373683737837388373983740837418374283743837448374583746837478374883749837508375183752837538375483755837568375783758837598376083761837628376383764837658376683767837688376983770837718377283773837748377583776837778377883779837808378183782837838378483785837868378783788837898379083791837928379383794837958379683797837988379983800838018380283803838048380583806838078380883809838108381183812838138381483815838168381783818838198382083821838228382383824838258382683827838288382983830838318383283833838348383583836838378383883839838408384183842838438384483845838468384783848838498385083851838528385383854838558385683857838588385983860838618386283863838648386583866838678386883869838708387183872838738387483875838768387783878838798388083881838828388383884838858388683887838888388983890838918389283893838948389583896838978389883899839008390183902839038390483905839068390783908839098391083911839128391383914839158391683917839188391983920839218392283923839248392583926839278392883929839308393183932839338393483935839368393783938839398394083941839428394383944839458394683947839488394983950839518395283953839548395583956839578395883959839608396183962839638396483965839668396783968839698397083971839728397383974839758397683977839788397983980839818398283983839848398583986839878398883989839908399183992839938399483995839968399783998839998400084001840028400384004840058400684007840088400984010840118401284013840148401584016840178401884019840208402184022840238402484025840268402784028840298403084031840328403384034840358403684037840388403984040840418404284043840448404584046840478404884049840508405184052840538405484055840568405784058840598406084061840628406384064840658406684067840688406984070840718407284073840748407584076840778407884079840808408184082840838408484085840868408784088840898409084091840928409384094840958409684097840988409984100841018410284103841048410584106841078410884109841108411184112841138411484115841168411784118841198412084121841228412384124841258412684127841288412984130841318413284133841348413584136841378413884139841408414184142841438414484145841468414784148841498415084151841528415384154841558415684157841588415984160841618416284163841648416584166841678416884169841708417184172841738417484175841768417784178841798418084181841828418384184841858418684187841888418984190841918419284193841948419584196841978419884199842008420184202842038420484205842068420784208842098421084211842128421384214842158421684217842188421984220842218422284223842248422584226842278422884229842308423184232842338423484235842368423784238842398424084241842428424384244842458424684247842488424984250842518425284253842548425584256842578425884259842608426184262842638426484265842668426784268842698427084271842728427384274842758427684277842788427984280842818428284283842848428584286842878428884289842908429184292842938429484295842968429784298842998430084301843028430384304843058430684307843088430984310843118431284313843148431584316843178431884319843208432184322843238432484325843268432784328843298433084331843328433384334843358433684337843388433984340843418434284343843448434584346843478434884349843508435184352843538435484355843568435784358843598436084361843628436384364843658436684367843688436984370843718437284373843748437584376843778437884379843808438184382843838438484385843868438784388843898439084391843928439384394843958439684397843988439984400844018440284403844048440584406844078440884409844108441184412844138441484415844168441784418844198442084421844228442384424844258442684427844288442984430844318443284433844348443584436844378443884439844408444184442844438444484445844468444784448844498445084451844528445384454844558445684457844588445984460844618446284463844648446584466844678446884469844708447184472844738447484475844768447784478844798448084481844828448384484844858448684487844888448984490844918449284493844948449584496844978449884499845008450184502845038450484505845068450784508845098451084511845128451384514845158451684517845188451984520845218452284523845248452584526845278452884529845308453184532845338453484535845368453784538845398454084541845428454384544845458454684547845488454984550845518455284553845548455584556845578455884559845608456184562845638456484565845668456784568845698457084571845728457384574845758457684577
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. get observers(): Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Check if the document object exists
  289. * @returns true if the document object exists
  290. */
  291. static IsDocumentAvailable(): boolean;
  292. /**
  293. * Extracts text content from a DOM element hierarchy
  294. * @param element defines the root element
  295. * @returns a string
  296. */
  297. static GetDOMTextContent(element: HTMLElement): string;
  298. }
  299. }
  300. declare module BABYLON {
  301. /**
  302. * Logger used througouht the application to allow configuration of
  303. * the log level required for the messages.
  304. */
  305. export class Logger {
  306. /**
  307. * No log
  308. */
  309. static readonly NoneLogLevel: number;
  310. /**
  311. * Only message logs
  312. */
  313. static readonly MessageLogLevel: number;
  314. /**
  315. * Only warning logs
  316. */
  317. static readonly WarningLogLevel: number;
  318. /**
  319. * Only error logs
  320. */
  321. static readonly ErrorLogLevel: number;
  322. /**
  323. * All logs
  324. */
  325. static readonly AllLogLevel: number;
  326. private static _LogCache;
  327. /**
  328. * Gets a value indicating the number of loading errors
  329. * @ignorenaming
  330. */
  331. static errorsCount: number;
  332. /**
  333. * Callback called when a new log is added
  334. */
  335. static OnNewCacheEntry: (entry: string) => void;
  336. private static _AddLogEntry;
  337. private static _FormatMessage;
  338. private static _LogDisabled;
  339. private static _LogEnabled;
  340. private static _WarnDisabled;
  341. private static _WarnEnabled;
  342. private static _ErrorDisabled;
  343. private static _ErrorEnabled;
  344. /**
  345. * Log a message to the console
  346. */
  347. static Log: (message: string) => void;
  348. /**
  349. * Write a warning message to the console
  350. */
  351. static Warn: (message: string) => void;
  352. /**
  353. * Write an error message to the console
  354. */
  355. static Error: (message: string) => void;
  356. /**
  357. * Gets current log cache (list of logs)
  358. */
  359. static get LogCache(): string;
  360. /**
  361. * Clears the log cache
  362. */
  363. static ClearLogCache(): void;
  364. /**
  365. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  366. */
  367. static set LogLevels(level: number);
  368. }
  369. }
  370. declare module BABYLON {
  371. /** @hidden */
  372. export class _TypeStore {
  373. /** @hidden */
  374. static RegisteredTypes: {
  375. [key: string]: Object;
  376. };
  377. /** @hidden */
  378. static GetClass(fqdn: string): any;
  379. }
  380. }
  381. declare module BABYLON {
  382. /**
  383. * Helper to manipulate strings
  384. */
  385. export class StringTools {
  386. /**
  387. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  388. * @param str Source string
  389. * @param suffix Suffix to search for in the source string
  390. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  391. */
  392. static EndsWith(str: string, suffix: string): boolean;
  393. /**
  394. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  395. * @param str Source string
  396. * @param suffix Suffix to search for in the source string
  397. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  398. */
  399. static StartsWith(str: string, suffix: string): boolean;
  400. /**
  401. * Decodes a buffer into a string
  402. * @param buffer The buffer to decode
  403. * @returns The decoded string
  404. */
  405. static Decode(buffer: Uint8Array | Uint16Array): string;
  406. /**
  407. * Encode a buffer to a base64 string
  408. * @param buffer defines the buffer to encode
  409. * @returns the encoded string
  410. */
  411. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  412. /**
  413. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  414. * @param num the number to convert and pad
  415. * @param length the expected length of the string
  416. * @returns the padded string
  417. */
  418. static PadNumber(num: number, length: number): string;
  419. }
  420. }
  421. declare module BABYLON {
  422. /**
  423. * Class containing a set of static utilities functions for deep copy.
  424. */
  425. export class DeepCopier {
  426. /**
  427. * Tries to copy an object by duplicating every property
  428. * @param source defines the source object
  429. * @param destination defines the target object
  430. * @param doNotCopyList defines a list of properties to avoid
  431. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  432. */
  433. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  434. }
  435. }
  436. declare module BABYLON {
  437. /**
  438. * Class containing a set of static utilities functions for precision date
  439. */
  440. export class PrecisionDate {
  441. /**
  442. * Gets either window.performance.now() if supported or Date.now() else
  443. */
  444. static get Now(): number;
  445. }
  446. }
  447. declare module BABYLON {
  448. /** @hidden */
  449. export class _DevTools {
  450. static WarnImport(name: string): string;
  451. }
  452. }
  453. declare module BABYLON {
  454. /**
  455. * Interface used to define the mechanism to get data from the network
  456. */
  457. export interface IWebRequest {
  458. /**
  459. * Returns client's response url
  460. */
  461. responseURL: string;
  462. /**
  463. * Returns client's status
  464. */
  465. status: number;
  466. /**
  467. * Returns client's status as a text
  468. */
  469. statusText: string;
  470. }
  471. }
  472. declare module BABYLON {
  473. /**
  474. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  475. */
  476. export class WebRequest implements IWebRequest {
  477. private _xhr;
  478. /**
  479. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  480. * i.e. when loading files, where the server/service expects an Authorization header
  481. */
  482. static CustomRequestHeaders: {
  483. [key: string]: string;
  484. };
  485. /**
  486. * Add callback functions in this array to update all the requests before they get sent to the network
  487. */
  488. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  489. private _injectCustomRequestHeaders;
  490. /**
  491. * Gets or sets a function to be called when loading progress changes
  492. */
  493. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  494. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  495. /**
  496. * Returns client's state
  497. */
  498. get readyState(): number;
  499. /**
  500. * Returns client's status
  501. */
  502. get status(): number;
  503. /**
  504. * Returns client's status as a text
  505. */
  506. get statusText(): string;
  507. /**
  508. * Returns client's response
  509. */
  510. get response(): any;
  511. /**
  512. * Returns client's response url
  513. */
  514. get responseURL(): string;
  515. /**
  516. * Returns client's response as text
  517. */
  518. get responseText(): string;
  519. /**
  520. * Gets or sets the expected response type
  521. */
  522. get responseType(): XMLHttpRequestResponseType;
  523. set responseType(value: XMLHttpRequestResponseType);
  524. /** @hidden */
  525. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  526. /** @hidden */
  527. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  528. /**
  529. * Cancels any network activity
  530. */
  531. abort(): void;
  532. /**
  533. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  534. * @param body defines an optional request body
  535. */
  536. send(body?: Document | BodyInit | null): void;
  537. /**
  538. * Sets the request method, request URL
  539. * @param method defines the method to use (GET, POST, etc..)
  540. * @param url defines the url to connect with
  541. */
  542. open(method: string, url: string): void;
  543. /**
  544. * Sets the value of a request header.
  545. * @param name The name of the header whose value is to be set
  546. * @param value The value to set as the body of the header
  547. */
  548. setRequestHeader(name: string, value: string): void;
  549. /**
  550. * Get the string containing the text of a particular header's value.
  551. * @param name The name of the header
  552. * @returns The string containing the text of the given header name
  553. */
  554. getResponseHeader(name: string): Nullable<string>;
  555. }
  556. }
  557. declare module BABYLON {
  558. /**
  559. * File request interface
  560. */
  561. export interface IFileRequest {
  562. /**
  563. * Raised when the request is complete (success or error).
  564. */
  565. onCompleteObservable: Observable<IFileRequest>;
  566. /**
  567. * Aborts the request for a file.
  568. */
  569. abort: () => void;
  570. }
  571. }
  572. declare module BABYLON {
  573. /**
  574. * Define options used to create a render target texture
  575. */
  576. export class RenderTargetCreationOptions {
  577. /**
  578. * Specifies is mipmaps must be generated
  579. */
  580. generateMipMaps?: boolean;
  581. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  582. generateDepthBuffer?: boolean;
  583. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  584. generateStencilBuffer?: boolean;
  585. /** Defines texture type (int by default) */
  586. type?: number;
  587. /** Defines sampling mode (trilinear by default) */
  588. samplingMode?: number;
  589. /** Defines format (RGBA by default) */
  590. format?: number;
  591. }
  592. }
  593. declare module BABYLON {
  594. /** Defines the cross module used constants to avoid circular dependncies */
  595. export class Constants {
  596. /** Defines that alpha blending is disabled */
  597. static readonly ALPHA_DISABLE: number;
  598. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  599. static readonly ALPHA_ADD: number;
  600. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  601. static readonly ALPHA_COMBINE: number;
  602. /** Defines that alpha blending is DEST - SRC * DEST */
  603. static readonly ALPHA_SUBTRACT: number;
  604. /** Defines that alpha blending is SRC * DEST */
  605. static readonly ALPHA_MULTIPLY: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  607. static readonly ALPHA_MAXIMIZED: number;
  608. /** Defines that alpha blending is SRC + DEST */
  609. static readonly ALPHA_ONEONE: number;
  610. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  611. static readonly ALPHA_PREMULTIPLIED: number;
  612. /**
  613. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  614. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  615. */
  616. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  617. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  618. static readonly ALPHA_INTERPOLATE: number;
  619. /**
  620. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  621. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  622. */
  623. static readonly ALPHA_SCREENMODE: number;
  624. /**
  625. * Defines that alpha blending is SRC + DST
  626. * Alpha will be set to SRC ALPHA + DST ALPHA
  627. */
  628. static readonly ALPHA_ONEONE_ONEONE: number;
  629. /**
  630. * Defines that alpha blending is SRC * DST ALPHA + DST
  631. * Alpha will be set to 0
  632. */
  633. static readonly ALPHA_ALPHATOCOLOR: number;
  634. /**
  635. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  636. */
  637. static readonly ALPHA_REVERSEONEMINUS: number;
  638. /**
  639. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  640. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  641. */
  642. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  643. /**
  644. * Defines that alpha blending is SRC + DST
  645. * Alpha will be set to SRC ALPHA
  646. */
  647. static readonly ALPHA_ONEONE_ONEZERO: number;
  648. /**
  649. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  650. * Alpha will be set to DST ALPHA
  651. */
  652. static readonly ALPHA_EXCLUSION: number;
  653. /** Defines that alpha blending equation a SUM */
  654. static readonly ALPHA_EQUATION_ADD: number;
  655. /** Defines that alpha blending equation a SUBSTRACTION */
  656. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  657. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  658. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  659. /** Defines that alpha blending equation a MAX operation */
  660. static readonly ALPHA_EQUATION_MAX: number;
  661. /** Defines that alpha blending equation a MIN operation */
  662. static readonly ALPHA_EQUATION_MIN: number;
  663. /**
  664. * Defines that alpha blending equation a DARKEN operation:
  665. * It takes the min of the src and sums the alpha channels.
  666. */
  667. static readonly ALPHA_EQUATION_DARKEN: number;
  668. /** Defines that the ressource is not delayed*/
  669. static readonly DELAYLOADSTATE_NONE: number;
  670. /** Defines that the ressource was successfully delay loaded */
  671. static readonly DELAYLOADSTATE_LOADED: number;
  672. /** Defines that the ressource is currently delay loading */
  673. static readonly DELAYLOADSTATE_LOADING: number;
  674. /** Defines that the ressource is delayed and has not started loading */
  675. static readonly DELAYLOADSTATE_NOTLOADED: number;
  676. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  677. static readonly NEVER: number;
  678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  679. static readonly ALWAYS: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  681. static readonly LESS: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  683. static readonly EQUAL: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  685. static readonly LEQUAL: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  687. static readonly GREATER: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  689. static readonly GEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  691. static readonly NOTEQUAL: number;
  692. /** Passed to stencilOperation to specify that stencil value must be kept */
  693. static readonly KEEP: number;
  694. /** Passed to stencilOperation to specify that stencil value must be replaced */
  695. static readonly REPLACE: number;
  696. /** Passed to stencilOperation to specify that stencil value must be incremented */
  697. static readonly INCR: number;
  698. /** Passed to stencilOperation to specify that stencil value must be decremented */
  699. static readonly DECR: number;
  700. /** Passed to stencilOperation to specify that stencil value must be inverted */
  701. static readonly INVERT: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  703. static readonly INCR_WRAP: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  705. static readonly DECR_WRAP: number;
  706. /** Texture is not repeating outside of 0..1 UVs */
  707. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  708. /** Texture is repeating outside of 0..1 UVs */
  709. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  710. /** Texture is repeating and mirrored */
  711. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  712. /** ALPHA */
  713. static readonly TEXTUREFORMAT_ALPHA: number;
  714. /** LUMINANCE */
  715. static readonly TEXTUREFORMAT_LUMINANCE: number;
  716. /** LUMINANCE_ALPHA */
  717. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  718. /** RGB */
  719. static readonly TEXTUREFORMAT_RGB: number;
  720. /** RGBA */
  721. static readonly TEXTUREFORMAT_RGBA: number;
  722. /** RED */
  723. static readonly TEXTUREFORMAT_RED: number;
  724. /** RED (2nd reference) */
  725. static readonly TEXTUREFORMAT_R: number;
  726. /** RG */
  727. static readonly TEXTUREFORMAT_RG: number;
  728. /** RED_INTEGER */
  729. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  730. /** RED_INTEGER (2nd reference) */
  731. static readonly TEXTUREFORMAT_R_INTEGER: number;
  732. /** RG_INTEGER */
  733. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  734. /** RGB_INTEGER */
  735. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  736. /** RGBA_INTEGER */
  737. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  738. /** UNSIGNED_BYTE */
  739. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  740. /** UNSIGNED_BYTE (2nd reference) */
  741. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  742. /** FLOAT */
  743. static readonly TEXTURETYPE_FLOAT: number;
  744. /** HALF_FLOAT */
  745. static readonly TEXTURETYPE_HALF_FLOAT: number;
  746. /** BYTE */
  747. static readonly TEXTURETYPE_BYTE: number;
  748. /** SHORT */
  749. static readonly TEXTURETYPE_SHORT: number;
  750. /** UNSIGNED_SHORT */
  751. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  752. /** INT */
  753. static readonly TEXTURETYPE_INT: number;
  754. /** UNSIGNED_INT */
  755. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  756. /** UNSIGNED_SHORT_4_4_4_4 */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  758. /** UNSIGNED_SHORT_5_5_5_1 */
  759. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  760. /** UNSIGNED_SHORT_5_6_5 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  762. /** UNSIGNED_INT_2_10_10_10_REV */
  763. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  764. /** UNSIGNED_INT_24_8 */
  765. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  766. /** UNSIGNED_INT_10F_11F_11F_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  768. /** UNSIGNED_INT_5_9_9_9_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  770. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  771. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  772. /** nearest is mag = nearest and min = nearest and no mip */
  773. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  774. /** mag = nearest and min = nearest and mip = none */
  775. static readonly TEXTURE_NEAREST_NEAREST: number;
  776. /** Bilinear is mag = linear and min = linear and no mip */
  777. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  778. /** mag = linear and min = linear and mip = none */
  779. static readonly TEXTURE_LINEAR_LINEAR: number;
  780. /** Trilinear is mag = linear and min = linear and mip = linear */
  781. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  782. /** Trilinear is mag = linear and min = linear and mip = linear */
  783. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  784. /** mag = nearest and min = nearest and mip = nearest */
  785. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  786. /** mag = nearest and min = linear and mip = nearest */
  787. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  788. /** mag = nearest and min = linear and mip = linear */
  789. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = linear and mip = none */
  791. static readonly TEXTURE_NEAREST_LINEAR: number;
  792. /** nearest is mag = nearest and min = nearest and mip = linear */
  793. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  794. /** mag = linear and min = nearest and mip = nearest */
  795. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  796. /** mag = linear and min = nearest and mip = linear */
  797. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  798. /** Bilinear is mag = linear and min = linear and mip = nearest */
  799. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = none */
  801. static readonly TEXTURE_LINEAR_NEAREST: number;
  802. /** Explicit coordinates mode */
  803. static readonly TEXTURE_EXPLICIT_MODE: number;
  804. /** Spherical coordinates mode */
  805. static readonly TEXTURE_SPHERICAL_MODE: number;
  806. /** Planar coordinates mode */
  807. static readonly TEXTURE_PLANAR_MODE: number;
  808. /** Cubic coordinates mode */
  809. static readonly TEXTURE_CUBIC_MODE: number;
  810. /** Projection coordinates mode */
  811. static readonly TEXTURE_PROJECTION_MODE: number;
  812. /** Skybox coordinates mode */
  813. static readonly TEXTURE_SKYBOX_MODE: number;
  814. /** Inverse Cubic coordinates mode */
  815. static readonly TEXTURE_INVCUBIC_MODE: number;
  816. /** Equirectangular coordinates mode */
  817. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  818. /** Equirectangular Fixed coordinates mode */
  819. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  820. /** Equirectangular Fixed Mirrored coordinates mode */
  821. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  822. /** Offline (baking) quality for texture filtering */
  823. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  824. /** High quality for texture filtering */
  825. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  826. /** Medium quality for texture filtering */
  827. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  828. /** Low quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  830. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  831. static readonly SCALEMODE_FLOOR: number;
  832. /** Defines that texture rescaling will look for the nearest power of 2 size */
  833. static readonly SCALEMODE_NEAREST: number;
  834. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  835. static readonly SCALEMODE_CEILING: number;
  836. /**
  837. * The dirty texture flag value
  838. */
  839. static readonly MATERIAL_TextureDirtyFlag: number;
  840. /**
  841. * The dirty light flag value
  842. */
  843. static readonly MATERIAL_LightDirtyFlag: number;
  844. /**
  845. * The dirty fresnel flag value
  846. */
  847. static readonly MATERIAL_FresnelDirtyFlag: number;
  848. /**
  849. * The dirty attribute flag value
  850. */
  851. static readonly MATERIAL_AttributesDirtyFlag: number;
  852. /**
  853. * The dirty misc flag value
  854. */
  855. static readonly MATERIAL_MiscDirtyFlag: number;
  856. /**
  857. * The all dirty flag value
  858. */
  859. static readonly MATERIAL_AllDirtyFlag: number;
  860. /**
  861. * Returns the triangle fill mode
  862. */
  863. static readonly MATERIAL_TriangleFillMode: number;
  864. /**
  865. * Returns the wireframe mode
  866. */
  867. static readonly MATERIAL_WireFrameFillMode: number;
  868. /**
  869. * Returns the point fill mode
  870. */
  871. static readonly MATERIAL_PointFillMode: number;
  872. /**
  873. * Returns the point list draw mode
  874. */
  875. static readonly MATERIAL_PointListDrawMode: number;
  876. /**
  877. * Returns the line list draw mode
  878. */
  879. static readonly MATERIAL_LineListDrawMode: number;
  880. /**
  881. * Returns the line loop draw mode
  882. */
  883. static readonly MATERIAL_LineLoopDrawMode: number;
  884. /**
  885. * Returns the line strip draw mode
  886. */
  887. static readonly MATERIAL_LineStripDrawMode: number;
  888. /**
  889. * Returns the triangle strip draw mode
  890. */
  891. static readonly MATERIAL_TriangleStripDrawMode: number;
  892. /**
  893. * Returns the triangle fan draw mode
  894. */
  895. static readonly MATERIAL_TriangleFanDrawMode: number;
  896. /**
  897. * Stores the clock-wise side orientation
  898. */
  899. static readonly MATERIAL_ClockWiseSideOrientation: number;
  900. /**
  901. * Stores the counter clock-wise side orientation
  902. */
  903. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  904. /**
  905. * Nothing
  906. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  907. */
  908. static readonly ACTION_NothingTrigger: number;
  909. /**
  910. * On pick
  911. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  912. */
  913. static readonly ACTION_OnPickTrigger: number;
  914. /**
  915. * On left pick
  916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_OnLeftPickTrigger: number;
  919. /**
  920. * On right pick
  921. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnRightPickTrigger: number;
  924. /**
  925. * On center pick
  926. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  927. */
  928. static readonly ACTION_OnCenterPickTrigger: number;
  929. /**
  930. * On pick down
  931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnPickDownTrigger: number;
  934. /**
  935. * On double pick
  936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnDoublePickTrigger: number;
  939. /**
  940. * On pick up
  941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPickUpTrigger: number;
  944. /**
  945. * On pick out.
  946. * This trigger will only be raised if you also declared a OnPickDown
  947. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  948. */
  949. static readonly ACTION_OnPickOutTrigger: number;
  950. /**
  951. * On long press
  952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  953. */
  954. static readonly ACTION_OnLongPressTrigger: number;
  955. /**
  956. * On pointer over
  957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  958. */
  959. static readonly ACTION_OnPointerOverTrigger: number;
  960. /**
  961. * On pointer out
  962. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  963. */
  964. static readonly ACTION_OnPointerOutTrigger: number;
  965. /**
  966. * On every frame
  967. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  968. */
  969. static readonly ACTION_OnEveryFrameTrigger: number;
  970. /**
  971. * On intersection enter
  972. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  973. */
  974. static readonly ACTION_OnIntersectionEnterTrigger: number;
  975. /**
  976. * On intersection exit
  977. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  978. */
  979. static readonly ACTION_OnIntersectionExitTrigger: number;
  980. /**
  981. * On key down
  982. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  983. */
  984. static readonly ACTION_OnKeyDownTrigger: number;
  985. /**
  986. * On key up
  987. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  988. */
  989. static readonly ACTION_OnKeyUpTrigger: number;
  990. /**
  991. * Billboard mode will only apply to Y axis
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  994. /**
  995. * Billboard mode will apply to all axes
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  998. /**
  999. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1002. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1003. * Test order :
  1004. * Is the bounding sphere outside the frustum ?
  1005. * If not, are the bounding box vertices outside the frustum ?
  1006. * It not, then the cullable object is in the frustum.
  1007. */
  1008. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1009. /** Culling strategy : Bounding Sphere Only.
  1010. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1011. * It's also less accurate than the standard because some not visible objects can still be selected.
  1012. * Test : is the bounding sphere outside the frustum ?
  1013. * If not, then the cullable object is in the frustum.
  1014. */
  1015. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1016. /** Culling strategy : Optimistic Inclusion.
  1017. * This in an inclusion test first, then the standard exclusion test.
  1018. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1019. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1020. * Anyway, it's as accurate as the standard strategy.
  1021. * Test :
  1022. * Is the cullable object bounding sphere center in the frustum ?
  1023. * If not, apply the default culling strategy.
  1024. */
  1025. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1026. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1027. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1028. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1029. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1030. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1031. * Test :
  1032. * Is the cullable object bounding sphere center in the frustum ?
  1033. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1034. */
  1035. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1036. /**
  1037. * No logging while loading
  1038. */
  1039. static readonly SCENELOADER_NO_LOGGING: number;
  1040. /**
  1041. * Minimal logging while loading
  1042. */
  1043. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1044. /**
  1045. * Summary logging while loading
  1046. */
  1047. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1048. /**
  1049. * Detailled logging while loading
  1050. */
  1051. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1052. }
  1053. }
  1054. declare module BABYLON {
  1055. /**
  1056. * This represents the required contract to create a new type of texture loader.
  1057. */
  1058. export interface IInternalTextureLoader {
  1059. /**
  1060. * Defines wether the loader supports cascade loading the different faces.
  1061. */
  1062. supportCascades: boolean;
  1063. /**
  1064. * This returns if the loader support the current file information.
  1065. * @param extension defines the file extension of the file being loaded
  1066. * @returns true if the loader can load the specified file
  1067. */
  1068. canLoad(extension: string): boolean;
  1069. /**
  1070. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1071. * @param data contains the texture data
  1072. * @param texture defines the BabylonJS internal texture
  1073. * @param createPolynomials will be true if polynomials have been requested
  1074. * @param onLoad defines the callback to trigger once the texture is ready
  1075. * @param onError defines the callback to trigger in case of error
  1076. */
  1077. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1078. /**
  1079. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1080. * @param data contains the texture data
  1081. * @param texture defines the BabylonJS internal texture
  1082. * @param callback defines the method to call once ready to upload
  1083. */
  1084. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1085. }
  1086. }
  1087. declare module BABYLON {
  1088. /**
  1089. * Class used to store and describe the pipeline context associated with an effect
  1090. */
  1091. export interface IPipelineContext {
  1092. /**
  1093. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1094. */
  1095. isAsync: boolean;
  1096. /**
  1097. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1098. */
  1099. isReady: boolean;
  1100. /** @hidden */
  1101. _getVertexShaderCode(): string | null;
  1102. /** @hidden */
  1103. _getFragmentShaderCode(): string | null;
  1104. /** @hidden */
  1105. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1106. }
  1107. }
  1108. declare module BABYLON {
  1109. /**
  1110. * Class used to store gfx data (like WebGLBuffer)
  1111. */
  1112. export class DataBuffer {
  1113. /**
  1114. * Gets or sets the number of objects referencing this buffer
  1115. */
  1116. references: number;
  1117. /** Gets or sets the size of the underlying buffer */
  1118. capacity: number;
  1119. /**
  1120. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1121. */
  1122. is32Bits: boolean;
  1123. /**
  1124. * Gets the underlying buffer
  1125. */
  1126. get underlyingResource(): any;
  1127. }
  1128. }
  1129. declare module BABYLON {
  1130. /** @hidden */
  1131. export interface IShaderProcessor {
  1132. attributeProcessor?: (attribute: string) => string;
  1133. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1134. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1135. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1136. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1137. lineProcessor?: (line: string, isFragment: boolean) => string;
  1138. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1139. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1140. }
  1141. }
  1142. declare module BABYLON {
  1143. /** @hidden */
  1144. export interface ProcessingOptions {
  1145. defines: string[];
  1146. indexParameters: any;
  1147. isFragment: boolean;
  1148. shouldUseHighPrecisionShader: boolean;
  1149. supportsUniformBuffers: boolean;
  1150. shadersRepository: string;
  1151. includesShadersStore: {
  1152. [key: string]: string;
  1153. };
  1154. processor?: IShaderProcessor;
  1155. version: string;
  1156. platformName: string;
  1157. lookForClosingBracketForUniformBuffer?: boolean;
  1158. }
  1159. }
  1160. declare module BABYLON {
  1161. /** @hidden */
  1162. export class ShaderCodeNode {
  1163. line: string;
  1164. children: ShaderCodeNode[];
  1165. additionalDefineKey?: string;
  1166. additionalDefineValue?: string;
  1167. isValid(preprocessors: {
  1168. [key: string]: string;
  1169. }): boolean;
  1170. process(preprocessors: {
  1171. [key: string]: string;
  1172. }, options: ProcessingOptions): string;
  1173. }
  1174. }
  1175. declare module BABYLON {
  1176. /** @hidden */
  1177. export class ShaderCodeCursor {
  1178. private _lines;
  1179. lineIndex: number;
  1180. get currentLine(): string;
  1181. get canRead(): boolean;
  1182. set lines(value: string[]);
  1183. }
  1184. }
  1185. declare module BABYLON {
  1186. /** @hidden */
  1187. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1188. process(preprocessors: {
  1189. [key: string]: string;
  1190. }, options: ProcessingOptions): string;
  1191. }
  1192. }
  1193. declare module BABYLON {
  1194. /** @hidden */
  1195. export class ShaderDefineExpression {
  1196. isTrue(preprocessors: {
  1197. [key: string]: string;
  1198. }): boolean;
  1199. private static _OperatorPriority;
  1200. private static _Stack;
  1201. static postfixToInfix(postfix: string[]): string;
  1202. static infixToPostfix(infix: string): string[];
  1203. }
  1204. }
  1205. declare module BABYLON {
  1206. /** @hidden */
  1207. export class ShaderCodeTestNode extends ShaderCodeNode {
  1208. testExpression: ShaderDefineExpression;
  1209. isValid(preprocessors: {
  1210. [key: string]: string;
  1211. }): boolean;
  1212. }
  1213. }
  1214. declare module BABYLON {
  1215. /** @hidden */
  1216. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1217. define: string;
  1218. not: boolean;
  1219. constructor(define: string, not?: boolean);
  1220. isTrue(preprocessors: {
  1221. [key: string]: string;
  1222. }): boolean;
  1223. }
  1224. }
  1225. declare module BABYLON {
  1226. /** @hidden */
  1227. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1228. leftOperand: ShaderDefineExpression;
  1229. rightOperand: ShaderDefineExpression;
  1230. isTrue(preprocessors: {
  1231. [key: string]: string;
  1232. }): boolean;
  1233. }
  1234. }
  1235. declare module BABYLON {
  1236. /** @hidden */
  1237. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1238. leftOperand: ShaderDefineExpression;
  1239. rightOperand: ShaderDefineExpression;
  1240. isTrue(preprocessors: {
  1241. [key: string]: string;
  1242. }): boolean;
  1243. }
  1244. }
  1245. declare module BABYLON {
  1246. /** @hidden */
  1247. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1248. define: string;
  1249. operand: string;
  1250. testValue: string;
  1251. constructor(define: string, operand: string, testValue: string);
  1252. isTrue(preprocessors: {
  1253. [key: string]: string;
  1254. }): boolean;
  1255. }
  1256. }
  1257. declare module BABYLON {
  1258. /**
  1259. * Class used to enable access to offline support
  1260. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1261. */
  1262. export interface IOfflineProvider {
  1263. /**
  1264. * Gets a boolean indicating if scene must be saved in the database
  1265. */
  1266. enableSceneOffline: boolean;
  1267. /**
  1268. * Gets a boolean indicating if textures must be saved in the database
  1269. */
  1270. enableTexturesOffline: boolean;
  1271. /**
  1272. * Open the offline support and make it available
  1273. * @param successCallback defines the callback to call on success
  1274. * @param errorCallback defines the callback to call on error
  1275. */
  1276. open(successCallback: () => void, errorCallback: () => void): void;
  1277. /**
  1278. * Loads an image from the offline support
  1279. * @param url defines the url to load from
  1280. * @param image defines the target DOM image
  1281. */
  1282. loadImage(url: string, image: HTMLImageElement): void;
  1283. /**
  1284. * Loads a file from offline support
  1285. * @param url defines the URL to load from
  1286. * @param sceneLoaded defines a callback to call on success
  1287. * @param progressCallBack defines a callback to call when progress changed
  1288. * @param errorCallback defines a callback to call on error
  1289. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1290. */
  1291. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1292. }
  1293. }
  1294. declare module BABYLON {
  1295. /**
  1296. * Class used to help managing file picking and drag'n'drop
  1297. * File Storage
  1298. */
  1299. export class FilesInputStore {
  1300. /**
  1301. * List of files ready to be loaded
  1302. */
  1303. static FilesToLoad: {
  1304. [key: string]: File;
  1305. };
  1306. }
  1307. }
  1308. declare module BABYLON {
  1309. /**
  1310. * Class used to define a retry strategy when error happens while loading assets
  1311. */
  1312. export class RetryStrategy {
  1313. /**
  1314. * Function used to defines an exponential back off strategy
  1315. * @param maxRetries defines the maximum number of retries (3 by default)
  1316. * @param baseInterval defines the interval between retries
  1317. * @returns the strategy function to use
  1318. */
  1319. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1320. }
  1321. }
  1322. declare module BABYLON {
  1323. /**
  1324. * @ignore
  1325. * Application error to support additional information when loading a file
  1326. */
  1327. export abstract class BaseError extends Error {
  1328. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1329. }
  1330. }
  1331. declare module BABYLON {
  1332. /** @ignore */
  1333. export class LoadFileError extends BaseError {
  1334. request?: WebRequest;
  1335. file?: File;
  1336. /**
  1337. * Creates a new LoadFileError
  1338. * @param message defines the message of the error
  1339. * @param request defines the optional web request
  1340. * @param file defines the optional file
  1341. */
  1342. constructor(message: string, object?: WebRequest | File);
  1343. }
  1344. /** @ignore */
  1345. export class RequestFileError extends BaseError {
  1346. request: WebRequest;
  1347. /**
  1348. * Creates a new LoadFileError
  1349. * @param message defines the message of the error
  1350. * @param request defines the optional web request
  1351. */
  1352. constructor(message: string, request: WebRequest);
  1353. }
  1354. /** @ignore */
  1355. export class ReadFileError extends BaseError {
  1356. file: File;
  1357. /**
  1358. * Creates a new ReadFileError
  1359. * @param message defines the message of the error
  1360. * @param file defines the optional file
  1361. */
  1362. constructor(message: string, file: File);
  1363. }
  1364. /**
  1365. * @hidden
  1366. */
  1367. export class FileTools {
  1368. /**
  1369. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1370. */
  1371. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1372. /**
  1373. * Gets or sets the base URL to use to load assets
  1374. */
  1375. static BaseUrl: string;
  1376. /**
  1377. * Default behaviour for cors in the application.
  1378. * It can be a string if the expected behavior is identical in the entire app.
  1379. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1380. */
  1381. static CorsBehavior: string | ((url: string | string[]) => string);
  1382. /**
  1383. * Gets or sets a function used to pre-process url before using them to load assets
  1384. */
  1385. static PreprocessUrl: (url: string) => string;
  1386. /**
  1387. * Removes unwanted characters from an url
  1388. * @param url defines the url to clean
  1389. * @returns the cleaned url
  1390. */
  1391. private static _CleanUrl;
  1392. /**
  1393. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1394. * @param url define the url we are trying
  1395. * @param element define the dom element where to configure the cors policy
  1396. */
  1397. static SetCorsBehavior(url: string | string[], element: {
  1398. crossOrigin: string | null;
  1399. }): void;
  1400. /**
  1401. * Loads an image as an HTMLImageElement.
  1402. * @param input url string, ArrayBuffer, or Blob to load
  1403. * @param onLoad callback called when the image successfully loads
  1404. * @param onError callback called when the image fails to load
  1405. * @param offlineProvider offline provider for caching
  1406. * @param mimeType optional mime type
  1407. * @returns the HTMLImageElement of the loaded image
  1408. */
  1409. 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>;
  1410. /**
  1411. * Reads a file from a File object
  1412. * @param file defines the file to load
  1413. * @param onSuccess defines the callback to call when data is loaded
  1414. * @param onProgress defines the callback to call during loading process
  1415. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1416. * @param onError defines the callback to call when an error occurs
  1417. * @returns a file request object
  1418. */
  1419. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1420. /**
  1421. * Loads a file from a url
  1422. * @param url url to load
  1423. * @param onSuccess callback called when the file successfully loads
  1424. * @param onProgress callback called while file is loading (if the server supports this mode)
  1425. * @param offlineProvider defines the offline provider for caching
  1426. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1427. * @param onError callback called when the file fails to load
  1428. * @returns a file request object
  1429. */
  1430. 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;
  1431. /**
  1432. * Loads a file
  1433. * @param url url to load
  1434. * @param onSuccess callback called when the file successfully loads
  1435. * @param onProgress callback called while file is loading (if the server supports this mode)
  1436. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1437. * @param onError callback called when the file fails to load
  1438. * @param onOpened callback called when the web request is opened
  1439. * @returns a file request object
  1440. */
  1441. 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;
  1442. /**
  1443. * Checks if the loaded document was accessed via `file:`-Protocol.
  1444. * @returns boolean
  1445. */
  1446. static IsFileURL(): boolean;
  1447. }
  1448. }
  1449. declare module BABYLON {
  1450. /** @hidden */
  1451. export class ShaderProcessor {
  1452. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1453. private static _ProcessPrecision;
  1454. private static _ExtractOperation;
  1455. private static _BuildSubExpression;
  1456. private static _BuildExpression;
  1457. private static _MoveCursorWithinIf;
  1458. private static _MoveCursor;
  1459. private static _EvaluatePreProcessors;
  1460. private static _PreparePreProcessors;
  1461. private static _ProcessShaderConversion;
  1462. private static _ProcessIncludes;
  1463. /**
  1464. * Loads a file from a url
  1465. * @param url url to load
  1466. * @param onSuccess callback called when the file successfully loads
  1467. * @param onProgress callback called while file is loading (if the server supports this mode)
  1468. * @param offlineProvider defines the offline provider for caching
  1469. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1470. * @param onError callback called when the file fails to load
  1471. * @returns a file request object
  1472. * @hidden
  1473. */
  1474. 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;
  1475. }
  1476. }
  1477. declare module BABYLON {
  1478. /**
  1479. * @hidden
  1480. */
  1481. export interface IColor4Like {
  1482. r: float;
  1483. g: float;
  1484. b: float;
  1485. a: float;
  1486. }
  1487. /**
  1488. * @hidden
  1489. */
  1490. export interface IColor3Like {
  1491. r: float;
  1492. g: float;
  1493. b: float;
  1494. }
  1495. /**
  1496. * @hidden
  1497. */
  1498. export interface IVector4Like {
  1499. x: float;
  1500. y: float;
  1501. z: float;
  1502. w: float;
  1503. }
  1504. /**
  1505. * @hidden
  1506. */
  1507. export interface IVector3Like {
  1508. x: float;
  1509. y: float;
  1510. z: float;
  1511. }
  1512. /**
  1513. * @hidden
  1514. */
  1515. export interface IVector2Like {
  1516. x: float;
  1517. y: float;
  1518. }
  1519. /**
  1520. * @hidden
  1521. */
  1522. export interface IMatrixLike {
  1523. toArray(): DeepImmutable<Float32Array>;
  1524. updateFlag: int;
  1525. }
  1526. /**
  1527. * @hidden
  1528. */
  1529. export interface IViewportLike {
  1530. x: float;
  1531. y: float;
  1532. width: float;
  1533. height: float;
  1534. }
  1535. /**
  1536. * @hidden
  1537. */
  1538. export interface IPlaneLike {
  1539. normal: IVector3Like;
  1540. d: float;
  1541. normalize(): void;
  1542. }
  1543. }
  1544. declare module BABYLON {
  1545. /**
  1546. * Interface used to define common properties for effect fallbacks
  1547. */
  1548. export interface IEffectFallbacks {
  1549. /**
  1550. * Removes the defines that should be removed when falling back.
  1551. * @param currentDefines defines the current define statements for the shader.
  1552. * @param effect defines the current effect we try to compile
  1553. * @returns The resulting defines with defines of the current rank removed.
  1554. */
  1555. reduce(currentDefines: string, effect: Effect): string;
  1556. /**
  1557. * Removes the fallback from the bound mesh.
  1558. */
  1559. unBindMesh(): void;
  1560. /**
  1561. * Checks to see if more fallbacks are still availible.
  1562. */
  1563. hasMoreFallbacks: boolean;
  1564. }
  1565. }
  1566. declare module BABYLON {
  1567. /**
  1568. * Class used to evalaute queries containing `and` and `or` operators
  1569. */
  1570. export class AndOrNotEvaluator {
  1571. /**
  1572. * Evaluate a query
  1573. * @param query defines the query to evaluate
  1574. * @param evaluateCallback defines the callback used to filter result
  1575. * @returns true if the query matches
  1576. */
  1577. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1578. private static _HandleParenthesisContent;
  1579. private static _SimplifyNegation;
  1580. }
  1581. }
  1582. declare module BABYLON {
  1583. /**
  1584. * Class used to store custom tags
  1585. */
  1586. export class Tags {
  1587. /**
  1588. * Adds support for tags on the given object
  1589. * @param obj defines the object to use
  1590. */
  1591. static EnableFor(obj: any): void;
  1592. /**
  1593. * Removes tags support
  1594. * @param obj defines the object to use
  1595. */
  1596. static DisableFor(obj: any): void;
  1597. /**
  1598. * Gets a boolean indicating if the given object has tags
  1599. * @param obj defines the object to use
  1600. * @returns a boolean
  1601. */
  1602. static HasTags(obj: any): boolean;
  1603. /**
  1604. * Gets the tags available on a given object
  1605. * @param obj defines the object to use
  1606. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1607. * @returns the tags
  1608. */
  1609. static GetTags(obj: any, asString?: boolean): any;
  1610. /**
  1611. * Adds tags to an object
  1612. * @param obj defines the object to use
  1613. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1614. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1615. */
  1616. static AddTagsTo(obj: any, tagsString: string): void;
  1617. /**
  1618. * @hidden
  1619. */
  1620. static _AddTagTo(obj: any, tag: string): void;
  1621. /**
  1622. * Removes specific tags from a specific object
  1623. * @param obj defines the object to use
  1624. * @param tagsString defines the tags to remove
  1625. */
  1626. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1627. /**
  1628. * @hidden
  1629. */
  1630. static _RemoveTagFrom(obj: any, tag: string): void;
  1631. /**
  1632. * Defines if tags hosted on an object match a given query
  1633. * @param obj defines the object to use
  1634. * @param tagsQuery defines the tag query
  1635. * @returns a boolean
  1636. */
  1637. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1638. }
  1639. }
  1640. declare module BABYLON {
  1641. /**
  1642. * Scalar computation library
  1643. */
  1644. export class Scalar {
  1645. /**
  1646. * Two pi constants convenient for computation.
  1647. */
  1648. static TwoPi: number;
  1649. /**
  1650. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1651. * @param a number
  1652. * @param b number
  1653. * @param epsilon (default = 1.401298E-45)
  1654. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1655. */
  1656. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1657. /**
  1658. * Returns a string : the upper case translation of the number i to hexadecimal.
  1659. * @param i number
  1660. * @returns the upper case translation of the number i to hexadecimal.
  1661. */
  1662. static ToHex(i: number): string;
  1663. /**
  1664. * Returns -1 if value is negative and +1 is value is positive.
  1665. * @param value the value
  1666. * @returns the value itself if it's equal to zero.
  1667. */
  1668. static Sign(value: number): number;
  1669. /**
  1670. * Returns the value itself if it's between min and max.
  1671. * Returns min if the value is lower than min.
  1672. * Returns max if the value is greater than max.
  1673. * @param value the value to clmap
  1674. * @param min the min value to clamp to (default: 0)
  1675. * @param max the max value to clamp to (default: 1)
  1676. * @returns the clamped value
  1677. */
  1678. static Clamp(value: number, min?: number, max?: number): number;
  1679. /**
  1680. * the log2 of value.
  1681. * @param value the value to compute log2 of
  1682. * @returns the log2 of value.
  1683. */
  1684. static Log2(value: number): number;
  1685. /**
  1686. * Loops the value, so that it is never larger than length and never smaller than 0.
  1687. *
  1688. * This is similar to the modulo operator but it works with floating point numbers.
  1689. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1690. * With t = 5 and length = 2.5, the result would be 0.0.
  1691. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1692. * @param value the value
  1693. * @param length the length
  1694. * @returns the looped value
  1695. */
  1696. static Repeat(value: number, length: number): number;
  1697. /**
  1698. * Normalize the value between 0.0 and 1.0 using min and max values
  1699. * @param value value to normalize
  1700. * @param min max to normalize between
  1701. * @param max min to normalize between
  1702. * @returns the normalized value
  1703. */
  1704. static Normalize(value: number, min: number, max: number): number;
  1705. /**
  1706. * Denormalize the value from 0.0 and 1.0 using min and max values
  1707. * @param normalized value to denormalize
  1708. * @param min max to denormalize between
  1709. * @param max min to denormalize between
  1710. * @returns the denormalized value
  1711. */
  1712. static Denormalize(normalized: number, min: number, max: number): number;
  1713. /**
  1714. * Calculates the shortest difference between two given angles given in degrees.
  1715. * @param current current angle in degrees
  1716. * @param target target angle in degrees
  1717. * @returns the delta
  1718. */
  1719. static DeltaAngle(current: number, target: number): number;
  1720. /**
  1721. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1722. * @param tx value
  1723. * @param length length
  1724. * @returns The returned value will move back and forth between 0 and length
  1725. */
  1726. static PingPong(tx: number, length: number): number;
  1727. /**
  1728. * Interpolates between min and max with smoothing at the limits.
  1729. *
  1730. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1731. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1732. * @param from from
  1733. * @param to to
  1734. * @param tx value
  1735. * @returns the smooth stepped value
  1736. */
  1737. static SmoothStep(from: number, to: number, tx: number): number;
  1738. /**
  1739. * Moves a value current towards target.
  1740. *
  1741. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1742. * Negative values of maxDelta pushes the value away from target.
  1743. * @param current current value
  1744. * @param target target value
  1745. * @param maxDelta max distance to move
  1746. * @returns resulting value
  1747. */
  1748. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1749. /**
  1750. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1751. *
  1752. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1753. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1754. * @param current current value
  1755. * @param target target value
  1756. * @param maxDelta max distance to move
  1757. * @returns resulting angle
  1758. */
  1759. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1760. /**
  1761. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1762. * @param start start value
  1763. * @param end target value
  1764. * @param amount amount to lerp between
  1765. * @returns the lerped value
  1766. */
  1767. static Lerp(start: number, end: number, amount: number): number;
  1768. /**
  1769. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1770. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1771. * @param start start value
  1772. * @param end target value
  1773. * @param amount amount to lerp between
  1774. * @returns the lerped value
  1775. */
  1776. static LerpAngle(start: number, end: number, amount: number): number;
  1777. /**
  1778. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1779. * @param a start value
  1780. * @param b target value
  1781. * @param value value between a and b
  1782. * @returns the inverseLerp value
  1783. */
  1784. static InverseLerp(a: number, b: number, value: number): number;
  1785. /**
  1786. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1787. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1788. * @param value1 spline value
  1789. * @param tangent1 spline value
  1790. * @param value2 spline value
  1791. * @param tangent2 spline value
  1792. * @param amount input value
  1793. * @returns hermite result
  1794. */
  1795. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1796. /**
  1797. * Returns a random float number between and min and max values
  1798. * @param min min value of random
  1799. * @param max max value of random
  1800. * @returns random value
  1801. */
  1802. static RandomRange(min: number, max: number): number;
  1803. /**
  1804. * This function returns percentage of a number in a given range.
  1805. *
  1806. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1807. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1808. * @param number to convert to percentage
  1809. * @param min min range
  1810. * @param max max range
  1811. * @returns the percentage
  1812. */
  1813. static RangeToPercent(number: number, min: number, max: number): number;
  1814. /**
  1815. * This function returns number that corresponds to the percentage in a given range.
  1816. *
  1817. * PercentToRange(0.34,0,100) will return 34.
  1818. * @param percent to convert to number
  1819. * @param min min range
  1820. * @param max max range
  1821. * @returns the number
  1822. */
  1823. static PercentToRange(percent: number, min: number, max: number): number;
  1824. /**
  1825. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1826. * @param angle The angle to normalize in radian.
  1827. * @return The converted angle.
  1828. */
  1829. static NormalizeRadians(angle: number): number;
  1830. }
  1831. }
  1832. declare module BABYLON {
  1833. /**
  1834. * Constant used to convert a value to gamma space
  1835. * @ignorenaming
  1836. */
  1837. export const ToGammaSpace: number;
  1838. /**
  1839. * Constant used to convert a value to linear space
  1840. * @ignorenaming
  1841. */
  1842. export const ToLinearSpace = 2.2;
  1843. /**
  1844. * Constant used to define the minimal number value in Babylon.js
  1845. * @ignorenaming
  1846. */
  1847. let Epsilon: number;
  1848. }
  1849. declare module BABYLON {
  1850. /**
  1851. * Class used to represent a viewport on screen
  1852. */
  1853. export class Viewport {
  1854. /** viewport left coordinate */
  1855. x: number;
  1856. /** viewport top coordinate */
  1857. y: number;
  1858. /**viewport width */
  1859. width: number;
  1860. /** viewport height */
  1861. height: number;
  1862. /**
  1863. * Creates a Viewport object located at (x, y) and sized (width, height)
  1864. * @param x defines viewport left coordinate
  1865. * @param y defines viewport top coordinate
  1866. * @param width defines the viewport width
  1867. * @param height defines the viewport height
  1868. */
  1869. constructor(
  1870. /** viewport left coordinate */
  1871. x: number,
  1872. /** viewport top coordinate */
  1873. y: number,
  1874. /**viewport width */
  1875. width: number,
  1876. /** viewport height */
  1877. height: number);
  1878. /**
  1879. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1880. * @param renderWidth defines the rendering width
  1881. * @param renderHeight defines the rendering height
  1882. * @returns a new Viewport
  1883. */
  1884. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1885. /**
  1886. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1887. * @param renderWidth defines the rendering width
  1888. * @param renderHeight defines the rendering height
  1889. * @param ref defines the target viewport
  1890. * @returns the current viewport
  1891. */
  1892. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1893. /**
  1894. * Returns a new Viewport copied from the current one
  1895. * @returns a new Viewport
  1896. */
  1897. clone(): Viewport;
  1898. }
  1899. }
  1900. declare module BABYLON {
  1901. /**
  1902. * Class containing a set of static utilities functions for arrays.
  1903. */
  1904. export class ArrayTools {
  1905. /**
  1906. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1907. * @param size the number of element to construct and put in the array
  1908. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1909. * @returns a new array filled with new objects
  1910. */
  1911. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1912. }
  1913. }
  1914. declare module BABYLON {
  1915. /**
  1916. * Represents a plane by the equation ax + by + cz + d = 0
  1917. */
  1918. export class Plane {
  1919. private static _TmpMatrix;
  1920. /**
  1921. * Normal of the plane (a,b,c)
  1922. */
  1923. normal: Vector3;
  1924. /**
  1925. * d component of the plane
  1926. */
  1927. d: number;
  1928. /**
  1929. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1930. * @param a a component of the plane
  1931. * @param b b component of the plane
  1932. * @param c c component of the plane
  1933. * @param d d component of the plane
  1934. */
  1935. constructor(a: number, b: number, c: number, d: number);
  1936. /**
  1937. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1938. */
  1939. asArray(): number[];
  1940. /**
  1941. * @returns a new plane copied from the current Plane.
  1942. */
  1943. clone(): Plane;
  1944. /**
  1945. * @returns the string "Plane".
  1946. */
  1947. getClassName(): string;
  1948. /**
  1949. * @returns the Plane hash code.
  1950. */
  1951. getHashCode(): number;
  1952. /**
  1953. * Normalize the current Plane in place.
  1954. * @returns the updated Plane.
  1955. */
  1956. normalize(): Plane;
  1957. /**
  1958. * Applies a transformation the plane and returns the result
  1959. * @param transformation the transformation matrix to be applied to the plane
  1960. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  1961. */
  1962. transform(transformation: DeepImmutable<Matrix>): Plane;
  1963. /**
  1964. * Compute the dot product between the point and the plane normal
  1965. * @param point point to calculate the dot product with
  1966. * @returns the dot product (float) of the point coordinates and the plane normal.
  1967. */
  1968. dotCoordinate(point: DeepImmutable<Vector3>): number;
  1969. /**
  1970. * Updates the current Plane from the plane defined by the three given points.
  1971. * @param point1 one of the points used to contruct the plane
  1972. * @param point2 one of the points used to contruct the plane
  1973. * @param point3 one of the points used to contruct the plane
  1974. * @returns the updated Plane.
  1975. */
  1976. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  1977. /**
  1978. * Checks if the plane is facing a given direction
  1979. * @param direction the direction to check if the plane is facing
  1980. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  1981. * @returns True is the vector "direction" is the same side than the plane normal.
  1982. */
  1983. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  1984. /**
  1985. * Calculates the distance to a point
  1986. * @param point point to calculate distance to
  1987. * @returns the signed distance (float) from the given point to the Plane.
  1988. */
  1989. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  1990. /**
  1991. * Creates a plane from an array
  1992. * @param array the array to create a plane from
  1993. * @returns a new Plane from the given array.
  1994. */
  1995. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  1996. /**
  1997. * Creates a plane from three points
  1998. * @param point1 point used to create the plane
  1999. * @param point2 point used to create the plane
  2000. * @param point3 point used to create the plane
  2001. * @returns a new Plane defined by the three given points.
  2002. */
  2003. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2004. /**
  2005. * Creates a plane from an origin point and a normal
  2006. * @param origin origin of the plane to be constructed
  2007. * @param normal normal of the plane to be constructed
  2008. * @returns a new Plane the normal vector to this plane at the given origin point.
  2009. * Note : the vector "normal" is updated because normalized.
  2010. */
  2011. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2012. /**
  2013. * Calculates the distance from a plane and a point
  2014. * @param origin origin of the plane to be constructed
  2015. * @param normal normal of the plane to be constructed
  2016. * @param point point to calculate distance to
  2017. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2018. */
  2019. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2020. }
  2021. }
  2022. declare module BABYLON {
  2023. /**
  2024. * Class representing a vector containing 2 coordinates
  2025. */
  2026. export class Vector2 {
  2027. /** defines the first coordinate */
  2028. x: number;
  2029. /** defines the second coordinate */
  2030. y: number;
  2031. /**
  2032. * Creates a new Vector2 from the given x and y coordinates
  2033. * @param x defines the first coordinate
  2034. * @param y defines the second coordinate
  2035. */
  2036. constructor(
  2037. /** defines the first coordinate */
  2038. x?: number,
  2039. /** defines the second coordinate */
  2040. y?: number);
  2041. /**
  2042. * Gets a string with the Vector2 coordinates
  2043. * @returns a string with the Vector2 coordinates
  2044. */
  2045. toString(): string;
  2046. /**
  2047. * Gets class name
  2048. * @returns the string "Vector2"
  2049. */
  2050. getClassName(): string;
  2051. /**
  2052. * Gets current vector hash code
  2053. * @returns the Vector2 hash code as a number
  2054. */
  2055. getHashCode(): number;
  2056. /**
  2057. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2058. * @param array defines the source array
  2059. * @param index defines the offset in source array
  2060. * @returns the current Vector2
  2061. */
  2062. toArray(array: FloatArray, index?: number): Vector2;
  2063. /**
  2064. * Copy the current vector to an array
  2065. * @returns a new array with 2 elements: the Vector2 coordinates.
  2066. */
  2067. asArray(): number[];
  2068. /**
  2069. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2070. * @param source defines the source Vector2
  2071. * @returns the current updated Vector2
  2072. */
  2073. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2074. /**
  2075. * Sets the Vector2 coordinates with the given floats
  2076. * @param x defines the first coordinate
  2077. * @param y defines the second coordinate
  2078. * @returns the current updated Vector2
  2079. */
  2080. copyFromFloats(x: number, y: number): Vector2;
  2081. /**
  2082. * Sets the Vector2 coordinates with the given floats
  2083. * @param x defines the first coordinate
  2084. * @param y defines the second coordinate
  2085. * @returns the current updated Vector2
  2086. */
  2087. set(x: number, y: number): Vector2;
  2088. /**
  2089. * Add another vector with the current one
  2090. * @param otherVector defines the other vector
  2091. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2092. */
  2093. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2094. /**
  2095. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2096. * @param otherVector defines the other vector
  2097. * @param result defines the target vector
  2098. * @returns the unmodified current Vector2
  2099. */
  2100. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2101. /**
  2102. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2103. * @param otherVector defines the other vector
  2104. * @returns the current updated Vector2
  2105. */
  2106. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2107. /**
  2108. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2109. * @param otherVector defines the other vector
  2110. * @returns a new Vector2
  2111. */
  2112. addVector3(otherVector: Vector3): Vector2;
  2113. /**
  2114. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2115. * @param otherVector defines the other vector
  2116. * @returns a new Vector2
  2117. */
  2118. subtract(otherVector: Vector2): Vector2;
  2119. /**
  2120. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2121. * @param otherVector defines the other vector
  2122. * @param result defines the target vector
  2123. * @returns the unmodified current Vector2
  2124. */
  2125. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2126. /**
  2127. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2128. * @param otherVector defines the other vector
  2129. * @returns the current updated Vector2
  2130. */
  2131. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2132. /**
  2133. * Multiplies in place the current Vector2 coordinates by the given ones
  2134. * @param otherVector defines the other vector
  2135. * @returns the current updated Vector2
  2136. */
  2137. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2138. /**
  2139. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2140. * @param otherVector defines the other vector
  2141. * @returns a new Vector2
  2142. */
  2143. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2144. /**
  2145. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2146. * @param otherVector defines the other vector
  2147. * @param result defines the target vector
  2148. * @returns the unmodified current Vector2
  2149. */
  2150. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2151. /**
  2152. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2153. * @param x defines the first coordinate
  2154. * @param y defines the second coordinate
  2155. * @returns a new Vector2
  2156. */
  2157. multiplyByFloats(x: number, y: number): Vector2;
  2158. /**
  2159. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2160. * @param otherVector defines the other vector
  2161. * @returns a new Vector2
  2162. */
  2163. divide(otherVector: Vector2): Vector2;
  2164. /**
  2165. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2166. * @param otherVector defines the other vector
  2167. * @param result defines the target vector
  2168. * @returns the unmodified current Vector2
  2169. */
  2170. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2171. /**
  2172. * Divides the current Vector2 coordinates by the given ones
  2173. * @param otherVector defines the other vector
  2174. * @returns the current updated Vector2
  2175. */
  2176. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2177. /**
  2178. * Gets a new Vector2 with current Vector2 negated coordinates
  2179. * @returns a new Vector2
  2180. */
  2181. negate(): Vector2;
  2182. /**
  2183. * Negate this vector in place
  2184. * @returns this
  2185. */
  2186. negateInPlace(): Vector2;
  2187. /**
  2188. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2189. * @param result defines the Vector3 object where to store the result
  2190. * @returns the current Vector2
  2191. */
  2192. negateToRef(result: Vector2): Vector2;
  2193. /**
  2194. * Multiply the Vector2 coordinates by scale
  2195. * @param scale defines the scaling factor
  2196. * @returns the current updated Vector2
  2197. */
  2198. scaleInPlace(scale: number): Vector2;
  2199. /**
  2200. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2201. * @param scale defines the scaling factor
  2202. * @returns a new Vector2
  2203. */
  2204. scale(scale: number): Vector2;
  2205. /**
  2206. * Scale the current Vector2 values by a factor to a given Vector2
  2207. * @param scale defines the scale factor
  2208. * @param result defines the Vector2 object where to store the result
  2209. * @returns the unmodified current Vector2
  2210. */
  2211. scaleToRef(scale: number, result: Vector2): Vector2;
  2212. /**
  2213. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2214. * @param scale defines the scale factor
  2215. * @param result defines the Vector2 object where to store the result
  2216. * @returns the unmodified current Vector2
  2217. */
  2218. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2219. /**
  2220. * Gets a boolean if two vectors are equals
  2221. * @param otherVector defines the other vector
  2222. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2223. */
  2224. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2225. /**
  2226. * Gets a boolean if two vectors are equals (using an epsilon value)
  2227. * @param otherVector defines the other vector
  2228. * @param epsilon defines the minimal distance to consider equality
  2229. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2230. */
  2231. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2232. /**
  2233. * Gets a new Vector2 from current Vector2 floored values
  2234. * @returns a new Vector2
  2235. */
  2236. floor(): Vector2;
  2237. /**
  2238. * Gets a new Vector2 from current Vector2 floored values
  2239. * @returns a new Vector2
  2240. */
  2241. fract(): Vector2;
  2242. /**
  2243. * Gets the length of the vector
  2244. * @returns the vector length (float)
  2245. */
  2246. length(): number;
  2247. /**
  2248. * Gets the vector squared length
  2249. * @returns the vector squared length (float)
  2250. */
  2251. lengthSquared(): number;
  2252. /**
  2253. * Normalize the vector
  2254. * @returns the current updated Vector2
  2255. */
  2256. normalize(): Vector2;
  2257. /**
  2258. * Gets a new Vector2 copied from the Vector2
  2259. * @returns a new Vector2
  2260. */
  2261. clone(): Vector2;
  2262. /**
  2263. * Gets a new Vector2(0, 0)
  2264. * @returns a new Vector2
  2265. */
  2266. static Zero(): Vector2;
  2267. /**
  2268. * Gets a new Vector2(1, 1)
  2269. * @returns a new Vector2
  2270. */
  2271. static One(): Vector2;
  2272. /**
  2273. * Gets a new Vector2 set from the given index element of the given array
  2274. * @param array defines the data source
  2275. * @param offset defines the offset in the data source
  2276. * @returns a new Vector2
  2277. */
  2278. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2279. /**
  2280. * Sets "result" from the given index element of the given array
  2281. * @param array defines the data source
  2282. * @param offset defines the offset in the data source
  2283. * @param result defines the target vector
  2284. */
  2285. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2286. /**
  2287. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2288. * @param value1 defines 1st point of control
  2289. * @param value2 defines 2nd point of control
  2290. * @param value3 defines 3rd point of control
  2291. * @param value4 defines 4th point of control
  2292. * @param amount defines the interpolation factor
  2293. * @returns a new Vector2
  2294. */
  2295. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2296. /**
  2297. * 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".
  2298. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2299. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2300. * @param value defines the value to clamp
  2301. * @param min defines the lower limit
  2302. * @param max defines the upper limit
  2303. * @returns a new Vector2
  2304. */
  2305. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2306. /**
  2307. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2308. * @param value1 defines the 1st control point
  2309. * @param tangent1 defines the outgoing tangent
  2310. * @param value2 defines the 2nd control point
  2311. * @param tangent2 defines the incoming tangent
  2312. * @param amount defines the interpolation factor
  2313. * @returns a new Vector2
  2314. */
  2315. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2316. /**
  2317. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2318. * @param start defines the start vector
  2319. * @param end defines the end vector
  2320. * @param amount defines the interpolation factor
  2321. * @returns a new Vector2
  2322. */
  2323. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2324. /**
  2325. * Gets the dot product of the vector "left" and the vector "right"
  2326. * @param left defines first vector
  2327. * @param right defines second vector
  2328. * @returns the dot product (float)
  2329. */
  2330. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2331. /**
  2332. * Returns a new Vector2 equal to the normalized given vector
  2333. * @param vector defines the vector to normalize
  2334. * @returns a new Vector2
  2335. */
  2336. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2337. /**
  2338. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2339. * @param left defines 1st vector
  2340. * @param right defines 2nd vector
  2341. * @returns a new Vector2
  2342. */
  2343. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2344. /**
  2345. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2346. * @param left defines 1st vector
  2347. * @param right defines 2nd vector
  2348. * @returns a new Vector2
  2349. */
  2350. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2351. /**
  2352. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2353. * @param vector defines the vector to transform
  2354. * @param transformation defines the matrix to apply
  2355. * @returns a new Vector2
  2356. */
  2357. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2358. /**
  2359. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2360. * @param vector defines the vector to transform
  2361. * @param transformation defines the matrix to apply
  2362. * @param result defines the target vector
  2363. */
  2364. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2365. /**
  2366. * Determines if a given vector is included in a triangle
  2367. * @param p defines the vector to test
  2368. * @param p0 defines 1st triangle point
  2369. * @param p1 defines 2nd triangle point
  2370. * @param p2 defines 3rd triangle point
  2371. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2372. */
  2373. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2374. /**
  2375. * Gets the distance between the vectors "value1" and "value2"
  2376. * @param value1 defines first vector
  2377. * @param value2 defines second vector
  2378. * @returns the distance between vectors
  2379. */
  2380. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2381. /**
  2382. * Returns the squared distance between the vectors "value1" and "value2"
  2383. * @param value1 defines first vector
  2384. * @param value2 defines second vector
  2385. * @returns the squared distance between vectors
  2386. */
  2387. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2388. /**
  2389. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2390. * @param value1 defines first vector
  2391. * @param value2 defines second vector
  2392. * @returns a new Vector2
  2393. */
  2394. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2395. /**
  2396. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2397. * @param p defines the middle point
  2398. * @param segA defines one point of the segment
  2399. * @param segB defines the other point of the segment
  2400. * @returns the shortest distance
  2401. */
  2402. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2403. }
  2404. /**
  2405. * Class used to store (x,y,z) vector representation
  2406. * A Vector3 is the main object used in 3D geometry
  2407. * It can represent etiher the coordinates of a point the space, either a direction
  2408. * Reminder: js uses a left handed forward facing system
  2409. */
  2410. export class Vector3 {
  2411. private static _UpReadOnly;
  2412. private static _ZeroReadOnly;
  2413. /** @hidden */
  2414. _x: number;
  2415. /** @hidden */
  2416. _y: number;
  2417. /** @hidden */
  2418. _z: number;
  2419. /** @hidden */
  2420. _isDirty: boolean;
  2421. /** Gets or sets the x coordinate */
  2422. get x(): number;
  2423. set x(value: number);
  2424. /** Gets or sets the y coordinate */
  2425. get y(): number;
  2426. set y(value: number);
  2427. /** Gets or sets the z coordinate */
  2428. get z(): number;
  2429. set z(value: number);
  2430. /**
  2431. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2432. * @param x defines the first coordinates (on X axis)
  2433. * @param y defines the second coordinates (on Y axis)
  2434. * @param z defines the third coordinates (on Z axis)
  2435. */
  2436. constructor(x?: number, y?: number, z?: number);
  2437. /**
  2438. * Creates a string representation of the Vector3
  2439. * @returns a string with the Vector3 coordinates.
  2440. */
  2441. toString(): string;
  2442. /**
  2443. * Gets the class name
  2444. * @returns the string "Vector3"
  2445. */
  2446. getClassName(): string;
  2447. /**
  2448. * Creates the Vector3 hash code
  2449. * @returns a number which tends to be unique between Vector3 instances
  2450. */
  2451. getHashCode(): number;
  2452. /**
  2453. * Creates an array containing three elements : the coordinates of the Vector3
  2454. * @returns a new array of numbers
  2455. */
  2456. asArray(): number[];
  2457. /**
  2458. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2459. * @param array defines the destination array
  2460. * @param index defines the offset in the destination array
  2461. * @returns the current Vector3
  2462. */
  2463. toArray(array: FloatArray, index?: number): Vector3;
  2464. /**
  2465. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2466. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2467. */
  2468. toQuaternion(): Quaternion;
  2469. /**
  2470. * Adds the given vector to the current Vector3
  2471. * @param otherVector defines the second operand
  2472. * @returns the current updated Vector3
  2473. */
  2474. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2475. /**
  2476. * Adds the given coordinates to the current Vector3
  2477. * @param x defines the x coordinate of the operand
  2478. * @param y defines the y coordinate of the operand
  2479. * @param z defines the z coordinate of the operand
  2480. * @returns the current updated Vector3
  2481. */
  2482. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2483. /**
  2484. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2485. * @param otherVector defines the second operand
  2486. * @returns the resulting Vector3
  2487. */
  2488. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2489. /**
  2490. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2491. * @param otherVector defines the second operand
  2492. * @param result defines the Vector3 object where to store the result
  2493. * @returns the current Vector3
  2494. */
  2495. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2496. /**
  2497. * Subtract the given vector from the current Vector3
  2498. * @param otherVector defines the second operand
  2499. * @returns the current updated Vector3
  2500. */
  2501. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2502. /**
  2503. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2504. * @param otherVector defines the second operand
  2505. * @returns the resulting Vector3
  2506. */
  2507. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2508. /**
  2509. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2510. * @param otherVector defines the second operand
  2511. * @param result defines the Vector3 object where to store the result
  2512. * @returns the current Vector3
  2513. */
  2514. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2515. /**
  2516. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2517. * @param x defines the x coordinate of the operand
  2518. * @param y defines the y coordinate of the operand
  2519. * @param z defines the z coordinate of the operand
  2520. * @returns the resulting Vector3
  2521. */
  2522. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2523. /**
  2524. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2525. * @param x defines the x coordinate of the operand
  2526. * @param y defines the y coordinate of the operand
  2527. * @param z defines the z coordinate of the operand
  2528. * @param result defines the Vector3 object where to store the result
  2529. * @returns the current Vector3
  2530. */
  2531. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2532. /**
  2533. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2534. * @returns a new Vector3
  2535. */
  2536. negate(): Vector3;
  2537. /**
  2538. * Negate this vector in place
  2539. * @returns this
  2540. */
  2541. negateInPlace(): Vector3;
  2542. /**
  2543. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2544. * @param result defines the Vector3 object where to store the result
  2545. * @returns the current Vector3
  2546. */
  2547. negateToRef(result: Vector3): Vector3;
  2548. /**
  2549. * Multiplies the Vector3 coordinates by the float "scale"
  2550. * @param scale defines the multiplier factor
  2551. * @returns the current updated Vector3
  2552. */
  2553. scaleInPlace(scale: number): Vector3;
  2554. /**
  2555. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2556. * @param scale defines the multiplier factor
  2557. * @returns a new Vector3
  2558. */
  2559. scale(scale: number): Vector3;
  2560. /**
  2561. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2562. * @param scale defines the multiplier factor
  2563. * @param result defines the Vector3 object where to store the result
  2564. * @returns the current Vector3
  2565. */
  2566. scaleToRef(scale: number, result: Vector3): Vector3;
  2567. /**
  2568. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2569. * @param scale defines the scale factor
  2570. * @param result defines the Vector3 object where to store the result
  2571. * @returns the unmodified current Vector3
  2572. */
  2573. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2574. /**
  2575. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2576. * @param origin defines the origin of the projection ray
  2577. * @param plane defines the plane to project to
  2578. * @returns the projected vector3
  2579. */
  2580. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2581. /**
  2582. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2583. * @param origin defines the origin of the projection ray
  2584. * @param plane defines the plane to project to
  2585. * @param result defines the Vector3 where to store the result
  2586. */
  2587. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2588. /**
  2589. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2590. * @param otherVector defines the second operand
  2591. * @returns true if both vectors are equals
  2592. */
  2593. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2594. /**
  2595. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2596. * @param otherVector defines the second operand
  2597. * @param epsilon defines the minimal distance to define values as equals
  2598. * @returns true if both vectors are distant less than epsilon
  2599. */
  2600. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2601. /**
  2602. * Returns true if the current Vector3 coordinates equals the given floats
  2603. * @param x defines the x coordinate of the operand
  2604. * @param y defines the y coordinate of the operand
  2605. * @param z defines the z coordinate of the operand
  2606. * @returns true if both vectors are equals
  2607. */
  2608. equalsToFloats(x: number, y: number, z: number): boolean;
  2609. /**
  2610. * Multiplies the current Vector3 coordinates by the given ones
  2611. * @param otherVector defines the second operand
  2612. * @returns the current updated Vector3
  2613. */
  2614. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2615. /**
  2616. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2617. * @param otherVector defines the second operand
  2618. * @returns the new Vector3
  2619. */
  2620. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2621. /**
  2622. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2623. * @param otherVector defines the second operand
  2624. * @param result defines the Vector3 object where to store the result
  2625. * @returns the current Vector3
  2626. */
  2627. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2628. /**
  2629. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2630. * @param x defines the x coordinate of the operand
  2631. * @param y defines the y coordinate of the operand
  2632. * @param z defines the z coordinate of the operand
  2633. * @returns the new Vector3
  2634. */
  2635. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2636. /**
  2637. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2638. * @param otherVector defines the second operand
  2639. * @returns the new Vector3
  2640. */
  2641. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2642. /**
  2643. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2644. * @param otherVector defines the second operand
  2645. * @param result defines the Vector3 object where to store the result
  2646. * @returns the current Vector3
  2647. */
  2648. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2649. /**
  2650. * Divides the current Vector3 coordinates by the given ones.
  2651. * @param otherVector defines the second operand
  2652. * @returns the current updated Vector3
  2653. */
  2654. divideInPlace(otherVector: Vector3): Vector3;
  2655. /**
  2656. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2657. * @param other defines the second operand
  2658. * @returns the current updated Vector3
  2659. */
  2660. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2661. /**
  2662. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2663. * @param other defines the second operand
  2664. * @returns the current updated Vector3
  2665. */
  2666. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2667. /**
  2668. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2669. * @param x defines the x coordinate of the operand
  2670. * @param y defines the y coordinate of the operand
  2671. * @param z defines the z coordinate of the operand
  2672. * @returns the current updated Vector3
  2673. */
  2674. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2675. /**
  2676. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2677. * @param x defines the x coordinate of the operand
  2678. * @param y defines the y coordinate of the operand
  2679. * @param z defines the z coordinate of the operand
  2680. * @returns the current updated Vector3
  2681. */
  2682. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2683. /**
  2684. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2685. * Check if is non uniform within a certain amount of decimal places to account for this
  2686. * @param epsilon the amount the values can differ
  2687. * @returns if the the vector is non uniform to a certain number of decimal places
  2688. */
  2689. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2690. /**
  2691. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2692. */
  2693. get isNonUniform(): boolean;
  2694. /**
  2695. * Gets a new Vector3 from current Vector3 floored values
  2696. * @returns a new Vector3
  2697. */
  2698. floor(): Vector3;
  2699. /**
  2700. * Gets a new Vector3 from current Vector3 floored values
  2701. * @returns a new Vector3
  2702. */
  2703. fract(): Vector3;
  2704. /**
  2705. * Gets the length of the Vector3
  2706. * @returns the length of the Vector3
  2707. */
  2708. length(): number;
  2709. /**
  2710. * Gets the squared length of the Vector3
  2711. * @returns squared length of the Vector3
  2712. */
  2713. lengthSquared(): number;
  2714. /**
  2715. * Normalize the current Vector3.
  2716. * Please note that this is an in place operation.
  2717. * @returns the current updated Vector3
  2718. */
  2719. normalize(): Vector3;
  2720. /**
  2721. * Reorders the x y z properties of the vector in place
  2722. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2723. * @returns the current updated vector
  2724. */
  2725. reorderInPlace(order: string): this;
  2726. /**
  2727. * Rotates the vector around 0,0,0 by a quaternion
  2728. * @param quaternion the rotation quaternion
  2729. * @param result vector to store the result
  2730. * @returns the resulting vector
  2731. */
  2732. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2733. /**
  2734. * Rotates a vector around a given point
  2735. * @param quaternion the rotation quaternion
  2736. * @param point the point to rotate around
  2737. * @param result vector to store the result
  2738. * @returns the resulting vector
  2739. */
  2740. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2741. /**
  2742. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2743. * The cross product is then orthogonal to both current and "other"
  2744. * @param other defines the right operand
  2745. * @returns the cross product
  2746. */
  2747. cross(other: Vector3): Vector3;
  2748. /**
  2749. * Normalize the current Vector3 with the given input length.
  2750. * Please note that this is an in place operation.
  2751. * @param len the length of the vector
  2752. * @returns the current updated Vector3
  2753. */
  2754. normalizeFromLength(len: number): Vector3;
  2755. /**
  2756. * Normalize the current Vector3 to a new vector
  2757. * @returns the new Vector3
  2758. */
  2759. normalizeToNew(): Vector3;
  2760. /**
  2761. * Normalize the current Vector3 to the reference
  2762. * @param reference define the Vector3 to update
  2763. * @returns the updated Vector3
  2764. */
  2765. normalizeToRef(reference: Vector3): Vector3;
  2766. /**
  2767. * Creates a new Vector3 copied from the current Vector3
  2768. * @returns the new Vector3
  2769. */
  2770. clone(): Vector3;
  2771. /**
  2772. * Copies the given vector coordinates to the current Vector3 ones
  2773. * @param source defines the source Vector3
  2774. * @returns the current updated Vector3
  2775. */
  2776. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2777. /**
  2778. * Copies the given floats to the current Vector3 coordinates
  2779. * @param x defines the x coordinate of the operand
  2780. * @param y defines the y coordinate of the operand
  2781. * @param z defines the z coordinate of the operand
  2782. * @returns the current updated Vector3
  2783. */
  2784. copyFromFloats(x: number, y: number, z: number): Vector3;
  2785. /**
  2786. * Copies the given floats to the current Vector3 coordinates
  2787. * @param x defines the x coordinate of the operand
  2788. * @param y defines the y coordinate of the operand
  2789. * @param z defines the z coordinate of the operand
  2790. * @returns the current updated Vector3
  2791. */
  2792. set(x: number, y: number, z: number): Vector3;
  2793. /**
  2794. * Copies the given float to the current Vector3 coordinates
  2795. * @param v defines the x, y and z coordinates of the operand
  2796. * @returns the current updated Vector3
  2797. */
  2798. setAll(v: number): Vector3;
  2799. /**
  2800. * Get the clip factor between two vectors
  2801. * @param vector0 defines the first operand
  2802. * @param vector1 defines the second operand
  2803. * @param axis defines the axis to use
  2804. * @param size defines the size along the axis
  2805. * @returns the clip factor
  2806. */
  2807. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2808. /**
  2809. * Get angle between two vectors
  2810. * @param vector0 angle between vector0 and vector1
  2811. * @param vector1 angle between vector0 and vector1
  2812. * @param normal direction of the normal
  2813. * @return the angle between vector0 and vector1
  2814. */
  2815. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2816. /**
  2817. * Returns a new Vector3 set from the index "offset" of the given array
  2818. * @param array defines the source array
  2819. * @param offset defines the offset in the source array
  2820. * @returns the new Vector3
  2821. */
  2822. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2823. /**
  2824. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2825. * @param array defines the source array
  2826. * @param offset defines the offset in the source array
  2827. * @returns the new Vector3
  2828. * @deprecated Please use FromArray instead.
  2829. */
  2830. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2831. /**
  2832. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2833. * @param array defines the source array
  2834. * @param offset defines the offset in the source array
  2835. * @param result defines the Vector3 where to store the result
  2836. */
  2837. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2838. /**
  2839. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2840. * @param array defines the source array
  2841. * @param offset defines the offset in the source array
  2842. * @param result defines the Vector3 where to store the result
  2843. * @deprecated Please use FromArrayToRef instead.
  2844. */
  2845. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2846. /**
  2847. * Sets the given vector "result" with the given floats.
  2848. * @param x defines the x coordinate of the source
  2849. * @param y defines the y coordinate of the source
  2850. * @param z defines the z coordinate of the source
  2851. * @param result defines the Vector3 where to store the result
  2852. */
  2853. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2854. /**
  2855. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2856. * @returns a new empty Vector3
  2857. */
  2858. static Zero(): Vector3;
  2859. /**
  2860. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2861. * @returns a new unit Vector3
  2862. */
  2863. static One(): Vector3;
  2864. /**
  2865. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2866. * @returns a new up Vector3
  2867. */
  2868. static Up(): Vector3;
  2869. /**
  2870. * Gets a up Vector3 that must not be updated
  2871. */
  2872. static get UpReadOnly(): DeepImmutable<Vector3>;
  2873. /**
  2874. * Gets a zero Vector3 that must not be updated
  2875. */
  2876. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2877. /**
  2878. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2879. * @returns a new down Vector3
  2880. */
  2881. static Down(): Vector3;
  2882. /**
  2883. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2884. * @param rightHandedSystem is the scene right-handed (negative z)
  2885. * @returns a new forward Vector3
  2886. */
  2887. static Forward(rightHandedSystem?: boolean): Vector3;
  2888. /**
  2889. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2890. * @param rightHandedSystem is the scene right-handed (negative-z)
  2891. * @returns a new forward Vector3
  2892. */
  2893. static Backward(rightHandedSystem?: boolean): Vector3;
  2894. /**
  2895. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2896. * @returns a new right Vector3
  2897. */
  2898. static Right(): Vector3;
  2899. /**
  2900. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2901. * @returns a new left Vector3
  2902. */
  2903. static Left(): Vector3;
  2904. /**
  2905. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2906. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2907. * @param vector defines the Vector3 to transform
  2908. * @param transformation defines the transformation matrix
  2909. * @returns the transformed Vector3
  2910. */
  2911. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2912. /**
  2913. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2914. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2915. * @param vector defines the Vector3 to transform
  2916. * @param transformation defines the transformation matrix
  2917. * @param result defines the Vector3 where to store the result
  2918. */
  2919. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2920. /**
  2921. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2922. * This method computes tranformed coordinates only, not transformed direction vectors
  2923. * @param x define the x coordinate of the source vector
  2924. * @param y define the y coordinate of the source vector
  2925. * @param z define the z coordinate of the source vector
  2926. * @param transformation defines the transformation matrix
  2927. * @param result defines the Vector3 where to store the result
  2928. */
  2929. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2930. /**
  2931. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2932. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2933. * @param vector defines the Vector3 to transform
  2934. * @param transformation defines the transformation matrix
  2935. * @returns the new Vector3
  2936. */
  2937. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2938. /**
  2939. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2940. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2941. * @param vector defines the Vector3 to transform
  2942. * @param transformation defines the transformation matrix
  2943. * @param result defines the Vector3 where to store the result
  2944. */
  2945. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2946. /**
  2947. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2948. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2949. * @param x define the x coordinate of the source vector
  2950. * @param y define the y coordinate of the source vector
  2951. * @param z define the z coordinate of the source vector
  2952. * @param transformation defines the transformation matrix
  2953. * @param result defines the Vector3 where to store the result
  2954. */
  2955. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2956. /**
  2957. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2958. * @param value1 defines the first control point
  2959. * @param value2 defines the second control point
  2960. * @param value3 defines the third control point
  2961. * @param value4 defines the fourth control point
  2962. * @param amount defines the amount on the spline to use
  2963. * @returns the new Vector3
  2964. */
  2965. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2966. /**
  2967. * 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"
  2968. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2969. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2970. * @param value defines the current value
  2971. * @param min defines the lower range value
  2972. * @param max defines the upper range value
  2973. * @returns the new Vector3
  2974. */
  2975. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2976. /**
  2977. * 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"
  2978. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2979. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2980. * @param value defines the current value
  2981. * @param min defines the lower range value
  2982. * @param max defines the upper range value
  2983. * @param result defines the Vector3 where to store the result
  2984. */
  2985. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2986. /**
  2987. * Checks if a given vector is inside a specific range
  2988. * @param v defines the vector to test
  2989. * @param min defines the minimum range
  2990. * @param max defines the maximum range
  2991. */
  2992. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2993. /**
  2994. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2995. * @param value1 defines the first control point
  2996. * @param tangent1 defines the first tangent vector
  2997. * @param value2 defines the second control point
  2998. * @param tangent2 defines the second tangent vector
  2999. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3000. * @returns the new Vector3
  3001. */
  3002. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3003. /**
  3004. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3005. * @param start defines the start value
  3006. * @param end defines the end value
  3007. * @param amount max defines amount between both (between 0 and 1)
  3008. * @returns the new Vector3
  3009. */
  3010. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3011. /**
  3012. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3013. * @param start defines the start value
  3014. * @param end defines the end value
  3015. * @param amount max defines amount between both (between 0 and 1)
  3016. * @param result defines the Vector3 where to store the result
  3017. */
  3018. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3019. /**
  3020. * Returns the dot product (float) between the vectors "left" and "right"
  3021. * @param left defines the left operand
  3022. * @param right defines the right operand
  3023. * @returns the dot product
  3024. */
  3025. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3026. /**
  3027. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3028. * The cross product is then orthogonal to both "left" and "right"
  3029. * @param left defines the left operand
  3030. * @param right defines the right operand
  3031. * @returns the cross product
  3032. */
  3033. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3034. /**
  3035. * Sets the given vector "result" with the cross product of "left" and "right"
  3036. * The cross product is then orthogonal to both "left" and "right"
  3037. * @param left defines the left operand
  3038. * @param right defines the right operand
  3039. * @param result defines the Vector3 where to store the result
  3040. */
  3041. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3042. /**
  3043. * Returns a new Vector3 as the normalization of the given vector
  3044. * @param vector defines the Vector3 to normalize
  3045. * @returns the new Vector3
  3046. */
  3047. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3048. /**
  3049. * Sets the given vector "result" with the normalization of the given first vector
  3050. * @param vector defines the Vector3 to normalize
  3051. * @param result defines the Vector3 where to store the result
  3052. */
  3053. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3054. /**
  3055. * Project a Vector3 onto screen space
  3056. * @param vector defines the Vector3 to project
  3057. * @param world defines the world matrix to use
  3058. * @param transform defines the transform (view x projection) matrix to use
  3059. * @param viewport defines the screen viewport to use
  3060. * @returns the new Vector3
  3061. */
  3062. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3063. /** @hidden */
  3064. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3065. /**
  3066. * Unproject from screen space to object space
  3067. * @param source defines the screen space Vector3 to use
  3068. * @param viewportWidth defines the current width of the viewport
  3069. * @param viewportHeight defines the current height of the viewport
  3070. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3071. * @param transform defines the transform (view x projection) matrix to use
  3072. * @returns the new Vector3
  3073. */
  3074. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3075. /**
  3076. * Unproject from screen space to object space
  3077. * @param source defines the screen space Vector3 to use
  3078. * @param viewportWidth defines the current width of the viewport
  3079. * @param viewportHeight defines the current height of the viewport
  3080. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3081. * @param view defines the view matrix to use
  3082. * @param projection defines the projection matrix to use
  3083. * @returns the new Vector3
  3084. */
  3085. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3086. /**
  3087. * Unproject from screen space to object space
  3088. * @param source defines the screen space Vector3 to use
  3089. * @param viewportWidth defines the current width of the viewport
  3090. * @param viewportHeight defines the current height of the viewport
  3091. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3092. * @param view defines the view matrix to use
  3093. * @param projection defines the projection matrix to use
  3094. * @param result defines the Vector3 where to store the result
  3095. */
  3096. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3097. /**
  3098. * Unproject from screen space to object space
  3099. * @param sourceX defines the screen space x coordinate to use
  3100. * @param sourceY defines the screen space y coordinate to use
  3101. * @param sourceZ defines the screen space z coordinate to use
  3102. * @param viewportWidth defines the current width of the viewport
  3103. * @param viewportHeight defines the current height of the viewport
  3104. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3105. * @param view defines the view matrix to use
  3106. * @param projection defines the projection matrix to use
  3107. * @param result defines the Vector3 where to store the result
  3108. */
  3109. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3110. /**
  3111. * Gets the minimal coordinate values between two Vector3
  3112. * @param left defines the first operand
  3113. * @param right defines the second operand
  3114. * @returns the new Vector3
  3115. */
  3116. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3117. /**
  3118. * Gets the maximal coordinate values between two Vector3
  3119. * @param left defines the first operand
  3120. * @param right defines the second operand
  3121. * @returns the new Vector3
  3122. */
  3123. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3124. /**
  3125. * Returns the distance between the vectors "value1" and "value2"
  3126. * @param value1 defines the first operand
  3127. * @param value2 defines the second operand
  3128. * @returns the distance
  3129. */
  3130. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3131. /**
  3132. * Returns the squared distance between the vectors "value1" and "value2"
  3133. * @param value1 defines the first operand
  3134. * @param value2 defines the second operand
  3135. * @returns the squared distance
  3136. */
  3137. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3138. /**
  3139. * Returns a new Vector3 located at the center between "value1" and "value2"
  3140. * @param value1 defines the first operand
  3141. * @param value2 defines the second operand
  3142. * @returns the new Vector3
  3143. */
  3144. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3145. /**
  3146. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3147. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3148. * to something in order to rotate it from its local system to the given target system
  3149. * Note: axis1, axis2 and axis3 are normalized during this operation
  3150. * @param axis1 defines the first axis
  3151. * @param axis2 defines the second axis
  3152. * @param axis3 defines the third axis
  3153. * @returns a new Vector3
  3154. */
  3155. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3156. /**
  3157. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3158. * @param axis1 defines the first axis
  3159. * @param axis2 defines the second axis
  3160. * @param axis3 defines the third axis
  3161. * @param ref defines the Vector3 where to store the result
  3162. */
  3163. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3164. }
  3165. /**
  3166. * Vector4 class created for EulerAngle class conversion to Quaternion
  3167. */
  3168. export class Vector4 {
  3169. /** x value of the vector */
  3170. x: number;
  3171. /** y value of the vector */
  3172. y: number;
  3173. /** z value of the vector */
  3174. z: number;
  3175. /** w value of the vector */
  3176. w: number;
  3177. /**
  3178. * Creates a Vector4 object from the given floats.
  3179. * @param x x value of the vector
  3180. * @param y y value of the vector
  3181. * @param z z value of the vector
  3182. * @param w w value of the vector
  3183. */
  3184. constructor(
  3185. /** x value of the vector */
  3186. x: number,
  3187. /** y value of the vector */
  3188. y: number,
  3189. /** z value of the vector */
  3190. z: number,
  3191. /** w value of the vector */
  3192. w: number);
  3193. /**
  3194. * Returns the string with the Vector4 coordinates.
  3195. * @returns a string containing all the vector values
  3196. */
  3197. toString(): string;
  3198. /**
  3199. * Returns the string "Vector4".
  3200. * @returns "Vector4"
  3201. */
  3202. getClassName(): string;
  3203. /**
  3204. * Returns the Vector4 hash code.
  3205. * @returns a unique hash code
  3206. */
  3207. getHashCode(): number;
  3208. /**
  3209. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3210. * @returns the resulting array
  3211. */
  3212. asArray(): number[];
  3213. /**
  3214. * Populates the given array from the given index with the Vector4 coordinates.
  3215. * @param array array to populate
  3216. * @param index index of the array to start at (default: 0)
  3217. * @returns the Vector4.
  3218. */
  3219. toArray(array: FloatArray, index?: number): Vector4;
  3220. /**
  3221. * Adds the given vector to the current Vector4.
  3222. * @param otherVector the vector to add
  3223. * @returns the updated Vector4.
  3224. */
  3225. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3226. /**
  3227. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3228. * @param otherVector the vector to add
  3229. * @returns the resulting vector
  3230. */
  3231. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3232. /**
  3233. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3234. * @param otherVector the vector to add
  3235. * @param result the vector to store the result
  3236. * @returns the current Vector4.
  3237. */
  3238. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3239. /**
  3240. * Subtract in place the given vector from the current Vector4.
  3241. * @param otherVector the vector to subtract
  3242. * @returns the updated Vector4.
  3243. */
  3244. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3245. /**
  3246. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3247. * @param otherVector the vector to add
  3248. * @returns the new vector with the result
  3249. */
  3250. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3251. /**
  3252. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3253. * @param otherVector the vector to subtract
  3254. * @param result the vector to store the result
  3255. * @returns the current Vector4.
  3256. */
  3257. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3258. /**
  3259. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3260. */
  3261. /**
  3262. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3263. * @param x value to subtract
  3264. * @param y value to subtract
  3265. * @param z value to subtract
  3266. * @param w value to subtract
  3267. * @returns new vector containing the result
  3268. */
  3269. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3270. /**
  3271. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3272. * @param x value to subtract
  3273. * @param y value to subtract
  3274. * @param z value to subtract
  3275. * @param w value to subtract
  3276. * @param result the vector to store the result in
  3277. * @returns the current Vector4.
  3278. */
  3279. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3280. /**
  3281. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3282. * @returns a new vector with the negated values
  3283. */
  3284. negate(): Vector4;
  3285. /**
  3286. * Negate this vector in place
  3287. * @returns this
  3288. */
  3289. negateInPlace(): Vector4;
  3290. /**
  3291. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3292. * @param result defines the Vector3 object where to store the result
  3293. * @returns the current Vector4
  3294. */
  3295. negateToRef(result: Vector4): Vector4;
  3296. /**
  3297. * Multiplies the current Vector4 coordinates by scale (float).
  3298. * @param scale the number to scale with
  3299. * @returns the updated Vector4.
  3300. */
  3301. scaleInPlace(scale: number): Vector4;
  3302. /**
  3303. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3304. * @param scale the number to scale with
  3305. * @returns a new vector with the result
  3306. */
  3307. scale(scale: number): Vector4;
  3308. /**
  3309. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3310. * @param scale the number to scale with
  3311. * @param result a vector to store the result in
  3312. * @returns the current Vector4.
  3313. */
  3314. scaleToRef(scale: number, result: Vector4): Vector4;
  3315. /**
  3316. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3317. * @param scale defines the scale factor
  3318. * @param result defines the Vector4 object where to store the result
  3319. * @returns the unmodified current Vector4
  3320. */
  3321. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3322. /**
  3323. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3324. * @param otherVector the vector to compare against
  3325. * @returns true if they are equal
  3326. */
  3327. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3328. /**
  3329. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3330. * @param otherVector vector to compare against
  3331. * @param epsilon (Default: very small number)
  3332. * @returns true if they are equal
  3333. */
  3334. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3335. /**
  3336. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3337. * @param x x value to compare against
  3338. * @param y y value to compare against
  3339. * @param z z value to compare against
  3340. * @param w w value to compare against
  3341. * @returns true if equal
  3342. */
  3343. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3344. /**
  3345. * Multiplies in place the current Vector4 by the given one.
  3346. * @param otherVector vector to multiple with
  3347. * @returns the updated Vector4.
  3348. */
  3349. multiplyInPlace(otherVector: Vector4): Vector4;
  3350. /**
  3351. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3352. * @param otherVector vector to multiple with
  3353. * @returns resulting new vector
  3354. */
  3355. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3356. /**
  3357. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3358. * @param otherVector vector to multiple with
  3359. * @param result vector to store the result
  3360. * @returns the current Vector4.
  3361. */
  3362. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3363. /**
  3364. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3365. * @param x x value multiply with
  3366. * @param y y value multiply with
  3367. * @param z z value multiply with
  3368. * @param w w value multiply with
  3369. * @returns resulting new vector
  3370. */
  3371. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3372. /**
  3373. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3374. * @param otherVector vector to devide with
  3375. * @returns resulting new vector
  3376. */
  3377. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3378. /**
  3379. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3380. * @param otherVector vector to devide with
  3381. * @param result vector to store the result
  3382. * @returns the current Vector4.
  3383. */
  3384. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3385. /**
  3386. * Divides the current Vector3 coordinates by the given ones.
  3387. * @param otherVector vector to devide with
  3388. * @returns the updated Vector3.
  3389. */
  3390. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3391. /**
  3392. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3393. * @param other defines the second operand
  3394. * @returns the current updated Vector4
  3395. */
  3396. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3397. /**
  3398. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3399. * @param other defines the second operand
  3400. * @returns the current updated Vector4
  3401. */
  3402. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3403. /**
  3404. * Gets a new Vector4 from current Vector4 floored values
  3405. * @returns a new Vector4
  3406. */
  3407. floor(): Vector4;
  3408. /**
  3409. * Gets a new Vector4 from current Vector3 floored values
  3410. * @returns a new Vector4
  3411. */
  3412. fract(): Vector4;
  3413. /**
  3414. * Returns the Vector4 length (float).
  3415. * @returns the length
  3416. */
  3417. length(): number;
  3418. /**
  3419. * Returns the Vector4 squared length (float).
  3420. * @returns the length squared
  3421. */
  3422. lengthSquared(): number;
  3423. /**
  3424. * Normalizes in place the Vector4.
  3425. * @returns the updated Vector4.
  3426. */
  3427. normalize(): Vector4;
  3428. /**
  3429. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3430. * @returns this converted to a new vector3
  3431. */
  3432. toVector3(): Vector3;
  3433. /**
  3434. * Returns a new Vector4 copied from the current one.
  3435. * @returns the new cloned vector
  3436. */
  3437. clone(): Vector4;
  3438. /**
  3439. * Updates the current Vector4 with the given one coordinates.
  3440. * @param source the source vector to copy from
  3441. * @returns the updated Vector4.
  3442. */
  3443. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3444. /**
  3445. * Updates the current Vector4 coordinates with the given floats.
  3446. * @param x float to copy from
  3447. * @param y float to copy from
  3448. * @param z float to copy from
  3449. * @param w float to copy from
  3450. * @returns the updated Vector4.
  3451. */
  3452. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3453. /**
  3454. * Updates the current Vector4 coordinates with the given floats.
  3455. * @param x float to set from
  3456. * @param y float to set from
  3457. * @param z float to set from
  3458. * @param w float to set from
  3459. * @returns the updated Vector4.
  3460. */
  3461. set(x: number, y: number, z: number, w: number): Vector4;
  3462. /**
  3463. * Copies the given float to the current Vector3 coordinates
  3464. * @param v defines the x, y, z and w coordinates of the operand
  3465. * @returns the current updated Vector3
  3466. */
  3467. setAll(v: number): Vector4;
  3468. /**
  3469. * Returns a new Vector4 set from the starting index of the given array.
  3470. * @param array the array to pull values from
  3471. * @param offset the offset into the array to start at
  3472. * @returns the new vector
  3473. */
  3474. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3475. /**
  3476. * Updates the given vector "result" from the starting index of the given array.
  3477. * @param array the array to pull values from
  3478. * @param offset the offset into the array to start at
  3479. * @param result the vector to store the result in
  3480. */
  3481. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3482. /**
  3483. * Updates the given vector "result" from the starting index of the given Float32Array.
  3484. * @param array the array to pull values from
  3485. * @param offset the offset into the array to start at
  3486. * @param result the vector to store the result in
  3487. */
  3488. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3489. /**
  3490. * Updates the given vector "result" coordinates from the given floats.
  3491. * @param x float to set from
  3492. * @param y float to set from
  3493. * @param z float to set from
  3494. * @param w float to set from
  3495. * @param result the vector to the floats in
  3496. */
  3497. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3498. /**
  3499. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3500. * @returns the new vector
  3501. */
  3502. static Zero(): Vector4;
  3503. /**
  3504. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3505. * @returns the new vector
  3506. */
  3507. static One(): Vector4;
  3508. /**
  3509. * Returns a new normalized Vector4 from the given one.
  3510. * @param vector the vector to normalize
  3511. * @returns the vector
  3512. */
  3513. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3514. /**
  3515. * Updates the given vector "result" from the normalization of the given one.
  3516. * @param vector the vector to normalize
  3517. * @param result the vector to store the result in
  3518. */
  3519. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3520. /**
  3521. * Returns a vector with the minimum values from the left and right vectors
  3522. * @param left left vector to minimize
  3523. * @param right right vector to minimize
  3524. * @returns a new vector with the minimum of the left and right vector values
  3525. */
  3526. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3527. /**
  3528. * Returns a vector with the maximum values from the left and right vectors
  3529. * @param left left vector to maximize
  3530. * @param right right vector to maximize
  3531. * @returns a new vector with the maximum of the left and right vector values
  3532. */
  3533. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3534. /**
  3535. * Returns the distance (float) between the vectors "value1" and "value2".
  3536. * @param value1 value to calulate the distance between
  3537. * @param value2 value to calulate the distance between
  3538. * @return the distance between the two vectors
  3539. */
  3540. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3541. /**
  3542. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3543. * @param value1 value to calulate the distance between
  3544. * @param value2 value to calulate the distance between
  3545. * @return the distance between the two vectors squared
  3546. */
  3547. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3548. /**
  3549. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3550. * @param value1 value to calulate the center between
  3551. * @param value2 value to calulate the center between
  3552. * @return the center between the two vectors
  3553. */
  3554. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3555. /**
  3556. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3557. * This methods computes transformed normalized direction vectors only.
  3558. * @param vector the vector to transform
  3559. * @param transformation the transformation matrix to apply
  3560. * @returns the new vector
  3561. */
  3562. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3563. /**
  3564. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3565. * This methods computes transformed normalized direction vectors only.
  3566. * @param vector the vector to transform
  3567. * @param transformation the transformation matrix to apply
  3568. * @param result the vector to store the result in
  3569. */
  3570. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3571. /**
  3572. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3573. * This methods computes transformed normalized direction vectors only.
  3574. * @param x value to transform
  3575. * @param y value to transform
  3576. * @param z value to transform
  3577. * @param w value to transform
  3578. * @param transformation the transformation matrix to apply
  3579. * @param result the vector to store the results in
  3580. */
  3581. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3582. /**
  3583. * Creates a new Vector4 from a Vector3
  3584. * @param source defines the source data
  3585. * @param w defines the 4th component (default is 0)
  3586. * @returns a new Vector4
  3587. */
  3588. static FromVector3(source: Vector3, w?: number): Vector4;
  3589. }
  3590. /**
  3591. * Class used to store quaternion data
  3592. * @see https://en.wikipedia.org/wiki/Quaternion
  3593. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3594. */
  3595. export class Quaternion {
  3596. /** @hidden */
  3597. _x: number;
  3598. /** @hidden */
  3599. _y: number;
  3600. /** @hidden */
  3601. _z: number;
  3602. /** @hidden */
  3603. _w: number;
  3604. /** @hidden */
  3605. _isDirty: boolean;
  3606. /** Gets or sets the x coordinate */
  3607. get x(): number;
  3608. set x(value: number);
  3609. /** Gets or sets the y coordinate */
  3610. get y(): number;
  3611. set y(value: number);
  3612. /** Gets or sets the z coordinate */
  3613. get z(): number;
  3614. set z(value: number);
  3615. /** Gets or sets the w coordinate */
  3616. get w(): number;
  3617. set w(value: number);
  3618. /**
  3619. * Creates a new Quaternion from the given floats
  3620. * @param x defines the first component (0 by default)
  3621. * @param y defines the second component (0 by default)
  3622. * @param z defines the third component (0 by default)
  3623. * @param w defines the fourth component (1.0 by default)
  3624. */
  3625. constructor(x?: number, y?: number, z?: number, w?: number);
  3626. /**
  3627. * Gets a string representation for the current quaternion
  3628. * @returns a string with the Quaternion coordinates
  3629. */
  3630. toString(): string;
  3631. /**
  3632. * Gets the class name of the quaternion
  3633. * @returns the string "Quaternion"
  3634. */
  3635. getClassName(): string;
  3636. /**
  3637. * Gets a hash code for this quaternion
  3638. * @returns the quaternion hash code
  3639. */
  3640. getHashCode(): number;
  3641. /**
  3642. * Copy the quaternion to an array
  3643. * @returns a new array populated with 4 elements from the quaternion coordinates
  3644. */
  3645. asArray(): number[];
  3646. /**
  3647. * Check if two quaternions are equals
  3648. * @param otherQuaternion defines the second operand
  3649. * @return true if the current quaternion and the given one coordinates are strictly equals
  3650. */
  3651. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3652. /**
  3653. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3654. * @param otherQuaternion defines the other quaternion
  3655. * @param epsilon defines the minimal distance to consider equality
  3656. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3657. */
  3658. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3659. /**
  3660. * Clone the current quaternion
  3661. * @returns a new quaternion copied from the current one
  3662. */
  3663. clone(): Quaternion;
  3664. /**
  3665. * Copy a quaternion to the current one
  3666. * @param other defines the other quaternion
  3667. * @returns the updated current quaternion
  3668. */
  3669. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3670. /**
  3671. * Updates the current quaternion with the given float coordinates
  3672. * @param x defines the x coordinate
  3673. * @param y defines the y coordinate
  3674. * @param z defines the z coordinate
  3675. * @param w defines the w coordinate
  3676. * @returns the updated current quaternion
  3677. */
  3678. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3679. /**
  3680. * Updates the current quaternion from the given float coordinates
  3681. * @param x defines the x coordinate
  3682. * @param y defines the y coordinate
  3683. * @param z defines the z coordinate
  3684. * @param w defines the w coordinate
  3685. * @returns the updated current quaternion
  3686. */
  3687. set(x: number, y: number, z: number, w: number): Quaternion;
  3688. /**
  3689. * Adds two quaternions
  3690. * @param other defines the second operand
  3691. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3692. */
  3693. add(other: DeepImmutable<Quaternion>): Quaternion;
  3694. /**
  3695. * Add a quaternion to the current one
  3696. * @param other defines the quaternion to add
  3697. * @returns the current quaternion
  3698. */
  3699. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3700. /**
  3701. * Subtract two quaternions
  3702. * @param other defines the second operand
  3703. * @returns a new quaternion as the subtraction result of the given one from the current one
  3704. */
  3705. subtract(other: Quaternion): Quaternion;
  3706. /**
  3707. * Multiplies the current quaternion by a scale factor
  3708. * @param value defines the scale factor
  3709. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3710. */
  3711. scale(value: number): Quaternion;
  3712. /**
  3713. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3714. * @param scale defines the scale factor
  3715. * @param result defines the Quaternion object where to store the result
  3716. * @returns the unmodified current quaternion
  3717. */
  3718. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3719. /**
  3720. * Multiplies in place the current quaternion by a scale factor
  3721. * @param value defines the scale factor
  3722. * @returns the current modified quaternion
  3723. */
  3724. scaleInPlace(value: number): Quaternion;
  3725. /**
  3726. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3727. * @param scale defines the scale factor
  3728. * @param result defines the Quaternion object where to store the result
  3729. * @returns the unmodified current quaternion
  3730. */
  3731. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3732. /**
  3733. * Multiplies two quaternions
  3734. * @param q1 defines the second operand
  3735. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3736. */
  3737. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3738. /**
  3739. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3740. * @param q1 defines the second operand
  3741. * @param result defines the target quaternion
  3742. * @returns the current quaternion
  3743. */
  3744. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3745. /**
  3746. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3747. * @param q1 defines the second operand
  3748. * @returns the currentupdated quaternion
  3749. */
  3750. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3751. /**
  3752. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3753. * @param ref defines the target quaternion
  3754. * @returns the current quaternion
  3755. */
  3756. conjugateToRef(ref: Quaternion): Quaternion;
  3757. /**
  3758. * Conjugates in place (1-q) the current quaternion
  3759. * @returns the current updated quaternion
  3760. */
  3761. conjugateInPlace(): Quaternion;
  3762. /**
  3763. * Conjugates in place (1-q) the current quaternion
  3764. * @returns a new quaternion
  3765. */
  3766. conjugate(): Quaternion;
  3767. /**
  3768. * Gets length of current quaternion
  3769. * @returns the quaternion length (float)
  3770. */
  3771. length(): number;
  3772. /**
  3773. * Normalize in place the current quaternion
  3774. * @returns the current updated quaternion
  3775. */
  3776. normalize(): Quaternion;
  3777. /**
  3778. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3779. * @param order is a reserved parameter and is ignore for now
  3780. * @returns a new Vector3 containing the Euler angles
  3781. */
  3782. toEulerAngles(order?: string): Vector3;
  3783. /**
  3784. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3785. * @param result defines the vector which will be filled with the Euler angles
  3786. * @param order is a reserved parameter and is ignore for now
  3787. * @returns the current unchanged quaternion
  3788. */
  3789. toEulerAnglesToRef(result: Vector3): Quaternion;
  3790. /**
  3791. * Updates the given rotation matrix with the current quaternion values
  3792. * @param result defines the target matrix
  3793. * @returns the current unchanged quaternion
  3794. */
  3795. toRotationMatrix(result: Matrix): Quaternion;
  3796. /**
  3797. * Updates the current quaternion from the given rotation matrix values
  3798. * @param matrix defines the source matrix
  3799. * @returns the current updated quaternion
  3800. */
  3801. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3802. /**
  3803. * Creates a new quaternion from a rotation matrix
  3804. * @param matrix defines the source matrix
  3805. * @returns a new quaternion created from the given rotation matrix values
  3806. */
  3807. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3808. /**
  3809. * Updates the given quaternion with the given rotation matrix values
  3810. * @param matrix defines the source matrix
  3811. * @param result defines the target quaternion
  3812. */
  3813. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3814. /**
  3815. * Returns the dot product (float) between the quaternions "left" and "right"
  3816. * @param left defines the left operand
  3817. * @param right defines the right operand
  3818. * @returns the dot product
  3819. */
  3820. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3821. /**
  3822. * Checks if the two quaternions are close to each other
  3823. * @param quat0 defines the first quaternion to check
  3824. * @param quat1 defines the second quaternion to check
  3825. * @returns true if the two quaternions are close to each other
  3826. */
  3827. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3828. /**
  3829. * Creates an empty quaternion
  3830. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3831. */
  3832. static Zero(): Quaternion;
  3833. /**
  3834. * Inverse a given quaternion
  3835. * @param q defines the source quaternion
  3836. * @returns a new quaternion as the inverted current quaternion
  3837. */
  3838. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3839. /**
  3840. * Inverse a given quaternion
  3841. * @param q defines the source quaternion
  3842. * @param result the quaternion the result will be stored in
  3843. * @returns the result quaternion
  3844. */
  3845. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3846. /**
  3847. * Creates an identity quaternion
  3848. * @returns the identity quaternion
  3849. */
  3850. static Identity(): Quaternion;
  3851. /**
  3852. * Gets a boolean indicating if the given quaternion is identity
  3853. * @param quaternion defines the quaternion to check
  3854. * @returns true if the quaternion is identity
  3855. */
  3856. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3857. /**
  3858. * Creates a quaternion from a rotation around an axis
  3859. * @param axis defines the axis to use
  3860. * @param angle defines the angle to use
  3861. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3862. */
  3863. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3864. /**
  3865. * Creates a rotation around an axis and stores it into the given quaternion
  3866. * @param axis defines the axis to use
  3867. * @param angle defines the angle to use
  3868. * @param result defines the target quaternion
  3869. * @returns the target quaternion
  3870. */
  3871. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3872. /**
  3873. * Creates a new quaternion from data stored into an array
  3874. * @param array defines the data source
  3875. * @param offset defines the offset in the source array where the data starts
  3876. * @returns a new quaternion
  3877. */
  3878. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3879. /**
  3880. * Updates the given quaternion "result" from the starting index of the given array.
  3881. * @param array the array to pull values from
  3882. * @param offset the offset into the array to start at
  3883. * @param result the quaternion to store the result in
  3884. */
  3885. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3886. /**
  3887. * Create a quaternion from Euler rotation angles
  3888. * @param x Pitch
  3889. * @param y Yaw
  3890. * @param z Roll
  3891. * @returns the new Quaternion
  3892. */
  3893. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3894. /**
  3895. * Updates a quaternion from Euler rotation angles
  3896. * @param x Pitch
  3897. * @param y Yaw
  3898. * @param z Roll
  3899. * @param result the quaternion to store the result
  3900. * @returns the updated quaternion
  3901. */
  3902. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3903. /**
  3904. * Create a quaternion from Euler rotation vector
  3905. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3906. * @returns the new Quaternion
  3907. */
  3908. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3909. /**
  3910. * Updates a quaternion from Euler rotation vector
  3911. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3912. * @param result the quaternion to store the result
  3913. * @returns the updated quaternion
  3914. */
  3915. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3916. /**
  3917. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3918. * @param yaw defines the rotation around Y axis
  3919. * @param pitch defines the rotation around X axis
  3920. * @param roll defines the rotation around Z axis
  3921. * @returns the new quaternion
  3922. */
  3923. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3924. /**
  3925. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3926. * @param yaw defines the rotation around Y axis
  3927. * @param pitch defines the rotation around X axis
  3928. * @param roll defines the rotation around Z axis
  3929. * @param result defines the target quaternion
  3930. */
  3931. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3932. /**
  3933. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3934. * @param alpha defines the rotation around first axis
  3935. * @param beta defines the rotation around second axis
  3936. * @param gamma defines the rotation around third axis
  3937. * @returns the new quaternion
  3938. */
  3939. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3940. /**
  3941. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3942. * @param alpha defines the rotation around first axis
  3943. * @param beta defines the rotation around second axis
  3944. * @param gamma defines the rotation around third axis
  3945. * @param result defines the target quaternion
  3946. */
  3947. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3948. /**
  3949. * 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)
  3950. * @param axis1 defines the first axis
  3951. * @param axis2 defines the second axis
  3952. * @param axis3 defines the third axis
  3953. * @returns the new quaternion
  3954. */
  3955. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3956. /**
  3957. * 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
  3958. * @param axis1 defines the first axis
  3959. * @param axis2 defines the second axis
  3960. * @param axis3 defines the third axis
  3961. * @param ref defines the target quaternion
  3962. */
  3963. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3964. /**
  3965. * Interpolates between two quaternions
  3966. * @param left defines first quaternion
  3967. * @param right defines second quaternion
  3968. * @param amount defines the gradient to use
  3969. * @returns the new interpolated quaternion
  3970. */
  3971. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3972. /**
  3973. * Interpolates between two quaternions and stores it into a target quaternion
  3974. * @param left defines first quaternion
  3975. * @param right defines second quaternion
  3976. * @param amount defines the gradient to use
  3977. * @param result defines the target quaternion
  3978. */
  3979. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3980. /**
  3981. * Interpolate between two quaternions using Hermite interpolation
  3982. * @param value1 defines first quaternion
  3983. * @param tangent1 defines the incoming tangent
  3984. * @param value2 defines second quaternion
  3985. * @param tangent2 defines the outgoing tangent
  3986. * @param amount defines the target quaternion
  3987. * @returns the new interpolated quaternion
  3988. */
  3989. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3990. }
  3991. /**
  3992. * Class used to store matrix data (4x4)
  3993. */
  3994. export class Matrix {
  3995. private static _updateFlagSeed;
  3996. private static _identityReadOnly;
  3997. private _isIdentity;
  3998. private _isIdentityDirty;
  3999. private _isIdentity3x2;
  4000. private _isIdentity3x2Dirty;
  4001. /**
  4002. * Gets the update flag of the matrix which is an unique number for the matrix.
  4003. * It will be incremented every time the matrix data change.
  4004. * You can use it to speed the comparison between two versions of the same matrix.
  4005. */
  4006. updateFlag: number;
  4007. private readonly _m;
  4008. /**
  4009. * Gets the internal data of the matrix
  4010. */
  4011. get m(): DeepImmutable<Float32Array>;
  4012. /** @hidden */
  4013. _markAsUpdated(): void;
  4014. /** @hidden */
  4015. private _updateIdentityStatus;
  4016. /**
  4017. * Creates an empty matrix (filled with zeros)
  4018. */
  4019. constructor();
  4020. /**
  4021. * Check if the current matrix is identity
  4022. * @returns true is the matrix is the identity matrix
  4023. */
  4024. isIdentity(): boolean;
  4025. /**
  4026. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4027. * @returns true is the matrix is the identity matrix
  4028. */
  4029. isIdentityAs3x2(): boolean;
  4030. /**
  4031. * Gets the determinant of the matrix
  4032. * @returns the matrix determinant
  4033. */
  4034. determinant(): number;
  4035. /**
  4036. * Returns the matrix as a Float32Array
  4037. * @returns the matrix underlying array
  4038. */
  4039. toArray(): DeepImmutable<Float32Array>;
  4040. /**
  4041. * Returns the matrix as a Float32Array
  4042. * @returns the matrix underlying array.
  4043. */
  4044. asArray(): DeepImmutable<Float32Array>;
  4045. /**
  4046. * Inverts the current matrix in place
  4047. * @returns the current inverted matrix
  4048. */
  4049. invert(): Matrix;
  4050. /**
  4051. * Sets all the matrix elements to zero
  4052. * @returns the current matrix
  4053. */
  4054. reset(): Matrix;
  4055. /**
  4056. * Adds the current matrix with a second one
  4057. * @param other defines the matrix to add
  4058. * @returns a new matrix as the addition of the current matrix and the given one
  4059. */
  4060. add(other: DeepImmutable<Matrix>): Matrix;
  4061. /**
  4062. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4063. * @param other defines the matrix to add
  4064. * @param result defines the target matrix
  4065. * @returns the current matrix
  4066. */
  4067. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4068. /**
  4069. * Adds in place the given matrix to the current matrix
  4070. * @param other defines the second operand
  4071. * @returns the current updated matrix
  4072. */
  4073. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4074. /**
  4075. * Sets the given matrix to the current inverted Matrix
  4076. * @param other defines the target matrix
  4077. * @returns the unmodified current matrix
  4078. */
  4079. invertToRef(other: Matrix): Matrix;
  4080. /**
  4081. * add a value at the specified position in the current Matrix
  4082. * @param index the index of the value within the matrix. between 0 and 15.
  4083. * @param value the value to be added
  4084. * @returns the current updated matrix
  4085. */
  4086. addAtIndex(index: number, value: number): Matrix;
  4087. /**
  4088. * mutiply the specified position in the current Matrix by a value
  4089. * @param index the index of the value within the matrix. between 0 and 15.
  4090. * @param value the value to be added
  4091. * @returns the current updated matrix
  4092. */
  4093. multiplyAtIndex(index: number, value: number): Matrix;
  4094. /**
  4095. * Inserts the translation vector (using 3 floats) in the current matrix
  4096. * @param x defines the 1st component of the translation
  4097. * @param y defines the 2nd component of the translation
  4098. * @param z defines the 3rd component of the translation
  4099. * @returns the current updated matrix
  4100. */
  4101. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4102. /**
  4103. * Adds the translation vector (using 3 floats) in the current matrix
  4104. * @param x defines the 1st component of the translation
  4105. * @param y defines the 2nd component of the translation
  4106. * @param z defines the 3rd component of the translation
  4107. * @returns the current updated matrix
  4108. */
  4109. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4110. /**
  4111. * Inserts the translation vector in the current matrix
  4112. * @param vector3 defines the translation to insert
  4113. * @returns the current updated matrix
  4114. */
  4115. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4116. /**
  4117. * Gets the translation value of the current matrix
  4118. * @returns a new Vector3 as the extracted translation from the matrix
  4119. */
  4120. getTranslation(): Vector3;
  4121. /**
  4122. * Fill a Vector3 with the extracted translation from the matrix
  4123. * @param result defines the Vector3 where to store the translation
  4124. * @returns the current matrix
  4125. */
  4126. getTranslationToRef(result: Vector3): Matrix;
  4127. /**
  4128. * Remove rotation and scaling part from the matrix
  4129. * @returns the updated matrix
  4130. */
  4131. removeRotationAndScaling(): Matrix;
  4132. /**
  4133. * Multiply two matrices
  4134. * @param other defines the second operand
  4135. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4136. */
  4137. multiply(other: DeepImmutable<Matrix>): Matrix;
  4138. /**
  4139. * Copy the current matrix from the given one
  4140. * @param other defines the source matrix
  4141. * @returns the current updated matrix
  4142. */
  4143. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4144. /**
  4145. * Populates the given array from the starting index with the current matrix values
  4146. * @param array defines the target array
  4147. * @param offset defines the offset in the target array where to start storing values
  4148. * @returns the current matrix
  4149. */
  4150. copyToArray(array: Float32Array, offset?: number): Matrix;
  4151. /**
  4152. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4153. * @param other defines the second operand
  4154. * @param result defines the matrix where to store the multiplication
  4155. * @returns the current matrix
  4156. */
  4157. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4158. /**
  4159. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4160. * @param other defines the second operand
  4161. * @param result defines the array where to store the multiplication
  4162. * @param offset defines the offset in the target array where to start storing values
  4163. * @returns the current matrix
  4164. */
  4165. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4166. /**
  4167. * Check equality between this matrix and a second one
  4168. * @param value defines the second matrix to compare
  4169. * @returns true is the current matrix and the given one values are strictly equal
  4170. */
  4171. equals(value: DeepImmutable<Matrix>): boolean;
  4172. /**
  4173. * Clone the current matrix
  4174. * @returns a new matrix from the current matrix
  4175. */
  4176. clone(): Matrix;
  4177. /**
  4178. * Returns the name of the current matrix class
  4179. * @returns the string "Matrix"
  4180. */
  4181. getClassName(): string;
  4182. /**
  4183. * Gets the hash code of the current matrix
  4184. * @returns the hash code
  4185. */
  4186. getHashCode(): number;
  4187. /**
  4188. * Decomposes the current Matrix into a translation, rotation and scaling components
  4189. * @param scale defines the scale vector3 given as a reference to update
  4190. * @param rotation defines the rotation quaternion given as a reference to update
  4191. * @param translation defines the translation vector3 given as a reference to update
  4192. * @returns true if operation was successful
  4193. */
  4194. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4195. /**
  4196. * Gets specific row of the matrix
  4197. * @param index defines the number of the row to get
  4198. * @returns the index-th row of the current matrix as a new Vector4
  4199. */
  4200. getRow(index: number): Nullable<Vector4>;
  4201. /**
  4202. * Sets the index-th row of the current matrix to the vector4 values
  4203. * @param index defines the number of the row to set
  4204. * @param row defines the target vector4
  4205. * @returns the updated current matrix
  4206. */
  4207. setRow(index: number, row: Vector4): Matrix;
  4208. /**
  4209. * Compute the transpose of the matrix
  4210. * @returns the new transposed matrix
  4211. */
  4212. transpose(): Matrix;
  4213. /**
  4214. * Compute the transpose of the matrix and store it in a given matrix
  4215. * @param result defines the target matrix
  4216. * @returns the current matrix
  4217. */
  4218. transposeToRef(result: Matrix): Matrix;
  4219. /**
  4220. * Sets the index-th row of the current matrix with the given 4 x float values
  4221. * @param index defines the row index
  4222. * @param x defines the x component to set
  4223. * @param y defines the y component to set
  4224. * @param z defines the z component to set
  4225. * @param w defines the w component to set
  4226. * @returns the updated current matrix
  4227. */
  4228. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4229. /**
  4230. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4231. * @param scale defines the scale factor
  4232. * @returns a new matrix
  4233. */
  4234. scale(scale: number): Matrix;
  4235. /**
  4236. * Scale the current matrix values by a factor to a given result matrix
  4237. * @param scale defines the scale factor
  4238. * @param result defines the matrix to store the result
  4239. * @returns the current matrix
  4240. */
  4241. scaleToRef(scale: number, result: Matrix): Matrix;
  4242. /**
  4243. * Scale the current matrix values by a factor and add the result to a given matrix
  4244. * @param scale defines the scale factor
  4245. * @param result defines the Matrix to store the result
  4246. * @returns the current matrix
  4247. */
  4248. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4249. /**
  4250. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4251. * @param ref matrix to store the result
  4252. */
  4253. toNormalMatrix(ref: Matrix): void;
  4254. /**
  4255. * Gets only rotation part of the current matrix
  4256. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4257. */
  4258. getRotationMatrix(): Matrix;
  4259. /**
  4260. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4261. * @param result defines the target matrix to store data to
  4262. * @returns the current matrix
  4263. */
  4264. getRotationMatrixToRef(result: Matrix): Matrix;
  4265. /**
  4266. * Toggles model matrix from being right handed to left handed in place and vice versa
  4267. */
  4268. toggleModelMatrixHandInPlace(): void;
  4269. /**
  4270. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4271. */
  4272. toggleProjectionMatrixHandInPlace(): void;
  4273. /**
  4274. * Creates a matrix from an array
  4275. * @param array defines the source array
  4276. * @param offset defines an offset in the source array
  4277. * @returns a new Matrix set from the starting index of the given array
  4278. */
  4279. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4280. /**
  4281. * Copy the content of an array into a given matrix
  4282. * @param array defines the source array
  4283. * @param offset defines an offset in the source array
  4284. * @param result defines the target matrix
  4285. */
  4286. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4287. /**
  4288. * Stores an array into a matrix after having multiplied each component by a given factor
  4289. * @param array defines the source array
  4290. * @param offset defines the offset in the source array
  4291. * @param scale defines the scaling factor
  4292. * @param result defines the target matrix
  4293. */
  4294. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4295. /**
  4296. * Gets an identity matrix that must not be updated
  4297. */
  4298. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4299. /**
  4300. * Stores a list of values (16) inside a given matrix
  4301. * @param initialM11 defines 1st value of 1st row
  4302. * @param initialM12 defines 2nd value of 1st row
  4303. * @param initialM13 defines 3rd value of 1st row
  4304. * @param initialM14 defines 4th value of 1st row
  4305. * @param initialM21 defines 1st value of 2nd row
  4306. * @param initialM22 defines 2nd value of 2nd row
  4307. * @param initialM23 defines 3rd value of 2nd row
  4308. * @param initialM24 defines 4th value of 2nd row
  4309. * @param initialM31 defines 1st value of 3rd row
  4310. * @param initialM32 defines 2nd value of 3rd row
  4311. * @param initialM33 defines 3rd value of 3rd row
  4312. * @param initialM34 defines 4th value of 3rd row
  4313. * @param initialM41 defines 1st value of 4th row
  4314. * @param initialM42 defines 2nd value of 4th row
  4315. * @param initialM43 defines 3rd value of 4th row
  4316. * @param initialM44 defines 4th value of 4th row
  4317. * @param result defines the target matrix
  4318. */
  4319. 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;
  4320. /**
  4321. * Creates new matrix from a list of values (16)
  4322. * @param initialM11 defines 1st value of 1st row
  4323. * @param initialM12 defines 2nd value of 1st row
  4324. * @param initialM13 defines 3rd value of 1st row
  4325. * @param initialM14 defines 4th value of 1st row
  4326. * @param initialM21 defines 1st value of 2nd row
  4327. * @param initialM22 defines 2nd value of 2nd row
  4328. * @param initialM23 defines 3rd value of 2nd row
  4329. * @param initialM24 defines 4th value of 2nd row
  4330. * @param initialM31 defines 1st value of 3rd row
  4331. * @param initialM32 defines 2nd value of 3rd row
  4332. * @param initialM33 defines 3rd value of 3rd row
  4333. * @param initialM34 defines 4th value of 3rd row
  4334. * @param initialM41 defines 1st value of 4th row
  4335. * @param initialM42 defines 2nd value of 4th row
  4336. * @param initialM43 defines 3rd value of 4th row
  4337. * @param initialM44 defines 4th value of 4th row
  4338. * @returns the new matrix
  4339. */
  4340. 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;
  4341. /**
  4342. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4343. * @param scale defines the scale vector3
  4344. * @param rotation defines the rotation quaternion
  4345. * @param translation defines the translation vector3
  4346. * @returns a new matrix
  4347. */
  4348. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4349. /**
  4350. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4351. * @param scale defines the scale vector3
  4352. * @param rotation defines the rotation quaternion
  4353. * @param translation defines the translation vector3
  4354. * @param result defines the target matrix
  4355. */
  4356. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4357. /**
  4358. * Creates a new identity matrix
  4359. * @returns a new identity matrix
  4360. */
  4361. static Identity(): Matrix;
  4362. /**
  4363. * Creates a new identity matrix and stores the result in a given matrix
  4364. * @param result defines the target matrix
  4365. */
  4366. static IdentityToRef(result: Matrix): void;
  4367. /**
  4368. * Creates a new zero matrix
  4369. * @returns a new zero matrix
  4370. */
  4371. static Zero(): Matrix;
  4372. /**
  4373. * Creates a new rotation matrix for "angle" radians around the X axis
  4374. * @param angle defines the angle (in radians) to use
  4375. * @return the new matrix
  4376. */
  4377. static RotationX(angle: number): Matrix;
  4378. /**
  4379. * Creates a new matrix as the invert of a given matrix
  4380. * @param source defines the source matrix
  4381. * @returns the new matrix
  4382. */
  4383. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4384. /**
  4385. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4386. * @param angle defines the angle (in radians) to use
  4387. * @param result defines the target matrix
  4388. */
  4389. static RotationXToRef(angle: number, result: Matrix): void;
  4390. /**
  4391. * Creates a new rotation matrix for "angle" radians around the Y axis
  4392. * @param angle defines the angle (in radians) to use
  4393. * @return the new matrix
  4394. */
  4395. static RotationY(angle: number): Matrix;
  4396. /**
  4397. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4398. * @param angle defines the angle (in radians) to use
  4399. * @param result defines the target matrix
  4400. */
  4401. static RotationYToRef(angle: number, result: Matrix): void;
  4402. /**
  4403. * Creates a new rotation matrix for "angle" radians around the Z axis
  4404. * @param angle defines the angle (in radians) to use
  4405. * @return the new matrix
  4406. */
  4407. static RotationZ(angle: number): Matrix;
  4408. /**
  4409. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4410. * @param angle defines the angle (in radians) to use
  4411. * @param result defines the target matrix
  4412. */
  4413. static RotationZToRef(angle: number, result: Matrix): void;
  4414. /**
  4415. * Creates a new rotation matrix for "angle" radians around the given axis
  4416. * @param axis defines the axis to use
  4417. * @param angle defines the angle (in radians) to use
  4418. * @return the new matrix
  4419. */
  4420. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4421. /**
  4422. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4423. * @param axis defines the axis to use
  4424. * @param angle defines the angle (in radians) to use
  4425. * @param result defines the target matrix
  4426. */
  4427. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4428. /**
  4429. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4430. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4431. * @param from defines the vector to align
  4432. * @param to defines the vector to align to
  4433. * @param result defines the target matrix
  4434. */
  4435. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4436. /**
  4437. * Creates a rotation matrix
  4438. * @param yaw defines the yaw angle in radians (Y axis)
  4439. * @param pitch defines the pitch angle in radians (X axis)
  4440. * @param roll defines the roll angle in radians (X axis)
  4441. * @returns the new rotation matrix
  4442. */
  4443. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4444. /**
  4445. * Creates a rotation matrix and stores it in a given matrix
  4446. * @param yaw defines the yaw angle in radians (Y axis)
  4447. * @param pitch defines the pitch angle in radians (X axis)
  4448. * @param roll defines the roll angle in radians (X axis)
  4449. * @param result defines the target matrix
  4450. */
  4451. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4452. /**
  4453. * Creates a scaling matrix
  4454. * @param x defines the scale factor on X axis
  4455. * @param y defines the scale factor on Y axis
  4456. * @param z defines the scale factor on Z axis
  4457. * @returns the new matrix
  4458. */
  4459. static Scaling(x: number, y: number, z: number): Matrix;
  4460. /**
  4461. * Creates a scaling matrix and stores it in a given matrix
  4462. * @param x defines the scale factor on X axis
  4463. * @param y defines the scale factor on Y axis
  4464. * @param z defines the scale factor on Z axis
  4465. * @param result defines the target matrix
  4466. */
  4467. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4468. /**
  4469. * Creates a translation matrix
  4470. * @param x defines the translation on X axis
  4471. * @param y defines the translation on Y axis
  4472. * @param z defines the translationon Z axis
  4473. * @returns the new matrix
  4474. */
  4475. static Translation(x: number, y: number, z: number): Matrix;
  4476. /**
  4477. * Creates a translation matrix and stores it in a given matrix
  4478. * @param x defines the translation on X axis
  4479. * @param y defines the translation on Y axis
  4480. * @param z defines the translationon Z axis
  4481. * @param result defines the target matrix
  4482. */
  4483. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4484. /**
  4485. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4486. * @param startValue defines the start value
  4487. * @param endValue defines the end value
  4488. * @param gradient defines the gradient factor
  4489. * @returns the new matrix
  4490. */
  4491. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4492. /**
  4493. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4494. * @param startValue defines the start value
  4495. * @param endValue defines the end value
  4496. * @param gradient defines the gradient factor
  4497. * @param result defines the Matrix object where to store data
  4498. */
  4499. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4500. /**
  4501. * Builds a new matrix whose values are computed by:
  4502. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4503. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4504. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4505. * @param startValue defines the first matrix
  4506. * @param endValue defines the second matrix
  4507. * @param gradient defines the gradient between the two matrices
  4508. * @returns the new matrix
  4509. */
  4510. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4511. /**
  4512. * Update a matrix to values which are computed by:
  4513. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4514. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4515. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4516. * @param startValue defines the first matrix
  4517. * @param endValue defines the second matrix
  4518. * @param gradient defines the gradient between the two matrices
  4519. * @param result defines the target matrix
  4520. */
  4521. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4522. /**
  4523. * 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"
  4524. * This function works in left handed mode
  4525. * @param eye defines the final position of the entity
  4526. * @param target defines where the entity should look at
  4527. * @param up defines the up vector for the entity
  4528. * @returns the new matrix
  4529. */
  4530. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4531. /**
  4532. * 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".
  4533. * This function works in left handed mode
  4534. * @param eye defines the final position of the entity
  4535. * @param target defines where the entity should look at
  4536. * @param up defines the up vector for the entity
  4537. * @param result defines the target matrix
  4538. */
  4539. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4540. /**
  4541. * 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"
  4542. * This function works in right handed mode
  4543. * @param eye defines the final position of the entity
  4544. * @param target defines where the entity should look at
  4545. * @param up defines the up vector for the entity
  4546. * @returns the new matrix
  4547. */
  4548. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4549. /**
  4550. * 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".
  4551. * This function works in right handed mode
  4552. * @param eye defines the final position of the entity
  4553. * @param target defines where the entity should look at
  4554. * @param up defines the up vector for the entity
  4555. * @param result defines the target matrix
  4556. */
  4557. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4558. /**
  4559. * Create a left-handed orthographic projection matrix
  4560. * @param width defines the viewport width
  4561. * @param height defines the viewport height
  4562. * @param znear defines the near clip plane
  4563. * @param zfar defines the far clip plane
  4564. * @returns a new matrix as a left-handed orthographic projection matrix
  4565. */
  4566. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4567. /**
  4568. * Store a left-handed orthographic projection to a given matrix
  4569. * @param width defines the viewport width
  4570. * @param height defines the viewport height
  4571. * @param znear defines the near clip plane
  4572. * @param zfar defines the far clip plane
  4573. * @param result defines the target matrix
  4574. */
  4575. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4576. /**
  4577. * Create a left-handed orthographic projection matrix
  4578. * @param left defines the viewport left coordinate
  4579. * @param right defines the viewport right coordinate
  4580. * @param bottom defines the viewport bottom coordinate
  4581. * @param top defines the viewport top coordinate
  4582. * @param znear defines the near clip plane
  4583. * @param zfar defines the far clip plane
  4584. * @returns a new matrix as a left-handed orthographic projection matrix
  4585. */
  4586. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4587. /**
  4588. * Stores a left-handed orthographic projection into a given matrix
  4589. * @param left defines the viewport left coordinate
  4590. * @param right defines the viewport right coordinate
  4591. * @param bottom defines the viewport bottom coordinate
  4592. * @param top defines the viewport top coordinate
  4593. * @param znear defines the near clip plane
  4594. * @param zfar defines the far clip plane
  4595. * @param result defines the target matrix
  4596. */
  4597. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4598. /**
  4599. * Creates a right-handed orthographic projection matrix
  4600. * @param left defines the viewport left coordinate
  4601. * @param right defines the viewport right coordinate
  4602. * @param bottom defines the viewport bottom coordinate
  4603. * @param top defines the viewport top coordinate
  4604. * @param znear defines the near clip plane
  4605. * @param zfar defines the far clip plane
  4606. * @returns a new matrix as a right-handed orthographic projection matrix
  4607. */
  4608. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4609. /**
  4610. * Stores a right-handed orthographic projection into a given matrix
  4611. * @param left defines the viewport left coordinate
  4612. * @param right defines the viewport right coordinate
  4613. * @param bottom defines the viewport bottom coordinate
  4614. * @param top defines the viewport top coordinate
  4615. * @param znear defines the near clip plane
  4616. * @param zfar defines the far clip plane
  4617. * @param result defines the target matrix
  4618. */
  4619. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4620. /**
  4621. * Creates a left-handed perspective projection matrix
  4622. * @param width defines the viewport width
  4623. * @param height defines the viewport height
  4624. * @param znear defines the near clip plane
  4625. * @param zfar defines the far clip plane
  4626. * @returns a new matrix as a left-handed perspective projection matrix
  4627. */
  4628. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4629. /**
  4630. * Creates a left-handed perspective projection matrix
  4631. * @param fov defines the horizontal field of view
  4632. * @param aspect defines the aspect ratio
  4633. * @param znear defines the near clip plane
  4634. * @param zfar defines the far clip plane
  4635. * @returns a new matrix as a left-handed perspective projection matrix
  4636. */
  4637. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4638. /**
  4639. * Stores a left-handed perspective projection into a given matrix
  4640. * @param fov defines the horizontal field of view
  4641. * @param aspect defines the aspect ratio
  4642. * @param znear defines the near clip plane
  4643. * @param zfar defines the far clip plane
  4644. * @param result defines the target matrix
  4645. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4646. */
  4647. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4648. /**
  4649. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4650. * @param fov defines the horizontal field of view
  4651. * @param aspect defines the aspect ratio
  4652. * @param znear defines the near clip plane
  4653. * @param zfar not used as infinity is used as far clip
  4654. * @param result defines the target matrix
  4655. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4656. */
  4657. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4658. /**
  4659. * Creates a right-handed perspective projection matrix
  4660. * @param fov defines the horizontal field of view
  4661. * @param aspect defines the aspect ratio
  4662. * @param znear defines the near clip plane
  4663. * @param zfar defines the far clip plane
  4664. * @returns a new matrix as a right-handed perspective projection matrix
  4665. */
  4666. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4667. /**
  4668. * Stores a right-handed perspective projection into a given matrix
  4669. * @param fov defines the horizontal field of view
  4670. * @param aspect defines the aspect ratio
  4671. * @param znear defines the near clip plane
  4672. * @param zfar defines the far clip plane
  4673. * @param result defines the target matrix
  4674. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4675. */
  4676. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4677. /**
  4678. * Stores a right-handed perspective projection into a given matrix
  4679. * @param fov defines the horizontal field of view
  4680. * @param aspect defines the aspect ratio
  4681. * @param znear defines the near clip plane
  4682. * @param zfar not used as infinity is used as far clip
  4683. * @param result defines the target matrix
  4684. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4685. */
  4686. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4687. /**
  4688. * Stores a perspective projection for WebVR info a given matrix
  4689. * @param fov defines the field of view
  4690. * @param znear defines the near clip plane
  4691. * @param zfar defines the far clip plane
  4692. * @param result defines the target matrix
  4693. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4694. */
  4695. static PerspectiveFovWebVRToRef(fov: {
  4696. upDegrees: number;
  4697. downDegrees: number;
  4698. leftDegrees: number;
  4699. rightDegrees: number;
  4700. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4701. /**
  4702. * Computes a complete transformation matrix
  4703. * @param viewport defines the viewport to use
  4704. * @param world defines the world matrix
  4705. * @param view defines the view matrix
  4706. * @param projection defines the projection matrix
  4707. * @param zmin defines the near clip plane
  4708. * @param zmax defines the far clip plane
  4709. * @returns the transformation matrix
  4710. */
  4711. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4712. /**
  4713. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4714. * @param matrix defines the matrix to use
  4715. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4716. */
  4717. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4718. /**
  4719. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4720. * @param matrix defines the matrix to use
  4721. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4722. */
  4723. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4724. /**
  4725. * Compute the transpose of a given matrix
  4726. * @param matrix defines the matrix to transpose
  4727. * @returns the new matrix
  4728. */
  4729. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4730. /**
  4731. * Compute the transpose of a matrix and store it in a target matrix
  4732. * @param matrix defines the matrix to transpose
  4733. * @param result defines the target matrix
  4734. */
  4735. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4736. /**
  4737. * Computes a reflection matrix from a plane
  4738. * @param plane defines the reflection plane
  4739. * @returns a new matrix
  4740. */
  4741. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4742. /**
  4743. * Computes a reflection matrix from a plane
  4744. * @param plane defines the reflection plane
  4745. * @param result defines the target matrix
  4746. */
  4747. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4748. /**
  4749. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4750. * @param xaxis defines the value of the 1st axis
  4751. * @param yaxis defines the value of the 2nd axis
  4752. * @param zaxis defines the value of the 3rd axis
  4753. * @param result defines the target matrix
  4754. */
  4755. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4756. /**
  4757. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4758. * @param quat defines the quaternion to use
  4759. * @param result defines the target matrix
  4760. */
  4761. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4762. }
  4763. /**
  4764. * @hidden
  4765. */
  4766. export class TmpVectors {
  4767. static Vector2: Vector2[];
  4768. static Vector3: Vector3[];
  4769. static Vector4: Vector4[];
  4770. static Quaternion: Quaternion[];
  4771. static Matrix: Matrix[];
  4772. }
  4773. }
  4774. declare module BABYLON {
  4775. /**
  4776. * Defines potential orientation for back face culling
  4777. */
  4778. export enum Orientation {
  4779. /**
  4780. * Clockwise
  4781. */
  4782. CW = 0,
  4783. /** Counter clockwise */
  4784. CCW = 1
  4785. }
  4786. /** Class used to represent a Bezier curve */
  4787. export class BezierCurve {
  4788. /**
  4789. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4790. * @param t defines the time
  4791. * @param x1 defines the left coordinate on X axis
  4792. * @param y1 defines the left coordinate on Y axis
  4793. * @param x2 defines the right coordinate on X axis
  4794. * @param y2 defines the right coordinate on Y axis
  4795. * @returns the interpolated value
  4796. */
  4797. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4798. }
  4799. /**
  4800. * Defines angle representation
  4801. */
  4802. export class Angle {
  4803. private _radians;
  4804. /**
  4805. * Creates an Angle object of "radians" radians (float).
  4806. * @param radians the angle in radians
  4807. */
  4808. constructor(radians: number);
  4809. /**
  4810. * Get value in degrees
  4811. * @returns the Angle value in degrees (float)
  4812. */
  4813. degrees(): number;
  4814. /**
  4815. * Get value in radians
  4816. * @returns the Angle value in radians (float)
  4817. */
  4818. radians(): number;
  4819. /**
  4820. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4821. * @param a defines first vector
  4822. * @param b defines second vector
  4823. * @returns a new Angle
  4824. */
  4825. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4826. /**
  4827. * Gets a new Angle object from the given float in radians
  4828. * @param radians defines the angle value in radians
  4829. * @returns a new Angle
  4830. */
  4831. static FromRadians(radians: number): Angle;
  4832. /**
  4833. * Gets a new Angle object from the given float in degrees
  4834. * @param degrees defines the angle value in degrees
  4835. * @returns a new Angle
  4836. */
  4837. static FromDegrees(degrees: number): Angle;
  4838. }
  4839. /**
  4840. * This represents an arc in a 2d space.
  4841. */
  4842. export class Arc2 {
  4843. /** Defines the start point of the arc */
  4844. startPoint: Vector2;
  4845. /** Defines the mid point of the arc */
  4846. midPoint: Vector2;
  4847. /** Defines the end point of the arc */
  4848. endPoint: Vector2;
  4849. /**
  4850. * Defines the center point of the arc.
  4851. */
  4852. centerPoint: Vector2;
  4853. /**
  4854. * Defines the radius of the arc.
  4855. */
  4856. radius: number;
  4857. /**
  4858. * Defines the angle of the arc (from mid point to end point).
  4859. */
  4860. angle: Angle;
  4861. /**
  4862. * Defines the start angle of the arc (from start point to middle point).
  4863. */
  4864. startAngle: Angle;
  4865. /**
  4866. * Defines the orientation of the arc (clock wise/counter clock wise).
  4867. */
  4868. orientation: Orientation;
  4869. /**
  4870. * Creates an Arc object from the three given points : start, middle and end.
  4871. * @param startPoint Defines the start point of the arc
  4872. * @param midPoint Defines the midlle point of the arc
  4873. * @param endPoint Defines the end point of the arc
  4874. */
  4875. constructor(
  4876. /** Defines the start point of the arc */
  4877. startPoint: Vector2,
  4878. /** Defines the mid point of the arc */
  4879. midPoint: Vector2,
  4880. /** Defines the end point of the arc */
  4881. endPoint: Vector2);
  4882. }
  4883. /**
  4884. * Represents a 2D path made up of multiple 2D points
  4885. */
  4886. export class Path2 {
  4887. private _points;
  4888. private _length;
  4889. /**
  4890. * If the path start and end point are the same
  4891. */
  4892. closed: boolean;
  4893. /**
  4894. * Creates a Path2 object from the starting 2D coordinates x and y.
  4895. * @param x the starting points x value
  4896. * @param y the starting points y value
  4897. */
  4898. constructor(x: number, y: number);
  4899. /**
  4900. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4901. * @param x the added points x value
  4902. * @param y the added points y value
  4903. * @returns the updated Path2.
  4904. */
  4905. addLineTo(x: number, y: number): Path2;
  4906. /**
  4907. * 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.
  4908. * @param midX middle point x value
  4909. * @param midY middle point y value
  4910. * @param endX end point x value
  4911. * @param endY end point y value
  4912. * @param numberOfSegments (default: 36)
  4913. * @returns the updated Path2.
  4914. */
  4915. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4916. /**
  4917. * Closes the Path2.
  4918. * @returns the Path2.
  4919. */
  4920. close(): Path2;
  4921. /**
  4922. * Gets the sum of the distance between each sequential point in the path
  4923. * @returns the Path2 total length (float).
  4924. */
  4925. length(): number;
  4926. /**
  4927. * Gets the points which construct the path
  4928. * @returns the Path2 internal array of points.
  4929. */
  4930. getPoints(): Vector2[];
  4931. /**
  4932. * Retreives the point at the distance aways from the starting point
  4933. * @param normalizedLengthPosition the length along the path to retreive the point from
  4934. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4935. */
  4936. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4937. /**
  4938. * Creates a new path starting from an x and y position
  4939. * @param x starting x value
  4940. * @param y starting y value
  4941. * @returns a new Path2 starting at the coordinates (x, y).
  4942. */
  4943. static StartingAt(x: number, y: number): Path2;
  4944. }
  4945. /**
  4946. * Represents a 3D path made up of multiple 3D points
  4947. */
  4948. export class Path3D {
  4949. /**
  4950. * an array of Vector3, the curve axis of the Path3D
  4951. */
  4952. path: Vector3[];
  4953. private _curve;
  4954. private _distances;
  4955. private _tangents;
  4956. private _normals;
  4957. private _binormals;
  4958. private _raw;
  4959. private _alignTangentsWithPath;
  4960. private readonly _pointAtData;
  4961. /**
  4962. * new Path3D(path, normal, raw)
  4963. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4964. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4965. * @param path an array of Vector3, the curve axis of the Path3D
  4966. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4967. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4968. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4969. */
  4970. constructor(
  4971. /**
  4972. * an array of Vector3, the curve axis of the Path3D
  4973. */
  4974. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4975. /**
  4976. * Returns the Path3D array of successive Vector3 designing its curve.
  4977. * @returns the Path3D array of successive Vector3 designing its curve.
  4978. */
  4979. getCurve(): Vector3[];
  4980. /**
  4981. * Returns the Path3D array of successive Vector3 designing its curve.
  4982. * @returns the Path3D array of successive Vector3 designing its curve.
  4983. */
  4984. getPoints(): Vector3[];
  4985. /**
  4986. * @returns the computed length (float) of the path.
  4987. */
  4988. length(): number;
  4989. /**
  4990. * Returns an array populated with tangent vectors on each Path3D curve point.
  4991. * @returns an array populated with tangent vectors on each Path3D curve point.
  4992. */
  4993. getTangents(): Vector3[];
  4994. /**
  4995. * Returns an array populated with normal vectors on each Path3D curve point.
  4996. * @returns an array populated with normal vectors on each Path3D curve point.
  4997. */
  4998. getNormals(): Vector3[];
  4999. /**
  5000. * Returns an array populated with binormal vectors on each Path3D curve point.
  5001. * @returns an array populated with binormal vectors on each Path3D curve point.
  5002. */
  5003. getBinormals(): Vector3[];
  5004. /**
  5005. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5006. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5007. */
  5008. getDistances(): number[];
  5009. /**
  5010. * Returns an interpolated point along this path
  5011. * @param position the position of the point along this path, from 0.0 to 1.0
  5012. * @returns a new Vector3 as the point
  5013. */
  5014. getPointAt(position: number): Vector3;
  5015. /**
  5016. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5017. * @param position the position of the point along this path, from 0.0 to 1.0
  5018. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5019. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5020. */
  5021. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5022. /**
  5023. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5024. * @param position the position of the point along this path, from 0.0 to 1.0
  5025. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5026. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5027. */
  5028. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5029. /**
  5030. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5031. * @param position the position of the point along this path, from 0.0 to 1.0
  5032. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5033. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5034. */
  5035. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5036. /**
  5037. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5038. * @param position the position of the point along this path, from 0.0 to 1.0
  5039. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5040. */
  5041. getDistanceAt(position: number): number;
  5042. /**
  5043. * Returns the array index of the previous point of an interpolated point along this path
  5044. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5045. * @returns the array index
  5046. */
  5047. getPreviousPointIndexAt(position: number): number;
  5048. /**
  5049. * 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)
  5050. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5051. * @returns the sub position
  5052. */
  5053. getSubPositionAt(position: number): number;
  5054. /**
  5055. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5056. * @param target the vector of which to get the closest position to
  5057. * @returns the position of the closest virtual point on this path to the target vector
  5058. */
  5059. getClosestPositionTo(target: Vector3): number;
  5060. /**
  5061. * Returns a sub path (slice) of this path
  5062. * @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
  5063. * @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
  5064. * @returns a sub path (slice) of this path
  5065. */
  5066. slice(start?: number, end?: number): Path3D;
  5067. /**
  5068. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5069. * @param path path which all values are copied into the curves points
  5070. * @param firstNormal which should be projected onto the curve
  5071. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5072. * @returns the same object updated.
  5073. */
  5074. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5075. private _compute;
  5076. private _getFirstNonNullVector;
  5077. private _getLastNonNullVector;
  5078. private _normalVector;
  5079. /**
  5080. * Updates the point at data for an interpolated point along this curve
  5081. * @param position the position of the point along this curve, from 0.0 to 1.0
  5082. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5083. * @returns the (updated) point at data
  5084. */
  5085. private _updatePointAtData;
  5086. /**
  5087. * Updates the point at data from the specified parameters
  5088. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5089. * @param point the interpolated point
  5090. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5091. */
  5092. private _setPointAtData;
  5093. /**
  5094. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5095. */
  5096. private _updateInterpolationMatrix;
  5097. }
  5098. /**
  5099. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5100. * A Curve3 is designed from a series of successive Vector3.
  5101. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5102. */
  5103. export class Curve3 {
  5104. private _points;
  5105. private _length;
  5106. /**
  5107. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5108. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5109. * @param v1 (Vector3) the control point
  5110. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5111. * @param nbPoints (integer) the wanted number of points in the curve
  5112. * @returns the created Curve3
  5113. */
  5114. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5115. /**
  5116. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5117. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5118. * @param v1 (Vector3) the first control point
  5119. * @param v2 (Vector3) the second control point
  5120. * @param v3 (Vector3) the end point of the Cubic Bezier
  5121. * @param nbPoints (integer) the wanted number of points in the curve
  5122. * @returns the created Curve3
  5123. */
  5124. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5125. /**
  5126. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5127. * @param p1 (Vector3) the origin point of the Hermite Spline
  5128. * @param t1 (Vector3) the tangent vector at the origin point
  5129. * @param p2 (Vector3) the end point of the Hermite Spline
  5130. * @param t2 (Vector3) the tangent vector at the end point
  5131. * @param nbPoints (integer) the wanted number of points in the curve
  5132. * @returns the created Curve3
  5133. */
  5134. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5135. /**
  5136. * Returns a Curve3 object along a CatmullRom Spline curve :
  5137. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5138. * @param nbPoints (integer) the wanted number of points between each curve control points
  5139. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5140. * @returns the created Curve3
  5141. */
  5142. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5143. /**
  5144. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5145. * A Curve3 is designed from a series of successive Vector3.
  5146. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5147. * @param points points which make up the curve
  5148. */
  5149. constructor(points: Vector3[]);
  5150. /**
  5151. * @returns the Curve3 stored array of successive Vector3
  5152. */
  5153. getPoints(): Vector3[];
  5154. /**
  5155. * @returns the computed length (float) of the curve.
  5156. */
  5157. length(): number;
  5158. /**
  5159. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5160. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5161. * curveA and curveB keep unchanged.
  5162. * @param curve the curve to continue from this curve
  5163. * @returns the newly constructed curve
  5164. */
  5165. continue(curve: DeepImmutable<Curve3>): Curve3;
  5166. private _computeLength;
  5167. }
  5168. }
  5169. declare module BABYLON {
  5170. /**
  5171. * This represents the main contract an easing function should follow.
  5172. * Easing functions are used throughout the animation system.
  5173. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5174. */
  5175. export interface IEasingFunction {
  5176. /**
  5177. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5178. * of the easing function.
  5179. * The link below provides some of the most common examples of easing functions.
  5180. * @see https://easings.net/
  5181. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5182. * @returns the corresponding value on the curve defined by the easing function
  5183. */
  5184. ease(gradient: number): number;
  5185. }
  5186. /**
  5187. * Base class used for every default easing function.
  5188. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5189. */
  5190. export class EasingFunction implements IEasingFunction {
  5191. /**
  5192. * Interpolation follows the mathematical formula associated with the easing function.
  5193. */
  5194. static readonly EASINGMODE_EASEIN: number;
  5195. /**
  5196. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5197. */
  5198. static readonly EASINGMODE_EASEOUT: number;
  5199. /**
  5200. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5201. */
  5202. static readonly EASINGMODE_EASEINOUT: number;
  5203. private _easingMode;
  5204. /**
  5205. * Sets the easing mode of the current function.
  5206. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5207. */
  5208. setEasingMode(easingMode: number): void;
  5209. /**
  5210. * Gets the current easing mode.
  5211. * @returns the easing mode
  5212. */
  5213. getEasingMode(): number;
  5214. /**
  5215. * @hidden
  5216. */
  5217. easeInCore(gradient: number): number;
  5218. /**
  5219. * Given an input gradient between 0 and 1, this returns the corresponding value
  5220. * of the easing function.
  5221. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5222. * @returns the corresponding value on the curve defined by the easing function
  5223. */
  5224. ease(gradient: number): number;
  5225. }
  5226. /**
  5227. * Easing function with a circle shape (see link below).
  5228. * @see https://easings.net/#easeInCirc
  5229. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5230. */
  5231. export class CircleEase extends EasingFunction implements IEasingFunction {
  5232. /** @hidden */
  5233. easeInCore(gradient: number): number;
  5234. }
  5235. /**
  5236. * Easing function with a ease back shape (see link below).
  5237. * @see https://easings.net/#easeInBack
  5238. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5239. */
  5240. export class BackEase extends EasingFunction implements IEasingFunction {
  5241. /** Defines the amplitude of the function */
  5242. amplitude: number;
  5243. /**
  5244. * Instantiates a back ease easing
  5245. * @see https://easings.net/#easeInBack
  5246. * @param amplitude Defines the amplitude of the function
  5247. */
  5248. constructor(
  5249. /** Defines the amplitude of the function */
  5250. amplitude?: number);
  5251. /** @hidden */
  5252. easeInCore(gradient: number): number;
  5253. }
  5254. /**
  5255. * Easing function with a bouncing shape (see link below).
  5256. * @see https://easings.net/#easeInBounce
  5257. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5258. */
  5259. export class BounceEase extends EasingFunction implements IEasingFunction {
  5260. /** Defines the number of bounces */
  5261. bounces: number;
  5262. /** Defines the amplitude of the bounce */
  5263. bounciness: number;
  5264. /**
  5265. * Instantiates a bounce easing
  5266. * @see https://easings.net/#easeInBounce
  5267. * @param bounces Defines the number of bounces
  5268. * @param bounciness Defines the amplitude of the bounce
  5269. */
  5270. constructor(
  5271. /** Defines the number of bounces */
  5272. bounces?: number,
  5273. /** Defines the amplitude of the bounce */
  5274. bounciness?: number);
  5275. /** @hidden */
  5276. easeInCore(gradient: number): number;
  5277. }
  5278. /**
  5279. * Easing function with a power of 3 shape (see link below).
  5280. * @see https://easings.net/#easeInCubic
  5281. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5282. */
  5283. export class CubicEase extends EasingFunction implements IEasingFunction {
  5284. /** @hidden */
  5285. easeInCore(gradient: number): number;
  5286. }
  5287. /**
  5288. * Easing function with an elastic shape (see link below).
  5289. * @see https://easings.net/#easeInElastic
  5290. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5291. */
  5292. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5293. /** Defines the number of oscillations*/
  5294. oscillations: number;
  5295. /** Defines the amplitude of the oscillations*/
  5296. springiness: number;
  5297. /**
  5298. * Instantiates an elastic easing function
  5299. * @see https://easings.net/#easeInElastic
  5300. * @param oscillations Defines the number of oscillations
  5301. * @param springiness Defines the amplitude of the oscillations
  5302. */
  5303. constructor(
  5304. /** Defines the number of oscillations*/
  5305. oscillations?: number,
  5306. /** Defines the amplitude of the oscillations*/
  5307. springiness?: number);
  5308. /** @hidden */
  5309. easeInCore(gradient: number): number;
  5310. }
  5311. /**
  5312. * Easing function with an exponential shape (see link below).
  5313. * @see https://easings.net/#easeInExpo
  5314. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5315. */
  5316. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5317. /** Defines the exponent of the function */
  5318. exponent: number;
  5319. /**
  5320. * Instantiates an exponential easing function
  5321. * @see https://easings.net/#easeInExpo
  5322. * @param exponent Defines the exponent of the function
  5323. */
  5324. constructor(
  5325. /** Defines the exponent of the function */
  5326. exponent?: number);
  5327. /** @hidden */
  5328. easeInCore(gradient: number): number;
  5329. }
  5330. /**
  5331. * Easing function with a power shape (see link below).
  5332. * @see https://easings.net/#easeInQuad
  5333. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5334. */
  5335. export class PowerEase extends EasingFunction implements IEasingFunction {
  5336. /** Defines the power of the function */
  5337. power: number;
  5338. /**
  5339. * Instantiates an power base easing function
  5340. * @see https://easings.net/#easeInQuad
  5341. * @param power Defines the power of the function
  5342. */
  5343. constructor(
  5344. /** Defines the power of the function */
  5345. power?: number);
  5346. /** @hidden */
  5347. easeInCore(gradient: number): number;
  5348. }
  5349. /**
  5350. * Easing function with a power of 2 shape (see link below).
  5351. * @see https://easings.net/#easeInQuad
  5352. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5353. */
  5354. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5355. /** @hidden */
  5356. easeInCore(gradient: number): number;
  5357. }
  5358. /**
  5359. * Easing function with a power of 4 shape (see link below).
  5360. * @see https://easings.net/#easeInQuart
  5361. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5362. */
  5363. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5364. /** @hidden */
  5365. easeInCore(gradient: number): number;
  5366. }
  5367. /**
  5368. * Easing function with a power of 5 shape (see link below).
  5369. * @see https://easings.net/#easeInQuint
  5370. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5371. */
  5372. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5373. /** @hidden */
  5374. easeInCore(gradient: number): number;
  5375. }
  5376. /**
  5377. * Easing function with a sin shape (see link below).
  5378. * @see https://easings.net/#easeInSine
  5379. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5380. */
  5381. export class SineEase extends EasingFunction implements IEasingFunction {
  5382. /** @hidden */
  5383. easeInCore(gradient: number): number;
  5384. }
  5385. /**
  5386. * Easing function with a bezier shape (see link below).
  5387. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5388. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5389. */
  5390. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5391. /** Defines the x component of the start tangent in the bezier curve */
  5392. x1: number;
  5393. /** Defines the y component of the start tangent in the bezier curve */
  5394. y1: number;
  5395. /** Defines the x component of the end tangent in the bezier curve */
  5396. x2: number;
  5397. /** Defines the y component of the end tangent in the bezier curve */
  5398. y2: number;
  5399. /**
  5400. * Instantiates a bezier function
  5401. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5402. * @param x1 Defines the x component of the start tangent in the bezier curve
  5403. * @param y1 Defines the y component of the start tangent in the bezier curve
  5404. * @param x2 Defines the x component of the end tangent in the bezier curve
  5405. * @param y2 Defines the y component of the end tangent in the bezier curve
  5406. */
  5407. constructor(
  5408. /** Defines the x component of the start tangent in the bezier curve */
  5409. x1?: number,
  5410. /** Defines the y component of the start tangent in the bezier curve */
  5411. y1?: number,
  5412. /** Defines the x component of the end tangent in the bezier curve */
  5413. x2?: number,
  5414. /** Defines the y component of the end tangent in the bezier curve */
  5415. y2?: number);
  5416. /** @hidden */
  5417. easeInCore(gradient: number): number;
  5418. }
  5419. }
  5420. declare module BABYLON {
  5421. /**
  5422. * Class used to hold a RBG color
  5423. */
  5424. export class Color3 {
  5425. /**
  5426. * Defines the red component (between 0 and 1, default is 0)
  5427. */
  5428. r: number;
  5429. /**
  5430. * Defines the green component (between 0 and 1, default is 0)
  5431. */
  5432. g: number;
  5433. /**
  5434. * Defines the blue component (between 0 and 1, default is 0)
  5435. */
  5436. b: number;
  5437. /**
  5438. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5439. * @param r defines the red component (between 0 and 1, default is 0)
  5440. * @param g defines the green component (between 0 and 1, default is 0)
  5441. * @param b defines the blue component (between 0 and 1, default is 0)
  5442. */
  5443. constructor(
  5444. /**
  5445. * Defines the red component (between 0 and 1, default is 0)
  5446. */
  5447. r?: number,
  5448. /**
  5449. * Defines the green component (between 0 and 1, default is 0)
  5450. */
  5451. g?: number,
  5452. /**
  5453. * Defines the blue component (between 0 and 1, default is 0)
  5454. */
  5455. b?: number);
  5456. /**
  5457. * Creates a string with the Color3 current values
  5458. * @returns the string representation of the Color3 object
  5459. */
  5460. toString(): string;
  5461. /**
  5462. * Returns the string "Color3"
  5463. * @returns "Color3"
  5464. */
  5465. getClassName(): string;
  5466. /**
  5467. * Compute the Color3 hash code
  5468. * @returns an unique number that can be used to hash Color3 objects
  5469. */
  5470. getHashCode(): number;
  5471. /**
  5472. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5473. * @param array defines the array where to store the r,g,b components
  5474. * @param index defines an optional index in the target array to define where to start storing values
  5475. * @returns the current Color3 object
  5476. */
  5477. toArray(array: FloatArray, index?: number): Color3;
  5478. /**
  5479. * Returns a new Color4 object from the current Color3 and the given alpha
  5480. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5481. * @returns a new Color4 object
  5482. */
  5483. toColor4(alpha?: number): Color4;
  5484. /**
  5485. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5486. * @returns the new array
  5487. */
  5488. asArray(): number[];
  5489. /**
  5490. * Returns the luminance value
  5491. * @returns a float value
  5492. */
  5493. toLuminance(): number;
  5494. /**
  5495. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5496. * @param otherColor defines the second operand
  5497. * @returns the new Color3 object
  5498. */
  5499. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5500. /**
  5501. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5502. * @param otherColor defines the second operand
  5503. * @param result defines the Color3 object where to store the result
  5504. * @returns the current Color3
  5505. */
  5506. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5507. /**
  5508. * Determines equality between Color3 objects
  5509. * @param otherColor defines the second operand
  5510. * @returns true if the rgb values are equal to the given ones
  5511. */
  5512. equals(otherColor: DeepImmutable<Color3>): boolean;
  5513. /**
  5514. * Determines equality between the current Color3 object and a set of r,b,g values
  5515. * @param r defines the red component to check
  5516. * @param g defines the green component to check
  5517. * @param b defines the blue component to check
  5518. * @returns true if the rgb values are equal to the given ones
  5519. */
  5520. equalsFloats(r: number, g: number, b: number): boolean;
  5521. /**
  5522. * Multiplies in place each rgb value by scale
  5523. * @param scale defines the scaling factor
  5524. * @returns the updated Color3
  5525. */
  5526. scale(scale: number): Color3;
  5527. /**
  5528. * Multiplies the rgb values by scale and stores the result into "result"
  5529. * @param scale defines the scaling factor
  5530. * @param result defines the Color3 object where to store the result
  5531. * @returns the unmodified current Color3
  5532. */
  5533. scaleToRef(scale: number, result: Color3): Color3;
  5534. /**
  5535. * Scale the current Color3 values by a factor and add the result to a given Color3
  5536. * @param scale defines the scale factor
  5537. * @param result defines color to store the result into
  5538. * @returns the unmodified current Color3
  5539. */
  5540. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5541. /**
  5542. * Clamps the rgb values by the min and max values and stores the result into "result"
  5543. * @param min defines minimum clamping value (default is 0)
  5544. * @param max defines maximum clamping value (default is 1)
  5545. * @param result defines color to store the result into
  5546. * @returns the original Color3
  5547. */
  5548. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5549. /**
  5550. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5551. * @param otherColor defines the second operand
  5552. * @returns the new Color3
  5553. */
  5554. add(otherColor: DeepImmutable<Color3>): Color3;
  5555. /**
  5556. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5557. * @param otherColor defines the second operand
  5558. * @param result defines Color3 object to store the result into
  5559. * @returns the unmodified current Color3
  5560. */
  5561. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5562. /**
  5563. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5564. * @param otherColor defines the second operand
  5565. * @returns the new Color3
  5566. */
  5567. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5568. /**
  5569. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5570. * @param otherColor defines the second operand
  5571. * @param result defines Color3 object to store the result into
  5572. * @returns the unmodified current Color3
  5573. */
  5574. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5575. /**
  5576. * Copy the current object
  5577. * @returns a new Color3 copied the current one
  5578. */
  5579. clone(): Color3;
  5580. /**
  5581. * Copies the rgb values from the source in the current Color3
  5582. * @param source defines the source Color3 object
  5583. * @returns the updated Color3 object
  5584. */
  5585. copyFrom(source: DeepImmutable<Color3>): Color3;
  5586. /**
  5587. * Updates the Color3 rgb values from the given floats
  5588. * @param r defines the red component to read from
  5589. * @param g defines the green component to read from
  5590. * @param b defines the blue component to read from
  5591. * @returns the current Color3 object
  5592. */
  5593. copyFromFloats(r: number, g: number, b: number): Color3;
  5594. /**
  5595. * Updates the Color3 rgb values from the given floats
  5596. * @param r defines the red component to read from
  5597. * @param g defines the green component to read from
  5598. * @param b defines the blue component to read from
  5599. * @returns the current Color3 object
  5600. */
  5601. set(r: number, g: number, b: number): Color3;
  5602. /**
  5603. * Compute the Color3 hexadecimal code as a string
  5604. * @returns a string containing the hexadecimal representation of the Color3 object
  5605. */
  5606. toHexString(): string;
  5607. /**
  5608. * Computes a new Color3 converted from the current one to linear space
  5609. * @returns a new Color3 object
  5610. */
  5611. toLinearSpace(): Color3;
  5612. /**
  5613. * Converts current color in rgb space to HSV values
  5614. * @returns a new color3 representing the HSV values
  5615. */
  5616. toHSV(): Color3;
  5617. /**
  5618. * Converts current color in rgb space to HSV values
  5619. * @param result defines the Color3 where to store the HSV values
  5620. */
  5621. toHSVToRef(result: Color3): void;
  5622. /**
  5623. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5624. * @param convertedColor defines the Color3 object where to store the linear space version
  5625. * @returns the unmodified Color3
  5626. */
  5627. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5628. /**
  5629. * Computes a new Color3 converted from the current one to gamma space
  5630. * @returns a new Color3 object
  5631. */
  5632. toGammaSpace(): Color3;
  5633. /**
  5634. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5635. * @param convertedColor defines the Color3 object where to store the gamma space version
  5636. * @returns the unmodified Color3
  5637. */
  5638. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5639. private static _BlackReadOnly;
  5640. /**
  5641. * Convert Hue, saturation and value to a Color3 (RGB)
  5642. * @param hue defines the hue
  5643. * @param saturation defines the saturation
  5644. * @param value defines the value
  5645. * @param result defines the Color3 where to store the RGB values
  5646. */
  5647. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5648. /**
  5649. * Creates a new Color3 from the string containing valid hexadecimal values
  5650. * @param hex defines a string containing valid hexadecimal values
  5651. * @returns a new Color3 object
  5652. */
  5653. static FromHexString(hex: string): Color3;
  5654. /**
  5655. * Creates a new Color3 from the starting index of the given array
  5656. * @param array defines the source array
  5657. * @param offset defines an offset in the source array
  5658. * @returns a new Color3 object
  5659. */
  5660. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5661. /**
  5662. * Creates a new Color3 from integer values (< 256)
  5663. * @param r defines the red component to read from (value between 0 and 255)
  5664. * @param g defines the green component to read from (value between 0 and 255)
  5665. * @param b defines the blue component to read from (value between 0 and 255)
  5666. * @returns a new Color3 object
  5667. */
  5668. static FromInts(r: number, g: number, b: number): Color3;
  5669. /**
  5670. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5671. * @param start defines the start Color3 value
  5672. * @param end defines the end Color3 value
  5673. * @param amount defines the gradient value between start and end
  5674. * @returns a new Color3 object
  5675. */
  5676. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5677. /**
  5678. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5679. * @param left defines the start value
  5680. * @param right defines the end value
  5681. * @param amount defines the gradient factor
  5682. * @param result defines the Color3 object where to store the result
  5683. */
  5684. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5685. /**
  5686. * Returns a Color3 value containing a red color
  5687. * @returns a new Color3 object
  5688. */
  5689. static Red(): Color3;
  5690. /**
  5691. * Returns a Color3 value containing a green color
  5692. * @returns a new Color3 object
  5693. */
  5694. static Green(): Color3;
  5695. /**
  5696. * Returns a Color3 value containing a blue color
  5697. * @returns a new Color3 object
  5698. */
  5699. static Blue(): Color3;
  5700. /**
  5701. * Returns a Color3 value containing a black color
  5702. * @returns a new Color3 object
  5703. */
  5704. static Black(): Color3;
  5705. /**
  5706. * Gets a Color3 value containing a black color that must not be updated
  5707. */
  5708. static get BlackReadOnly(): DeepImmutable<Color3>;
  5709. /**
  5710. * Returns a Color3 value containing a white color
  5711. * @returns a new Color3 object
  5712. */
  5713. static White(): Color3;
  5714. /**
  5715. * Returns a Color3 value containing a purple color
  5716. * @returns a new Color3 object
  5717. */
  5718. static Purple(): Color3;
  5719. /**
  5720. * Returns a Color3 value containing a magenta color
  5721. * @returns a new Color3 object
  5722. */
  5723. static Magenta(): Color3;
  5724. /**
  5725. * Returns a Color3 value containing a yellow color
  5726. * @returns a new Color3 object
  5727. */
  5728. static Yellow(): Color3;
  5729. /**
  5730. * Returns a Color3 value containing a gray color
  5731. * @returns a new Color3 object
  5732. */
  5733. static Gray(): Color3;
  5734. /**
  5735. * Returns a Color3 value containing a teal color
  5736. * @returns a new Color3 object
  5737. */
  5738. static Teal(): Color3;
  5739. /**
  5740. * Returns a Color3 value containing a random color
  5741. * @returns a new Color3 object
  5742. */
  5743. static Random(): Color3;
  5744. }
  5745. /**
  5746. * Class used to hold a RBGA color
  5747. */
  5748. export class Color4 {
  5749. /**
  5750. * Defines the red component (between 0 and 1, default is 0)
  5751. */
  5752. r: number;
  5753. /**
  5754. * Defines the green component (between 0 and 1, default is 0)
  5755. */
  5756. g: number;
  5757. /**
  5758. * Defines the blue component (between 0 and 1, default is 0)
  5759. */
  5760. b: number;
  5761. /**
  5762. * Defines the alpha component (between 0 and 1, default is 1)
  5763. */
  5764. a: number;
  5765. /**
  5766. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5767. * @param r defines the red component (between 0 and 1, default is 0)
  5768. * @param g defines the green component (between 0 and 1, default is 0)
  5769. * @param b defines the blue component (between 0 and 1, default is 0)
  5770. * @param a defines the alpha component (between 0 and 1, default is 1)
  5771. */
  5772. constructor(
  5773. /**
  5774. * Defines the red component (between 0 and 1, default is 0)
  5775. */
  5776. r?: number,
  5777. /**
  5778. * Defines the green component (between 0 and 1, default is 0)
  5779. */
  5780. g?: number,
  5781. /**
  5782. * Defines the blue component (between 0 and 1, default is 0)
  5783. */
  5784. b?: number,
  5785. /**
  5786. * Defines the alpha component (between 0 and 1, default is 1)
  5787. */
  5788. a?: number);
  5789. /**
  5790. * Adds in place the given Color4 values to the current Color4 object
  5791. * @param right defines the second operand
  5792. * @returns the current updated Color4 object
  5793. */
  5794. addInPlace(right: DeepImmutable<Color4>): Color4;
  5795. /**
  5796. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5797. * @returns the new array
  5798. */
  5799. asArray(): number[];
  5800. /**
  5801. * Stores from the starting index in the given array the Color4 successive values
  5802. * @param array defines the array where to store the r,g,b components
  5803. * @param index defines an optional index in the target array to define where to start storing values
  5804. * @returns the current Color4 object
  5805. */
  5806. toArray(array: number[], index?: number): Color4;
  5807. /**
  5808. * Determines equality between Color4 objects
  5809. * @param otherColor defines the second operand
  5810. * @returns true if the rgba values are equal to the given ones
  5811. */
  5812. equals(otherColor: DeepImmutable<Color4>): boolean;
  5813. /**
  5814. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5815. * @param right defines the second operand
  5816. * @returns a new Color4 object
  5817. */
  5818. add(right: DeepImmutable<Color4>): Color4;
  5819. /**
  5820. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5821. * @param right defines the second operand
  5822. * @returns a new Color4 object
  5823. */
  5824. subtract(right: DeepImmutable<Color4>): Color4;
  5825. /**
  5826. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5827. * @param right defines the second operand
  5828. * @param result defines the Color4 object where to store the result
  5829. * @returns the current Color4 object
  5830. */
  5831. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5832. /**
  5833. * Creates a new Color4 with the current Color4 values multiplied by scale
  5834. * @param scale defines the scaling factor to apply
  5835. * @returns a new Color4 object
  5836. */
  5837. scale(scale: number): Color4;
  5838. /**
  5839. * Multiplies the current Color4 values by scale and stores the result in "result"
  5840. * @param scale defines the scaling factor to apply
  5841. * @param result defines the Color4 object where to store the result
  5842. * @returns the current unmodified Color4
  5843. */
  5844. scaleToRef(scale: number, result: Color4): Color4;
  5845. /**
  5846. * Scale the current Color4 values by a factor and add the result to a given Color4
  5847. * @param scale defines the scale factor
  5848. * @param result defines the Color4 object where to store the result
  5849. * @returns the unmodified current Color4
  5850. */
  5851. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5852. /**
  5853. * Clamps the rgb values by the min and max values and stores the result into "result"
  5854. * @param min defines minimum clamping value (default is 0)
  5855. * @param max defines maximum clamping value (default is 1)
  5856. * @param result defines color to store the result into.
  5857. * @returns the cuurent Color4
  5858. */
  5859. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5860. /**
  5861. * Multipy an Color4 value by another and return a new Color4 object
  5862. * @param color defines the Color4 value to multiply by
  5863. * @returns a new Color4 object
  5864. */
  5865. multiply(color: Color4): Color4;
  5866. /**
  5867. * Multipy a Color4 value by another and push the result in a reference value
  5868. * @param color defines the Color4 value to multiply by
  5869. * @param result defines the Color4 to fill the result in
  5870. * @returns the result Color4
  5871. */
  5872. multiplyToRef(color: Color4, result: Color4): Color4;
  5873. /**
  5874. * Creates a string with the Color4 current values
  5875. * @returns the string representation of the Color4 object
  5876. */
  5877. toString(): string;
  5878. /**
  5879. * Returns the string "Color4"
  5880. * @returns "Color4"
  5881. */
  5882. getClassName(): string;
  5883. /**
  5884. * Compute the Color4 hash code
  5885. * @returns an unique number that can be used to hash Color4 objects
  5886. */
  5887. getHashCode(): number;
  5888. /**
  5889. * Creates a new Color4 copied from the current one
  5890. * @returns a new Color4 object
  5891. */
  5892. clone(): Color4;
  5893. /**
  5894. * Copies the given Color4 values into the current one
  5895. * @param source defines the source Color4 object
  5896. * @returns the current updated Color4 object
  5897. */
  5898. copyFrom(source: Color4): Color4;
  5899. /**
  5900. * Copies the given float values into the current one
  5901. * @param r defines the red component to read from
  5902. * @param g defines the green component to read from
  5903. * @param b defines the blue component to read from
  5904. * @param a defines the alpha component to read from
  5905. * @returns the current updated Color4 object
  5906. */
  5907. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5908. /**
  5909. * Copies the given float values into the current one
  5910. * @param r defines the red component to read from
  5911. * @param g defines the green component to read from
  5912. * @param b defines the blue component to read from
  5913. * @param a defines the alpha component to read from
  5914. * @returns the current updated Color4 object
  5915. */
  5916. set(r: number, g: number, b: number, a: number): Color4;
  5917. /**
  5918. * Compute the Color4 hexadecimal code as a string
  5919. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5920. * @returns a string containing the hexadecimal representation of the Color4 object
  5921. */
  5922. toHexString(returnAsColor3?: boolean): string;
  5923. /**
  5924. * Computes a new Color4 converted from the current one to linear space
  5925. * @returns a new Color4 object
  5926. */
  5927. toLinearSpace(): Color4;
  5928. /**
  5929. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5930. * @param convertedColor defines the Color4 object where to store the linear space version
  5931. * @returns the unmodified Color4
  5932. */
  5933. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5934. /**
  5935. * Computes a new Color4 converted from the current one to gamma space
  5936. * @returns a new Color4 object
  5937. */
  5938. toGammaSpace(): Color4;
  5939. /**
  5940. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5941. * @param convertedColor defines the Color4 object where to store the gamma space version
  5942. * @returns the unmodified Color4
  5943. */
  5944. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5945. /**
  5946. * Creates a new Color4 from the string containing valid hexadecimal values
  5947. * @param hex defines a string containing valid hexadecimal values
  5948. * @returns a new Color4 object
  5949. */
  5950. static FromHexString(hex: string): Color4;
  5951. /**
  5952. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5953. * @param left defines the start value
  5954. * @param right defines the end value
  5955. * @param amount defines the gradient factor
  5956. * @returns a new Color4 object
  5957. */
  5958. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5959. /**
  5960. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5961. * @param left defines the start value
  5962. * @param right defines the end value
  5963. * @param amount defines the gradient factor
  5964. * @param result defines the Color4 object where to store data
  5965. */
  5966. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5967. /**
  5968. * Creates a new Color4 from a Color3 and an alpha value
  5969. * @param color3 defines the source Color3 to read from
  5970. * @param alpha defines the alpha component (1.0 by default)
  5971. * @returns a new Color4 object
  5972. */
  5973. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5974. /**
  5975. * Creates a new Color4 from the starting index element of the given array
  5976. * @param array defines the source array to read from
  5977. * @param offset defines the offset in the source array
  5978. * @returns a new Color4 object
  5979. */
  5980. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5981. /**
  5982. * Creates a new Color3 from integer values (< 256)
  5983. * @param r defines the red component to read from (value between 0 and 255)
  5984. * @param g defines the green component to read from (value between 0 and 255)
  5985. * @param b defines the blue component to read from (value between 0 and 255)
  5986. * @param a defines the alpha component to read from (value between 0 and 255)
  5987. * @returns a new Color3 object
  5988. */
  5989. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5990. /**
  5991. * Check the content of a given array and convert it to an array containing RGBA data
  5992. * If the original array was already containing count * 4 values then it is returned directly
  5993. * @param colors defines the array to check
  5994. * @param count defines the number of RGBA data to expect
  5995. * @returns an array containing count * 4 values (RGBA)
  5996. */
  5997. static CheckColors4(colors: number[], count: number): number[];
  5998. }
  5999. /**
  6000. * @hidden
  6001. */
  6002. export class TmpColors {
  6003. static Color3: Color3[];
  6004. static Color4: Color4[];
  6005. }
  6006. }
  6007. declare module BABYLON {
  6008. /**
  6009. * Defines an interface which represents an animation key frame
  6010. */
  6011. export interface IAnimationKey {
  6012. /**
  6013. * Frame of the key frame
  6014. */
  6015. frame: number;
  6016. /**
  6017. * Value at the specifies key frame
  6018. */
  6019. value: any;
  6020. /**
  6021. * The input tangent for the cubic hermite spline
  6022. */
  6023. inTangent?: any;
  6024. /**
  6025. * The output tangent for the cubic hermite spline
  6026. */
  6027. outTangent?: any;
  6028. /**
  6029. * The animation interpolation type
  6030. */
  6031. interpolation?: AnimationKeyInterpolation;
  6032. }
  6033. /**
  6034. * Enum for the animation key frame interpolation type
  6035. */
  6036. export enum AnimationKeyInterpolation {
  6037. /**
  6038. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6039. */
  6040. STEP = 1
  6041. }
  6042. }
  6043. declare module BABYLON {
  6044. /**
  6045. * Represents the range of an animation
  6046. */
  6047. export class AnimationRange {
  6048. /**The name of the animation range**/
  6049. name: string;
  6050. /**The starting frame of the animation */
  6051. from: number;
  6052. /**The ending frame of the animation*/
  6053. to: number;
  6054. /**
  6055. * Initializes the range of an animation
  6056. * @param name The name of the animation range
  6057. * @param from The starting frame of the animation
  6058. * @param to The ending frame of the animation
  6059. */
  6060. constructor(
  6061. /**The name of the animation range**/
  6062. name: string,
  6063. /**The starting frame of the animation */
  6064. from: number,
  6065. /**The ending frame of the animation*/
  6066. to: number);
  6067. /**
  6068. * Makes a copy of the animation range
  6069. * @returns A copy of the animation range
  6070. */
  6071. clone(): AnimationRange;
  6072. }
  6073. }
  6074. declare module BABYLON {
  6075. /**
  6076. * Composed of a frame, and an action function
  6077. */
  6078. export class AnimationEvent {
  6079. /** The frame for which the event is triggered **/
  6080. frame: number;
  6081. /** The event to perform when triggered **/
  6082. action: (currentFrame: number) => void;
  6083. /** Specifies if the event should be triggered only once**/
  6084. onlyOnce?: boolean | undefined;
  6085. /**
  6086. * Specifies if the animation event is done
  6087. */
  6088. isDone: boolean;
  6089. /**
  6090. * Initializes the animation event
  6091. * @param frame The frame for which the event is triggered
  6092. * @param action The event to perform when triggered
  6093. * @param onlyOnce Specifies if the event should be triggered only once
  6094. */
  6095. constructor(
  6096. /** The frame for which the event is triggered **/
  6097. frame: number,
  6098. /** The event to perform when triggered **/
  6099. action: (currentFrame: number) => void,
  6100. /** Specifies if the event should be triggered only once**/
  6101. onlyOnce?: boolean | undefined);
  6102. /** @hidden */
  6103. _clone(): AnimationEvent;
  6104. }
  6105. }
  6106. declare module BABYLON {
  6107. /**
  6108. * Interface used to define a behavior
  6109. */
  6110. export interface Behavior<T> {
  6111. /** gets or sets behavior's name */
  6112. name: string;
  6113. /**
  6114. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6115. */
  6116. init(): void;
  6117. /**
  6118. * Called when the behavior is attached to a target
  6119. * @param target defines the target where the behavior is attached to
  6120. */
  6121. attach(target: T): void;
  6122. /**
  6123. * Called when the behavior is detached from its target
  6124. */
  6125. detach(): void;
  6126. }
  6127. /**
  6128. * Interface implemented by classes supporting behaviors
  6129. */
  6130. export interface IBehaviorAware<T> {
  6131. /**
  6132. * Attach a behavior
  6133. * @param behavior defines the behavior to attach
  6134. * @returns the current host
  6135. */
  6136. addBehavior(behavior: Behavior<T>): T;
  6137. /**
  6138. * Remove a behavior from the current object
  6139. * @param behavior defines the behavior to detach
  6140. * @returns the current host
  6141. */
  6142. removeBehavior(behavior: Behavior<T>): T;
  6143. /**
  6144. * Gets a behavior using its name to search
  6145. * @param name defines the name to search
  6146. * @returns the behavior or null if not found
  6147. */
  6148. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6149. }
  6150. }
  6151. declare module BABYLON {
  6152. /**
  6153. * Defines an array and its length.
  6154. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6155. */
  6156. export interface ISmartArrayLike<T> {
  6157. /**
  6158. * The data of the array.
  6159. */
  6160. data: Array<T>;
  6161. /**
  6162. * The active length of the array.
  6163. */
  6164. length: number;
  6165. }
  6166. /**
  6167. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6168. */
  6169. export class SmartArray<T> implements ISmartArrayLike<T> {
  6170. /**
  6171. * The full set of data from the array.
  6172. */
  6173. data: Array<T>;
  6174. /**
  6175. * The active length of the array.
  6176. */
  6177. length: number;
  6178. protected _id: number;
  6179. /**
  6180. * Instantiates a Smart Array.
  6181. * @param capacity defines the default capacity of the array.
  6182. */
  6183. constructor(capacity: number);
  6184. /**
  6185. * Pushes a value at the end of the active data.
  6186. * @param value defines the object to push in the array.
  6187. */
  6188. push(value: T): void;
  6189. /**
  6190. * Iterates over the active data and apply the lambda to them.
  6191. * @param func defines the action to apply on each value.
  6192. */
  6193. forEach(func: (content: T) => void): void;
  6194. /**
  6195. * Sorts the full sets of data.
  6196. * @param compareFn defines the comparison function to apply.
  6197. */
  6198. sort(compareFn: (a: T, b: T) => number): void;
  6199. /**
  6200. * Resets the active data to an empty array.
  6201. */
  6202. reset(): void;
  6203. /**
  6204. * Releases all the data from the array as well as the array.
  6205. */
  6206. dispose(): void;
  6207. /**
  6208. * Concats the active data with a given array.
  6209. * @param array defines the data to concatenate with.
  6210. */
  6211. concat(array: any): void;
  6212. /**
  6213. * Returns the position of a value in the active data.
  6214. * @param value defines the value to find the index for
  6215. * @returns the index if found in the active data otherwise -1
  6216. */
  6217. indexOf(value: T): number;
  6218. /**
  6219. * Returns whether an element is part of the active data.
  6220. * @param value defines the value to look for
  6221. * @returns true if found in the active data otherwise false
  6222. */
  6223. contains(value: T): boolean;
  6224. private static _GlobalId;
  6225. }
  6226. /**
  6227. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6228. * The data in this array can only be present once
  6229. */
  6230. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6231. private _duplicateId;
  6232. /**
  6233. * Pushes a value at the end of the active data.
  6234. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6235. * @param value defines the object to push in the array.
  6236. */
  6237. push(value: T): void;
  6238. /**
  6239. * Pushes a value at the end of the active data.
  6240. * If the data is already present, it won t be added again
  6241. * @param value defines the object to push in the array.
  6242. * @returns true if added false if it was already present
  6243. */
  6244. pushNoDuplicate(value: T): boolean;
  6245. /**
  6246. * Resets the active data to an empty array.
  6247. */
  6248. reset(): void;
  6249. /**
  6250. * Concats the active data with a given array.
  6251. * This ensures no dupplicate will be present in the result.
  6252. * @param array defines the data to concatenate with.
  6253. */
  6254. concatWithNoDuplicate(array: any): void;
  6255. }
  6256. }
  6257. declare module BABYLON {
  6258. /**
  6259. * @ignore
  6260. * This is a list of all the different input types that are available in the application.
  6261. * Fo instance: ArcRotateCameraGamepadInput...
  6262. */
  6263. export var CameraInputTypes: {};
  6264. /**
  6265. * This is the contract to implement in order to create a new input class.
  6266. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6267. */
  6268. export interface ICameraInput<TCamera extends Camera> {
  6269. /**
  6270. * Defines the camera the input is attached to.
  6271. */
  6272. camera: Nullable<TCamera>;
  6273. /**
  6274. * Gets the class name of the current intput.
  6275. * @returns the class name
  6276. */
  6277. getClassName(): string;
  6278. /**
  6279. * Get the friendly name associated with the input class.
  6280. * @returns the input friendly name
  6281. */
  6282. getSimpleName(): string;
  6283. /**
  6284. * Attach the input controls to a specific dom element to get the input from.
  6285. * @param element Defines the element the controls should be listened from
  6286. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6287. */
  6288. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6289. /**
  6290. * Detach the current controls from the specified dom element.
  6291. * @param element Defines the element to stop listening the inputs from
  6292. */
  6293. detachControl(element: Nullable<HTMLElement>): void;
  6294. /**
  6295. * Update the current camera state depending on the inputs that have been used this frame.
  6296. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6297. */
  6298. checkInputs?: () => void;
  6299. }
  6300. /**
  6301. * Represents a map of input types to input instance or input index to input instance.
  6302. */
  6303. export interface CameraInputsMap<TCamera extends Camera> {
  6304. /**
  6305. * Accessor to the input by input type.
  6306. */
  6307. [name: string]: ICameraInput<TCamera>;
  6308. /**
  6309. * Accessor to the input by input index.
  6310. */
  6311. [idx: number]: ICameraInput<TCamera>;
  6312. }
  6313. /**
  6314. * This represents the input manager used within a camera.
  6315. * It helps dealing with all the different kind of input attached to a camera.
  6316. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6317. */
  6318. export class CameraInputsManager<TCamera extends Camera> {
  6319. /**
  6320. * Defines the list of inputs attahed to the camera.
  6321. */
  6322. attached: CameraInputsMap<TCamera>;
  6323. /**
  6324. * Defines the dom element the camera is collecting inputs from.
  6325. * This is null if the controls have not been attached.
  6326. */
  6327. attachedElement: Nullable<HTMLElement>;
  6328. /**
  6329. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6330. */
  6331. noPreventDefault: boolean;
  6332. /**
  6333. * Defined the camera the input manager belongs to.
  6334. */
  6335. camera: TCamera;
  6336. /**
  6337. * Update the current camera state depending on the inputs that have been used this frame.
  6338. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6339. */
  6340. checkInputs: () => void;
  6341. /**
  6342. * Instantiate a new Camera Input Manager.
  6343. * @param camera Defines the camera the input manager blongs to
  6344. */
  6345. constructor(camera: TCamera);
  6346. /**
  6347. * Add an input method to a camera
  6348. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6349. * @param input camera input method
  6350. */
  6351. add(input: ICameraInput<TCamera>): void;
  6352. /**
  6353. * Remove a specific input method from a camera
  6354. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6355. * @param inputToRemove camera input method
  6356. */
  6357. remove(inputToRemove: ICameraInput<TCamera>): void;
  6358. /**
  6359. * Remove a specific input type from a camera
  6360. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6361. * @param inputType the type of the input to remove
  6362. */
  6363. removeByType(inputType: string): void;
  6364. private _addCheckInputs;
  6365. /**
  6366. * Attach the input controls to the currently attached dom element to listen the events from.
  6367. * @param input Defines the input to attach
  6368. */
  6369. attachInput(input: ICameraInput<TCamera>): void;
  6370. /**
  6371. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6372. * @param element Defines the dom element to collect the events from
  6373. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6374. */
  6375. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6376. /**
  6377. * Detach the current manager inputs controls from a specific dom element.
  6378. * @param element Defines the dom element to collect the events from
  6379. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6380. */
  6381. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6382. /**
  6383. * Rebuild the dynamic inputCheck function from the current list of
  6384. * defined inputs in the manager.
  6385. */
  6386. rebuildInputCheck(): void;
  6387. /**
  6388. * Remove all attached input methods from a camera
  6389. */
  6390. clear(): void;
  6391. /**
  6392. * Serialize the current input manager attached to a camera.
  6393. * This ensures than once parsed,
  6394. * the input associated to the camera will be identical to the current ones
  6395. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6396. */
  6397. serialize(serializedCamera: any): void;
  6398. /**
  6399. * Parses an input manager serialized JSON to restore the previous list of inputs
  6400. * and states associated to a camera.
  6401. * @param parsedCamera Defines the JSON to parse
  6402. */
  6403. parse(parsedCamera: any): void;
  6404. }
  6405. }
  6406. declare module BABYLON {
  6407. /**
  6408. * Class used to store data that will be store in GPU memory
  6409. */
  6410. export class Buffer {
  6411. private _engine;
  6412. private _buffer;
  6413. /** @hidden */
  6414. _data: Nullable<DataArray>;
  6415. private _updatable;
  6416. private _instanced;
  6417. private _divisor;
  6418. /**
  6419. * Gets the byte stride.
  6420. */
  6421. readonly byteStride: number;
  6422. /**
  6423. * Constructor
  6424. * @param engine the engine
  6425. * @param data the data to use for this buffer
  6426. * @param updatable whether the data is updatable
  6427. * @param stride the stride (optional)
  6428. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6429. * @param instanced whether the buffer is instanced (optional)
  6430. * @param useBytes set to true if the stride in in bytes (optional)
  6431. * @param divisor sets an optional divisor for instances (1 by default)
  6432. */
  6433. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6434. /**
  6435. * Create a new VertexBuffer based on the current buffer
  6436. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6437. * @param offset defines offset in the buffer (0 by default)
  6438. * @param size defines the size in floats of attributes (position is 3 for instance)
  6439. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6440. * @param instanced defines if the vertex buffer contains indexed data
  6441. * @param useBytes defines if the offset and stride are in bytes *
  6442. * @param divisor sets an optional divisor for instances (1 by default)
  6443. * @returns the new vertex buffer
  6444. */
  6445. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6446. /**
  6447. * Gets a boolean indicating if the Buffer is updatable?
  6448. * @returns true if the buffer is updatable
  6449. */
  6450. isUpdatable(): boolean;
  6451. /**
  6452. * Gets current buffer's data
  6453. * @returns a DataArray or null
  6454. */
  6455. getData(): Nullable<DataArray>;
  6456. /**
  6457. * Gets underlying native buffer
  6458. * @returns underlying native buffer
  6459. */
  6460. getBuffer(): Nullable<DataBuffer>;
  6461. /**
  6462. * Gets the stride in float32 units (i.e. byte stride / 4).
  6463. * May not be an integer if the byte stride is not divisible by 4.
  6464. * @returns the stride in float32 units
  6465. * @deprecated Please use byteStride instead.
  6466. */
  6467. getStrideSize(): number;
  6468. /**
  6469. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6470. * @param data defines the data to store
  6471. */
  6472. create(data?: Nullable<DataArray>): void;
  6473. /** @hidden */
  6474. _rebuild(): void;
  6475. /**
  6476. * Update current buffer data
  6477. * @param data defines the data to store
  6478. */
  6479. update(data: DataArray): void;
  6480. /**
  6481. * Updates the data directly.
  6482. * @param data the new data
  6483. * @param offset the new offset
  6484. * @param vertexCount the vertex count (optional)
  6485. * @param useBytes set to true if the offset is in bytes
  6486. */
  6487. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6488. /**
  6489. * Release all resources
  6490. */
  6491. dispose(): void;
  6492. }
  6493. /**
  6494. * Specialized buffer used to store vertex data
  6495. */
  6496. export class VertexBuffer {
  6497. /** @hidden */
  6498. _buffer: Buffer;
  6499. private _kind;
  6500. private _size;
  6501. private _ownsBuffer;
  6502. private _instanced;
  6503. private _instanceDivisor;
  6504. /**
  6505. * The byte type.
  6506. */
  6507. static readonly BYTE: number;
  6508. /**
  6509. * The unsigned byte type.
  6510. */
  6511. static readonly UNSIGNED_BYTE: number;
  6512. /**
  6513. * The short type.
  6514. */
  6515. static readonly SHORT: number;
  6516. /**
  6517. * The unsigned short type.
  6518. */
  6519. static readonly UNSIGNED_SHORT: number;
  6520. /**
  6521. * The integer type.
  6522. */
  6523. static readonly INT: number;
  6524. /**
  6525. * The unsigned integer type.
  6526. */
  6527. static readonly UNSIGNED_INT: number;
  6528. /**
  6529. * The float type.
  6530. */
  6531. static readonly FLOAT: number;
  6532. /**
  6533. * Gets or sets the instance divisor when in instanced mode
  6534. */
  6535. get instanceDivisor(): number;
  6536. set instanceDivisor(value: number);
  6537. /**
  6538. * Gets the byte stride.
  6539. */
  6540. readonly byteStride: number;
  6541. /**
  6542. * Gets the byte offset.
  6543. */
  6544. readonly byteOffset: number;
  6545. /**
  6546. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6547. */
  6548. readonly normalized: boolean;
  6549. /**
  6550. * Gets the data type of each component in the array.
  6551. */
  6552. readonly type: number;
  6553. /**
  6554. * Constructor
  6555. * @param engine the engine
  6556. * @param data the data to use for this vertex buffer
  6557. * @param kind the vertex buffer kind
  6558. * @param updatable whether the data is updatable
  6559. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6560. * @param stride the stride (optional)
  6561. * @param instanced whether the buffer is instanced (optional)
  6562. * @param offset the offset of the data (optional)
  6563. * @param size the number of components (optional)
  6564. * @param type the type of the component (optional)
  6565. * @param normalized whether the data contains normalized data (optional)
  6566. * @param useBytes set to true if stride and offset are in bytes (optional)
  6567. * @param divisor defines the instance divisor to use (1 by default)
  6568. */
  6569. 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);
  6570. /** @hidden */
  6571. _rebuild(): void;
  6572. /**
  6573. * Returns the kind of the VertexBuffer (string)
  6574. * @returns a string
  6575. */
  6576. getKind(): string;
  6577. /**
  6578. * Gets a boolean indicating if the VertexBuffer is updatable?
  6579. * @returns true if the buffer is updatable
  6580. */
  6581. isUpdatable(): boolean;
  6582. /**
  6583. * Gets current buffer's data
  6584. * @returns a DataArray or null
  6585. */
  6586. getData(): Nullable<DataArray>;
  6587. /**
  6588. * Gets underlying native buffer
  6589. * @returns underlying native buffer
  6590. */
  6591. getBuffer(): Nullable<DataBuffer>;
  6592. /**
  6593. * Gets the stride in float32 units (i.e. byte stride / 4).
  6594. * May not be an integer if the byte stride is not divisible by 4.
  6595. * @returns the stride in float32 units
  6596. * @deprecated Please use byteStride instead.
  6597. */
  6598. getStrideSize(): number;
  6599. /**
  6600. * Returns the offset as a multiple of the type byte length.
  6601. * @returns the offset in bytes
  6602. * @deprecated Please use byteOffset instead.
  6603. */
  6604. getOffset(): number;
  6605. /**
  6606. * Returns the number of components per vertex attribute (integer)
  6607. * @returns the size in float
  6608. */
  6609. getSize(): number;
  6610. /**
  6611. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6612. * @returns true if this buffer is instanced
  6613. */
  6614. getIsInstanced(): boolean;
  6615. /**
  6616. * Returns the instancing divisor, zero for non-instanced (integer).
  6617. * @returns a number
  6618. */
  6619. getInstanceDivisor(): number;
  6620. /**
  6621. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6622. * @param data defines the data to store
  6623. */
  6624. create(data?: DataArray): void;
  6625. /**
  6626. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6627. * This function will create a new buffer if the current one is not updatable
  6628. * @param data defines the data to store
  6629. */
  6630. update(data: DataArray): void;
  6631. /**
  6632. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6633. * Returns the directly updated WebGLBuffer.
  6634. * @param data the new data
  6635. * @param offset the new offset
  6636. * @param useBytes set to true if the offset is in bytes
  6637. */
  6638. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6639. /**
  6640. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6641. */
  6642. dispose(): void;
  6643. /**
  6644. * Enumerates each value of this vertex buffer as numbers.
  6645. * @param count the number of values to enumerate
  6646. * @param callback the callback function called for each value
  6647. */
  6648. forEach(count: number, callback: (value: number, index: number) => void): void;
  6649. /**
  6650. * Positions
  6651. */
  6652. static readonly PositionKind: string;
  6653. /**
  6654. * Normals
  6655. */
  6656. static readonly NormalKind: string;
  6657. /**
  6658. * Tangents
  6659. */
  6660. static readonly TangentKind: string;
  6661. /**
  6662. * Texture coordinates
  6663. */
  6664. static readonly UVKind: string;
  6665. /**
  6666. * Texture coordinates 2
  6667. */
  6668. static readonly UV2Kind: string;
  6669. /**
  6670. * Texture coordinates 3
  6671. */
  6672. static readonly UV3Kind: string;
  6673. /**
  6674. * Texture coordinates 4
  6675. */
  6676. static readonly UV4Kind: string;
  6677. /**
  6678. * Texture coordinates 5
  6679. */
  6680. static readonly UV5Kind: string;
  6681. /**
  6682. * Texture coordinates 6
  6683. */
  6684. static readonly UV6Kind: string;
  6685. /**
  6686. * Colors
  6687. */
  6688. static readonly ColorKind: string;
  6689. /**
  6690. * Matrix indices (for bones)
  6691. */
  6692. static readonly MatricesIndicesKind: string;
  6693. /**
  6694. * Matrix weights (for bones)
  6695. */
  6696. static readonly MatricesWeightsKind: string;
  6697. /**
  6698. * Additional matrix indices (for bones)
  6699. */
  6700. static readonly MatricesIndicesExtraKind: string;
  6701. /**
  6702. * Additional matrix weights (for bones)
  6703. */
  6704. static readonly MatricesWeightsExtraKind: string;
  6705. /**
  6706. * Deduces the stride given a kind.
  6707. * @param kind The kind string to deduce
  6708. * @returns The deduced stride
  6709. */
  6710. static DeduceStride(kind: string): number;
  6711. /**
  6712. * Gets the byte length of the given type.
  6713. * @param type the type
  6714. * @returns the number of bytes
  6715. */
  6716. static GetTypeByteLength(type: number): number;
  6717. /**
  6718. * Enumerates each value of the given parameters as numbers.
  6719. * @param data the data to enumerate
  6720. * @param byteOffset the byte offset of the data
  6721. * @param byteStride the byte stride of the data
  6722. * @param componentCount the number of components per element
  6723. * @param componentType the type of the component
  6724. * @param count the number of values to enumerate
  6725. * @param normalized whether the data is normalized
  6726. * @param callback the callback function called for each value
  6727. */
  6728. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6729. private static _GetFloatValue;
  6730. }
  6731. }
  6732. declare module BABYLON {
  6733. /**
  6734. * @hidden
  6735. */
  6736. export class IntersectionInfo {
  6737. bu: Nullable<number>;
  6738. bv: Nullable<number>;
  6739. distance: number;
  6740. faceId: number;
  6741. subMeshId: number;
  6742. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6743. }
  6744. }
  6745. declare module BABYLON {
  6746. /**
  6747. * Class used to store bounding sphere information
  6748. */
  6749. export class BoundingSphere {
  6750. /**
  6751. * Gets the center of the bounding sphere in local space
  6752. */
  6753. readonly center: Vector3;
  6754. /**
  6755. * Radius of the bounding sphere in local space
  6756. */
  6757. radius: number;
  6758. /**
  6759. * Gets the center of the bounding sphere in world space
  6760. */
  6761. readonly centerWorld: Vector3;
  6762. /**
  6763. * Radius of the bounding sphere in world space
  6764. */
  6765. radiusWorld: number;
  6766. /**
  6767. * Gets the minimum vector in local space
  6768. */
  6769. readonly minimum: Vector3;
  6770. /**
  6771. * Gets the maximum vector in local space
  6772. */
  6773. readonly maximum: Vector3;
  6774. private _worldMatrix;
  6775. private static readonly TmpVector3;
  6776. /**
  6777. * Creates a new bounding sphere
  6778. * @param min defines the minimum vector (in local space)
  6779. * @param max defines the maximum vector (in local space)
  6780. * @param worldMatrix defines the new world matrix
  6781. */
  6782. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6783. /**
  6784. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6785. * @param min defines the new minimum vector (in local space)
  6786. * @param max defines the new maximum vector (in local space)
  6787. * @param worldMatrix defines the new world matrix
  6788. */
  6789. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6790. /**
  6791. * Scale the current bounding sphere by applying a scale factor
  6792. * @param factor defines the scale factor to apply
  6793. * @returns the current bounding box
  6794. */
  6795. scale(factor: number): BoundingSphere;
  6796. /**
  6797. * Gets the world matrix of the bounding box
  6798. * @returns a matrix
  6799. */
  6800. getWorldMatrix(): DeepImmutable<Matrix>;
  6801. /** @hidden */
  6802. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6803. /**
  6804. * Tests if the bounding sphere is intersecting the frustum planes
  6805. * @param frustumPlanes defines the frustum planes to test
  6806. * @returns true if there is an intersection
  6807. */
  6808. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6809. /**
  6810. * Tests if the bounding sphere center is in between the frustum planes.
  6811. * Used for optimistic fast inclusion.
  6812. * @param frustumPlanes defines the frustum planes to test
  6813. * @returns true if the sphere center is in between the frustum planes
  6814. */
  6815. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6816. /**
  6817. * Tests if a point is inside the bounding sphere
  6818. * @param point defines the point to test
  6819. * @returns true if the point is inside the bounding sphere
  6820. */
  6821. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6822. /**
  6823. * Checks if two sphere intersct
  6824. * @param sphere0 sphere 0
  6825. * @param sphere1 sphere 1
  6826. * @returns true if the speres intersect
  6827. */
  6828. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6829. }
  6830. }
  6831. declare module BABYLON {
  6832. /**
  6833. * Class used to store bounding box information
  6834. */
  6835. export class BoundingBox implements ICullable {
  6836. /**
  6837. * Gets the 8 vectors representing the bounding box in local space
  6838. */
  6839. readonly vectors: Vector3[];
  6840. /**
  6841. * Gets the center of the bounding box in local space
  6842. */
  6843. readonly center: Vector3;
  6844. /**
  6845. * Gets the center of the bounding box in world space
  6846. */
  6847. readonly centerWorld: Vector3;
  6848. /**
  6849. * Gets the extend size in local space
  6850. */
  6851. readonly extendSize: Vector3;
  6852. /**
  6853. * Gets the extend size in world space
  6854. */
  6855. readonly extendSizeWorld: Vector3;
  6856. /**
  6857. * Gets the OBB (object bounding box) directions
  6858. */
  6859. readonly directions: Vector3[];
  6860. /**
  6861. * Gets the 8 vectors representing the bounding box in world space
  6862. */
  6863. readonly vectorsWorld: Vector3[];
  6864. /**
  6865. * Gets the minimum vector in world space
  6866. */
  6867. readonly minimumWorld: Vector3;
  6868. /**
  6869. * Gets the maximum vector in world space
  6870. */
  6871. readonly maximumWorld: Vector3;
  6872. /**
  6873. * Gets the minimum vector in local space
  6874. */
  6875. readonly minimum: Vector3;
  6876. /**
  6877. * Gets the maximum vector in local space
  6878. */
  6879. readonly maximum: Vector3;
  6880. private _worldMatrix;
  6881. private static readonly TmpVector3;
  6882. /**
  6883. * @hidden
  6884. */
  6885. _tag: number;
  6886. /**
  6887. * Creates a new bounding box
  6888. * @param min defines the minimum vector (in local space)
  6889. * @param max defines the maximum vector (in local space)
  6890. * @param worldMatrix defines the new world matrix
  6891. */
  6892. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6893. /**
  6894. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6895. * @param min defines the new minimum vector (in local space)
  6896. * @param max defines the new maximum vector (in local space)
  6897. * @param worldMatrix defines the new world matrix
  6898. */
  6899. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6900. /**
  6901. * Scale the current bounding box by applying a scale factor
  6902. * @param factor defines the scale factor to apply
  6903. * @returns the current bounding box
  6904. */
  6905. scale(factor: number): BoundingBox;
  6906. /**
  6907. * Gets the world matrix of the bounding box
  6908. * @returns a matrix
  6909. */
  6910. getWorldMatrix(): DeepImmutable<Matrix>;
  6911. /** @hidden */
  6912. _update(world: DeepImmutable<Matrix>): void;
  6913. /**
  6914. * Tests if the bounding box is intersecting the frustum planes
  6915. * @param frustumPlanes defines the frustum planes to test
  6916. * @returns true if there is an intersection
  6917. */
  6918. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6919. /**
  6920. * Tests if the bounding box is entirely inside the frustum planes
  6921. * @param frustumPlanes defines the frustum planes to test
  6922. * @returns true if there is an inclusion
  6923. */
  6924. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6925. /**
  6926. * Tests if a point is inside the bounding box
  6927. * @param point defines the point to test
  6928. * @returns true if the point is inside the bounding box
  6929. */
  6930. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6931. /**
  6932. * Tests if the bounding box intersects with a bounding sphere
  6933. * @param sphere defines the sphere to test
  6934. * @returns true if there is an intersection
  6935. */
  6936. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6937. /**
  6938. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6939. * @param min defines the min vector to use
  6940. * @param max defines the max vector to use
  6941. * @returns true if there is an intersection
  6942. */
  6943. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6944. /**
  6945. * Tests if two bounding boxes are intersections
  6946. * @param box0 defines the first box to test
  6947. * @param box1 defines the second box to test
  6948. * @returns true if there is an intersection
  6949. */
  6950. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6951. /**
  6952. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6953. * @param minPoint defines the minimum vector of the bounding box
  6954. * @param maxPoint defines the maximum vector of the bounding box
  6955. * @param sphereCenter defines the sphere center
  6956. * @param sphereRadius defines the sphere radius
  6957. * @returns true if there is an intersection
  6958. */
  6959. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6960. /**
  6961. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6962. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6963. * @param frustumPlanes defines the frustum planes to test
  6964. * @return true if there is an inclusion
  6965. */
  6966. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6967. /**
  6968. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6969. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6970. * @param frustumPlanes defines the frustum planes to test
  6971. * @return true if there is an intersection
  6972. */
  6973. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6974. }
  6975. }
  6976. declare module BABYLON {
  6977. /** @hidden */
  6978. export class Collider {
  6979. /** Define if a collision was found */
  6980. collisionFound: boolean;
  6981. /**
  6982. * Define last intersection point in local space
  6983. */
  6984. intersectionPoint: Vector3;
  6985. /**
  6986. * Define last collided mesh
  6987. */
  6988. collidedMesh: Nullable<AbstractMesh>;
  6989. private _collisionPoint;
  6990. private _planeIntersectionPoint;
  6991. private _tempVector;
  6992. private _tempVector2;
  6993. private _tempVector3;
  6994. private _tempVector4;
  6995. private _edge;
  6996. private _baseToVertex;
  6997. private _destinationPoint;
  6998. private _slidePlaneNormal;
  6999. private _displacementVector;
  7000. /** @hidden */
  7001. _radius: Vector3;
  7002. /** @hidden */
  7003. _retry: number;
  7004. private _velocity;
  7005. private _basePoint;
  7006. private _epsilon;
  7007. /** @hidden */
  7008. _velocityWorldLength: number;
  7009. /** @hidden */
  7010. _basePointWorld: Vector3;
  7011. private _velocityWorld;
  7012. private _normalizedVelocity;
  7013. /** @hidden */
  7014. _initialVelocity: Vector3;
  7015. /** @hidden */
  7016. _initialPosition: Vector3;
  7017. private _nearestDistance;
  7018. private _collisionMask;
  7019. get collisionMask(): number;
  7020. set collisionMask(mask: number);
  7021. /**
  7022. * Gets the plane normal used to compute the sliding response (in local space)
  7023. */
  7024. get slidePlaneNormal(): Vector3;
  7025. /** @hidden */
  7026. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7027. /** @hidden */
  7028. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7029. /** @hidden */
  7030. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7031. /** @hidden */
  7032. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7033. /** @hidden */
  7034. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7035. /** @hidden */
  7036. _getResponse(pos: Vector3, vel: Vector3): void;
  7037. }
  7038. }
  7039. declare module BABYLON {
  7040. /**
  7041. * Interface for cullable objects
  7042. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7043. */
  7044. export interface ICullable {
  7045. /**
  7046. * Checks if the object or part of the object is in the frustum
  7047. * @param frustumPlanes Camera near/planes
  7048. * @returns true if the object is in frustum otherwise false
  7049. */
  7050. isInFrustum(frustumPlanes: Plane[]): boolean;
  7051. /**
  7052. * Checks if a cullable object (mesh...) is in the camera frustum
  7053. * Unlike isInFrustum this cheks the full bounding box
  7054. * @param frustumPlanes Camera near/planes
  7055. * @returns true if the object is in frustum otherwise false
  7056. */
  7057. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7058. }
  7059. /**
  7060. * Info for a bounding data of a mesh
  7061. */
  7062. export class BoundingInfo implements ICullable {
  7063. /**
  7064. * Bounding box for the mesh
  7065. */
  7066. readonly boundingBox: BoundingBox;
  7067. /**
  7068. * Bounding sphere for the mesh
  7069. */
  7070. readonly boundingSphere: BoundingSphere;
  7071. private _isLocked;
  7072. private static readonly TmpVector3;
  7073. /**
  7074. * Constructs bounding info
  7075. * @param minimum min vector of the bounding box/sphere
  7076. * @param maximum max vector of the bounding box/sphere
  7077. * @param worldMatrix defines the new world matrix
  7078. */
  7079. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7080. /**
  7081. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7082. * @param min defines the new minimum vector (in local space)
  7083. * @param max defines the new maximum vector (in local space)
  7084. * @param worldMatrix defines the new world matrix
  7085. */
  7086. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7087. /**
  7088. * min vector of the bounding box/sphere
  7089. */
  7090. get minimum(): Vector3;
  7091. /**
  7092. * max vector of the bounding box/sphere
  7093. */
  7094. get maximum(): Vector3;
  7095. /**
  7096. * If the info is locked and won't be updated to avoid perf overhead
  7097. */
  7098. get isLocked(): boolean;
  7099. set isLocked(value: boolean);
  7100. /**
  7101. * Updates the bounding sphere and box
  7102. * @param world world matrix to be used to update
  7103. */
  7104. update(world: DeepImmutable<Matrix>): void;
  7105. /**
  7106. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7107. * @param center New center of the bounding info
  7108. * @param extend New extend of the bounding info
  7109. * @returns the current bounding info
  7110. */
  7111. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7112. /**
  7113. * Scale the current bounding info by applying a scale factor
  7114. * @param factor defines the scale factor to apply
  7115. * @returns the current bounding info
  7116. */
  7117. scale(factor: number): BoundingInfo;
  7118. /**
  7119. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7120. * @param frustumPlanes defines the frustum to test
  7121. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7122. * @returns true if the bounding info is in the frustum planes
  7123. */
  7124. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7125. /**
  7126. * Gets the world distance between the min and max points of the bounding box
  7127. */
  7128. get diagonalLength(): number;
  7129. /**
  7130. * Checks if a cullable object (mesh...) is in the camera frustum
  7131. * Unlike isInFrustum this cheks the full bounding box
  7132. * @param frustumPlanes Camera near/planes
  7133. * @returns true if the object is in frustum otherwise false
  7134. */
  7135. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7136. /** @hidden */
  7137. _checkCollision(collider: Collider): boolean;
  7138. /**
  7139. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7140. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7141. * @param point the point to check intersection with
  7142. * @returns if the point intersects
  7143. */
  7144. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7145. /**
  7146. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7147. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7148. * @param boundingInfo the bounding info to check intersection with
  7149. * @param precise if the intersection should be done using OBB
  7150. * @returns if the bounding info intersects
  7151. */
  7152. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7153. }
  7154. }
  7155. declare module BABYLON {
  7156. /**
  7157. * Extracts minimum and maximum values from a list of indexed positions
  7158. * @param positions defines the positions to use
  7159. * @param indices defines the indices to the positions
  7160. * @param indexStart defines the start index
  7161. * @param indexCount defines the end index
  7162. * @param bias defines bias value to add to the result
  7163. * @return minimum and maximum values
  7164. */
  7165. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7166. minimum: Vector3;
  7167. maximum: Vector3;
  7168. };
  7169. /**
  7170. * Extracts minimum and maximum values from a list of positions
  7171. * @param positions defines the positions to use
  7172. * @param start defines the start index in the positions array
  7173. * @param count defines the number of positions to handle
  7174. * @param bias defines bias value to add to the result
  7175. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7176. * @return minimum and maximum values
  7177. */
  7178. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7179. minimum: Vector3;
  7180. maximum: Vector3;
  7181. };
  7182. }
  7183. declare module BABYLON {
  7184. /** @hidden */
  7185. export class WebGLDataBuffer extends DataBuffer {
  7186. private _buffer;
  7187. constructor(resource: WebGLBuffer);
  7188. get underlyingResource(): any;
  7189. }
  7190. }
  7191. declare module BABYLON {
  7192. /** @hidden */
  7193. export class WebGLPipelineContext implements IPipelineContext {
  7194. engine: ThinEngine;
  7195. program: Nullable<WebGLProgram>;
  7196. context?: WebGLRenderingContext;
  7197. vertexShader?: WebGLShader;
  7198. fragmentShader?: WebGLShader;
  7199. isParallelCompiled: boolean;
  7200. onCompiled?: () => void;
  7201. transformFeedback?: WebGLTransformFeedback | null;
  7202. vertexCompilationError: Nullable<string>;
  7203. fragmentCompilationError: Nullable<string>;
  7204. programLinkError: Nullable<string>;
  7205. programValidationError: Nullable<string>;
  7206. get isAsync(): boolean;
  7207. get isReady(): boolean;
  7208. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7209. _getVertexShaderCode(): string | null;
  7210. _getFragmentShaderCode(): string | null;
  7211. }
  7212. }
  7213. declare module BABYLON {
  7214. interface ThinEngine {
  7215. /**
  7216. * Create an uniform buffer
  7217. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7218. * @param elements defines the content of the uniform buffer
  7219. * @returns the webGL uniform buffer
  7220. */
  7221. createUniformBuffer(elements: FloatArray): DataBuffer;
  7222. /**
  7223. * Create a dynamic uniform buffer
  7224. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7225. * @param elements defines the content of the uniform buffer
  7226. * @returns the webGL uniform buffer
  7227. */
  7228. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7229. /**
  7230. * Update an existing uniform buffer
  7231. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7232. * @param uniformBuffer defines the target uniform buffer
  7233. * @param elements defines the content to update
  7234. * @param offset defines the offset in the uniform buffer where update should start
  7235. * @param count defines the size of the data to update
  7236. */
  7237. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7238. /**
  7239. * Bind an uniform buffer to the current webGL context
  7240. * @param buffer defines the buffer to bind
  7241. */
  7242. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7243. /**
  7244. * Bind a buffer to the current webGL context at a given location
  7245. * @param buffer defines the buffer to bind
  7246. * @param location defines the index where to bind the buffer
  7247. */
  7248. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7249. /**
  7250. * Bind a specific block at a given index in a specific shader program
  7251. * @param pipelineContext defines the pipeline context to use
  7252. * @param blockName defines the block name
  7253. * @param index defines the index where to bind the block
  7254. */
  7255. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7256. }
  7257. }
  7258. declare module BABYLON {
  7259. /**
  7260. * Uniform buffer objects.
  7261. *
  7262. * Handles blocks of uniform on the GPU.
  7263. *
  7264. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7265. *
  7266. * For more information, please refer to :
  7267. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7268. */
  7269. export class UniformBuffer {
  7270. private _engine;
  7271. private _buffer;
  7272. private _data;
  7273. private _bufferData;
  7274. private _dynamic?;
  7275. private _uniformLocations;
  7276. private _uniformSizes;
  7277. private _uniformLocationPointer;
  7278. private _needSync;
  7279. private _noUBO;
  7280. private _currentEffect;
  7281. /** @hidden */
  7282. _alreadyBound: boolean;
  7283. private static _MAX_UNIFORM_SIZE;
  7284. private static _tempBuffer;
  7285. /**
  7286. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7287. * This is dynamic to allow compat with webgl 1 and 2.
  7288. * You will need to pass the name of the uniform as well as the value.
  7289. */
  7290. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7291. /**
  7292. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7293. * This is dynamic to allow compat with webgl 1 and 2.
  7294. * You will need to pass the name of the uniform as well as the value.
  7295. */
  7296. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7297. /**
  7298. * Lambda to Update a single float in a uniform buffer.
  7299. * This is dynamic to allow compat with webgl 1 and 2.
  7300. * You will need to pass the name of the uniform as well as the value.
  7301. */
  7302. updateFloat: (name: string, x: number) => void;
  7303. /**
  7304. * Lambda to Update a vec2 of float in a uniform buffer.
  7305. * This is dynamic to allow compat with webgl 1 and 2.
  7306. * You will need to pass the name of the uniform as well as the value.
  7307. */
  7308. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7309. /**
  7310. * Lambda to Update a vec3 of float in a uniform buffer.
  7311. * This is dynamic to allow compat with webgl 1 and 2.
  7312. * You will need to pass the name of the uniform as well as the value.
  7313. */
  7314. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7315. /**
  7316. * Lambda to Update a vec4 of float in a uniform buffer.
  7317. * This is dynamic to allow compat with webgl 1 and 2.
  7318. * You will need to pass the name of the uniform as well as the value.
  7319. */
  7320. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7321. /**
  7322. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7323. * This is dynamic to allow compat with webgl 1 and 2.
  7324. * You will need to pass the name of the uniform as well as the value.
  7325. */
  7326. updateMatrix: (name: string, mat: Matrix) => void;
  7327. /**
  7328. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7329. * This is dynamic to allow compat with webgl 1 and 2.
  7330. * You will need to pass the name of the uniform as well as the value.
  7331. */
  7332. updateVector3: (name: string, vector: Vector3) => void;
  7333. /**
  7334. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7335. * This is dynamic to allow compat with webgl 1 and 2.
  7336. * You will need to pass the name of the uniform as well as the value.
  7337. */
  7338. updateVector4: (name: string, vector: Vector4) => void;
  7339. /**
  7340. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7341. * This is dynamic to allow compat with webgl 1 and 2.
  7342. * You will need to pass the name of the uniform as well as the value.
  7343. */
  7344. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7345. /**
  7346. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7347. * This is dynamic to allow compat with webgl 1 and 2.
  7348. * You will need to pass the name of the uniform as well as the value.
  7349. */
  7350. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7351. /**
  7352. * Instantiates a new Uniform buffer objects.
  7353. *
  7354. * Handles blocks of uniform on the GPU.
  7355. *
  7356. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7357. *
  7358. * For more information, please refer to :
  7359. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7360. * @param engine Define the engine the buffer is associated with
  7361. * @param data Define the data contained in the buffer
  7362. * @param dynamic Define if the buffer is updatable
  7363. */
  7364. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7365. /**
  7366. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7367. * or just falling back on setUniformXXX calls.
  7368. */
  7369. get useUbo(): boolean;
  7370. /**
  7371. * Indicates if the WebGL underlying uniform buffer is in sync
  7372. * with the javascript cache data.
  7373. */
  7374. get isSync(): boolean;
  7375. /**
  7376. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7377. * Also, a dynamic UniformBuffer will disable cache verification and always
  7378. * update the underlying WebGL uniform buffer to the GPU.
  7379. * @returns if Dynamic, otherwise false
  7380. */
  7381. isDynamic(): boolean;
  7382. /**
  7383. * The data cache on JS side.
  7384. * @returns the underlying data as a float array
  7385. */
  7386. getData(): Float32Array;
  7387. /**
  7388. * The underlying WebGL Uniform buffer.
  7389. * @returns the webgl buffer
  7390. */
  7391. getBuffer(): Nullable<DataBuffer>;
  7392. /**
  7393. * std140 layout specifies how to align data within an UBO structure.
  7394. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7395. * for specs.
  7396. */
  7397. private _fillAlignment;
  7398. /**
  7399. * Adds an uniform in the buffer.
  7400. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7401. * for the layout to be correct !
  7402. * @param name Name of the uniform, as used in the uniform block in the shader.
  7403. * @param size Data size, or data directly.
  7404. */
  7405. addUniform(name: string, size: number | number[]): void;
  7406. /**
  7407. * Adds a Matrix 4x4 to the uniform buffer.
  7408. * @param name Name of the uniform, as used in the uniform block in the shader.
  7409. * @param mat A 4x4 matrix.
  7410. */
  7411. addMatrix(name: string, mat: Matrix): void;
  7412. /**
  7413. * Adds a vec2 to the uniform buffer.
  7414. * @param name Name of the uniform, as used in the uniform block in the shader.
  7415. * @param x Define the x component value of the vec2
  7416. * @param y Define the y component value of the vec2
  7417. */
  7418. addFloat2(name: string, x: number, y: number): void;
  7419. /**
  7420. * Adds a vec3 to the uniform buffer.
  7421. * @param name Name of the uniform, as used in the uniform block in the shader.
  7422. * @param x Define the x component value of the vec3
  7423. * @param y Define the y component value of the vec3
  7424. * @param z Define the z component value of the vec3
  7425. */
  7426. addFloat3(name: string, x: number, y: number, z: number): void;
  7427. /**
  7428. * Adds a vec3 to the uniform buffer.
  7429. * @param name Name of the uniform, as used in the uniform block in the shader.
  7430. * @param color Define the vec3 from a Color
  7431. */
  7432. addColor3(name: string, color: Color3): void;
  7433. /**
  7434. * Adds a vec4 to the uniform buffer.
  7435. * @param name Name of the uniform, as used in the uniform block in the shader.
  7436. * @param color Define the rgb components from a Color
  7437. * @param alpha Define the a component of the vec4
  7438. */
  7439. addColor4(name: string, color: Color3, alpha: number): void;
  7440. /**
  7441. * Adds a vec3 to the uniform buffer.
  7442. * @param name Name of the uniform, as used in the uniform block in the shader.
  7443. * @param vector Define the vec3 components from a Vector
  7444. */
  7445. addVector3(name: string, vector: Vector3): void;
  7446. /**
  7447. * Adds a Matrix 3x3 to the uniform buffer.
  7448. * @param name Name of the uniform, as used in the uniform block in the shader.
  7449. */
  7450. addMatrix3x3(name: string): void;
  7451. /**
  7452. * Adds a Matrix 2x2 to the uniform buffer.
  7453. * @param name Name of the uniform, as used in the uniform block in the shader.
  7454. */
  7455. addMatrix2x2(name: string): void;
  7456. /**
  7457. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7458. */
  7459. create(): void;
  7460. /** @hidden */
  7461. _rebuild(): void;
  7462. /**
  7463. * Updates the WebGL Uniform Buffer on the GPU.
  7464. * If the `dynamic` flag is set to true, no cache comparison is done.
  7465. * Otherwise, the buffer will be updated only if the cache differs.
  7466. */
  7467. update(): void;
  7468. /**
  7469. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7470. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7471. * @param data Define the flattened data
  7472. * @param size Define the size of the data.
  7473. */
  7474. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7475. private _valueCache;
  7476. private _cacheMatrix;
  7477. private _updateMatrix3x3ForUniform;
  7478. private _updateMatrix3x3ForEffect;
  7479. private _updateMatrix2x2ForEffect;
  7480. private _updateMatrix2x2ForUniform;
  7481. private _updateFloatForEffect;
  7482. private _updateFloatForUniform;
  7483. private _updateFloat2ForEffect;
  7484. private _updateFloat2ForUniform;
  7485. private _updateFloat3ForEffect;
  7486. private _updateFloat3ForUniform;
  7487. private _updateFloat4ForEffect;
  7488. private _updateFloat4ForUniform;
  7489. private _updateMatrixForEffect;
  7490. private _updateMatrixForUniform;
  7491. private _updateVector3ForEffect;
  7492. private _updateVector3ForUniform;
  7493. private _updateVector4ForEffect;
  7494. private _updateVector4ForUniform;
  7495. private _updateColor3ForEffect;
  7496. private _updateColor3ForUniform;
  7497. private _updateColor4ForEffect;
  7498. private _updateColor4ForUniform;
  7499. /**
  7500. * Sets a sampler uniform on the effect.
  7501. * @param name Define the name of the sampler.
  7502. * @param texture Define the texture to set in the sampler
  7503. */
  7504. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7505. /**
  7506. * Directly updates the value of the uniform in the cache AND on the GPU.
  7507. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7508. * @param data Define the flattened data
  7509. */
  7510. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7511. /**
  7512. * Binds this uniform buffer to an effect.
  7513. * @param effect Define the effect to bind the buffer to
  7514. * @param name Name of the uniform block in the shader.
  7515. */
  7516. bindToEffect(effect: Effect, name: string): void;
  7517. /**
  7518. * Disposes the uniform buffer.
  7519. */
  7520. dispose(): void;
  7521. }
  7522. }
  7523. declare module BABYLON {
  7524. /**
  7525. * Enum that determines the text-wrapping mode to use.
  7526. */
  7527. export enum InspectableType {
  7528. /**
  7529. * Checkbox for booleans
  7530. */
  7531. Checkbox = 0,
  7532. /**
  7533. * Sliders for numbers
  7534. */
  7535. Slider = 1,
  7536. /**
  7537. * Vector3
  7538. */
  7539. Vector3 = 2,
  7540. /**
  7541. * Quaternions
  7542. */
  7543. Quaternion = 3,
  7544. /**
  7545. * Color3
  7546. */
  7547. Color3 = 4,
  7548. /**
  7549. * String
  7550. */
  7551. String = 5
  7552. }
  7553. /**
  7554. * Interface used to define custom inspectable properties.
  7555. * This interface is used by the inspector to display custom property grids
  7556. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7557. */
  7558. export interface IInspectable {
  7559. /**
  7560. * Gets the label to display
  7561. */
  7562. label: string;
  7563. /**
  7564. * Gets the name of the property to edit
  7565. */
  7566. propertyName: string;
  7567. /**
  7568. * Gets the type of the editor to use
  7569. */
  7570. type: InspectableType;
  7571. /**
  7572. * Gets the minimum value of the property when using in "slider" mode
  7573. */
  7574. min?: number;
  7575. /**
  7576. * Gets the maximum value of the property when using in "slider" mode
  7577. */
  7578. max?: number;
  7579. /**
  7580. * Gets the setp to use when using in "slider" mode
  7581. */
  7582. step?: number;
  7583. }
  7584. }
  7585. declare module BABYLON {
  7586. /**
  7587. * Class used to provide helper for timing
  7588. */
  7589. export class TimingTools {
  7590. /**
  7591. * Polyfill for setImmediate
  7592. * @param action defines the action to execute after the current execution block
  7593. */
  7594. static SetImmediate(action: () => void): void;
  7595. }
  7596. }
  7597. declare module BABYLON {
  7598. /**
  7599. * Class used to enable instatition of objects by class name
  7600. */
  7601. export class InstantiationTools {
  7602. /**
  7603. * Use this object to register external classes like custom textures or material
  7604. * to allow the laoders to instantiate them
  7605. */
  7606. static RegisteredExternalClasses: {
  7607. [key: string]: Object;
  7608. };
  7609. /**
  7610. * Tries to instantiate a new object from a given class name
  7611. * @param className defines the class name to instantiate
  7612. * @returns the new object or null if the system was not able to do the instantiation
  7613. */
  7614. static Instantiate(className: string): any;
  7615. }
  7616. }
  7617. declare module BABYLON {
  7618. /**
  7619. * Define options used to create a depth texture
  7620. */
  7621. export class DepthTextureCreationOptions {
  7622. /** Specifies whether or not a stencil should be allocated in the texture */
  7623. generateStencil?: boolean;
  7624. /** Specifies whether or not bilinear filtering is enable on the texture */
  7625. bilinearFiltering?: boolean;
  7626. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7627. comparisonFunction?: number;
  7628. /** Specifies if the created texture is a cube texture */
  7629. isCube?: boolean;
  7630. }
  7631. }
  7632. declare module BABYLON {
  7633. interface ThinEngine {
  7634. /**
  7635. * Creates a depth stencil cube texture.
  7636. * This is only available in WebGL 2.
  7637. * @param size The size of face edge in the cube texture.
  7638. * @param options The options defining the cube texture.
  7639. * @returns The cube texture
  7640. */
  7641. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7642. /**
  7643. * Creates a cube texture
  7644. * @param rootUrl defines the url where the files to load is located
  7645. * @param scene defines the current scene
  7646. * @param files defines the list of files to load (1 per face)
  7647. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7648. * @param onLoad defines an optional callback raised when the texture is loaded
  7649. * @param onError defines an optional callback raised if there is an issue to load the texture
  7650. * @param format defines the format of the data
  7651. * @param forcedExtension defines the extension to use to pick the right loader
  7652. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7653. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7654. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7655. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7656. * @returns the cube texture as an InternalTexture
  7657. */
  7658. 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;
  7659. /**
  7660. * Creates a cube texture
  7661. * @param rootUrl defines the url where the files to load is located
  7662. * @param scene defines the current scene
  7663. * @param files defines the list of files to load (1 per face)
  7664. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7665. * @param onLoad defines an optional callback raised when the texture is loaded
  7666. * @param onError defines an optional callback raised if there is an issue to load the texture
  7667. * @param format defines the format of the data
  7668. * @param forcedExtension defines the extension to use to pick the right loader
  7669. * @returns the cube texture as an InternalTexture
  7670. */
  7671. 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;
  7672. /**
  7673. * Creates a cube texture
  7674. * @param rootUrl defines the url where the files to load is located
  7675. * @param scene defines the current scene
  7676. * @param files defines the list of files to load (1 per face)
  7677. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7678. * @param onLoad defines an optional callback raised when the texture is loaded
  7679. * @param onError defines an optional callback raised if there is an issue to load the texture
  7680. * @param format defines the format of the data
  7681. * @param forcedExtension defines the extension to use to pick the right loader
  7682. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7683. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7684. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7685. * @returns the cube texture as an InternalTexture
  7686. */
  7687. 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;
  7688. /** @hidden */
  7689. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7690. /** @hidden */
  7691. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7692. /** @hidden */
  7693. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7694. /** @hidden */
  7695. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7696. /**
  7697. * @hidden
  7698. */
  7699. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7700. }
  7701. }
  7702. declare module BABYLON {
  7703. /**
  7704. * Class for creating a cube texture
  7705. */
  7706. export class CubeTexture extends BaseTexture {
  7707. private _delayedOnLoad;
  7708. /**
  7709. * Observable triggered once the texture has been loaded.
  7710. */
  7711. onLoadObservable: Observable<CubeTexture>;
  7712. /**
  7713. * The url of the texture
  7714. */
  7715. url: string;
  7716. /**
  7717. * Gets or sets the center of the bounding box associated with the cube texture.
  7718. * It must define where the camera used to render the texture was set
  7719. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7720. */
  7721. boundingBoxPosition: Vector3;
  7722. private _boundingBoxSize;
  7723. /**
  7724. * Gets or sets the size of the bounding box associated with the cube texture
  7725. * When defined, the cubemap will switch to local mode
  7726. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7727. * @example https://www.babylonjs-playground.com/#RNASML
  7728. */
  7729. set boundingBoxSize(value: Vector3);
  7730. /**
  7731. * Returns the bounding box size
  7732. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7733. */
  7734. get boundingBoxSize(): Vector3;
  7735. protected _rotationY: number;
  7736. /**
  7737. * Sets texture matrix rotation angle around Y axis in radians.
  7738. */
  7739. set rotationY(value: number);
  7740. /**
  7741. * Gets texture matrix rotation angle around Y axis radians.
  7742. */
  7743. get rotationY(): number;
  7744. /**
  7745. * Are mip maps generated for this texture or not.
  7746. */
  7747. get noMipmap(): boolean;
  7748. private _noMipmap;
  7749. private _files;
  7750. protected _forcedExtension: Nullable<string>;
  7751. private _extensions;
  7752. private _textureMatrix;
  7753. private _format;
  7754. private _createPolynomials;
  7755. /**
  7756. * Creates a cube texture from an array of image urls
  7757. * @param files defines an array of image urls
  7758. * @param scene defines the hosting scene
  7759. * @param noMipmap specifies if mip maps are not used
  7760. * @returns a cube texture
  7761. */
  7762. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7763. /**
  7764. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7765. * @param url defines the url of the prefiltered texture
  7766. * @param scene defines the scene the texture is attached to
  7767. * @param forcedExtension defines the extension of the file if different from the url
  7768. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7769. * @return the prefiltered texture
  7770. */
  7771. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7772. /**
  7773. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7774. * as prefiltered data.
  7775. * @param rootUrl defines the url of the texture or the root name of the six images
  7776. * @param null defines the scene or engine the texture is attached to
  7777. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7778. * @param noMipmap defines if mipmaps should be created or not
  7779. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7780. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7781. * @param onError defines a callback triggered in case of error during load
  7782. * @param format defines the internal format to use for the texture once loaded
  7783. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7784. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7785. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7786. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7787. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7788. * @return the cube texture
  7789. */
  7790. 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);
  7791. /**
  7792. * Get the current class name of the texture useful for serialization or dynamic coding.
  7793. * @returns "CubeTexture"
  7794. */
  7795. getClassName(): string;
  7796. /**
  7797. * Update the url (and optional buffer) of this texture if url was null during construction.
  7798. * @param url the url of the texture
  7799. * @param forcedExtension defines the extension to use
  7800. * @param onLoad callback called when the texture is loaded (defaults to null)
  7801. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7802. */
  7803. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7804. /**
  7805. * Delays loading of the cube texture
  7806. * @param forcedExtension defines the extension to use
  7807. */
  7808. delayLoad(forcedExtension?: string): void;
  7809. /**
  7810. * Returns the reflection texture matrix
  7811. * @returns the reflection texture matrix
  7812. */
  7813. getReflectionTextureMatrix(): Matrix;
  7814. /**
  7815. * Sets the reflection texture matrix
  7816. * @param value Reflection texture matrix
  7817. */
  7818. setReflectionTextureMatrix(value: Matrix): void;
  7819. /**
  7820. * Parses text to create a cube texture
  7821. * @param parsedTexture define the serialized text to read from
  7822. * @param scene defines the hosting scene
  7823. * @param rootUrl defines the root url of the cube texture
  7824. * @returns a cube texture
  7825. */
  7826. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7827. /**
  7828. * Makes a clone, or deep copy, of the cube texture
  7829. * @returns a new cube texture
  7830. */
  7831. clone(): CubeTexture;
  7832. }
  7833. }
  7834. declare module BABYLON {
  7835. /**
  7836. * Manages the defines for the Material
  7837. */
  7838. export class MaterialDefines {
  7839. /** @hidden */
  7840. protected _keys: string[];
  7841. private _isDirty;
  7842. /** @hidden */
  7843. _renderId: number;
  7844. /** @hidden */
  7845. _areLightsDirty: boolean;
  7846. /** @hidden */
  7847. _areLightsDisposed: boolean;
  7848. /** @hidden */
  7849. _areAttributesDirty: boolean;
  7850. /** @hidden */
  7851. _areTexturesDirty: boolean;
  7852. /** @hidden */
  7853. _areFresnelDirty: boolean;
  7854. /** @hidden */
  7855. _areMiscDirty: boolean;
  7856. /** @hidden */
  7857. _areImageProcessingDirty: boolean;
  7858. /** @hidden */
  7859. _normals: boolean;
  7860. /** @hidden */
  7861. _uvs: boolean;
  7862. /** @hidden */
  7863. _needNormals: boolean;
  7864. /** @hidden */
  7865. _needUVs: boolean;
  7866. [id: string]: any;
  7867. /**
  7868. * Specifies if the material needs to be re-calculated
  7869. */
  7870. get isDirty(): boolean;
  7871. /**
  7872. * Marks the material to indicate that it has been re-calculated
  7873. */
  7874. markAsProcessed(): void;
  7875. /**
  7876. * Marks the material to indicate that it needs to be re-calculated
  7877. */
  7878. markAsUnprocessed(): void;
  7879. /**
  7880. * Marks the material to indicate all of its defines need to be re-calculated
  7881. */
  7882. markAllAsDirty(): void;
  7883. /**
  7884. * Marks the material to indicate that image processing needs to be re-calculated
  7885. */
  7886. markAsImageProcessingDirty(): void;
  7887. /**
  7888. * Marks the material to indicate the lights need to be re-calculated
  7889. * @param disposed Defines whether the light is dirty due to dispose or not
  7890. */
  7891. markAsLightDirty(disposed?: boolean): void;
  7892. /**
  7893. * Marks the attribute state as changed
  7894. */
  7895. markAsAttributesDirty(): void;
  7896. /**
  7897. * Marks the texture state as changed
  7898. */
  7899. markAsTexturesDirty(): void;
  7900. /**
  7901. * Marks the fresnel state as changed
  7902. */
  7903. markAsFresnelDirty(): void;
  7904. /**
  7905. * Marks the misc state as changed
  7906. */
  7907. markAsMiscDirty(): void;
  7908. /**
  7909. * Rebuilds the material defines
  7910. */
  7911. rebuild(): void;
  7912. /**
  7913. * Specifies if two material defines are equal
  7914. * @param other - A material define instance to compare to
  7915. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7916. */
  7917. isEqual(other: MaterialDefines): boolean;
  7918. /**
  7919. * Clones this instance's defines to another instance
  7920. * @param other - material defines to clone values to
  7921. */
  7922. cloneTo(other: MaterialDefines): void;
  7923. /**
  7924. * Resets the material define values
  7925. */
  7926. reset(): void;
  7927. /**
  7928. * Converts the material define values to a string
  7929. * @returns - String of material define information
  7930. */
  7931. toString(): string;
  7932. }
  7933. }
  7934. declare module BABYLON {
  7935. /**
  7936. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7937. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7938. * 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;
  7939. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7940. */
  7941. export class ColorCurves {
  7942. private _dirty;
  7943. private _tempColor;
  7944. private _globalCurve;
  7945. private _highlightsCurve;
  7946. private _midtonesCurve;
  7947. private _shadowsCurve;
  7948. private _positiveCurve;
  7949. private _negativeCurve;
  7950. private _globalHue;
  7951. private _globalDensity;
  7952. private _globalSaturation;
  7953. private _globalExposure;
  7954. /**
  7955. * Gets the global Hue value.
  7956. * 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).
  7957. */
  7958. get globalHue(): number;
  7959. /**
  7960. * Sets the global Hue value.
  7961. * 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).
  7962. */
  7963. set globalHue(value: number);
  7964. /**
  7965. * Gets the global Density value.
  7966. * 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.
  7967. * Values less than zero provide a filter of opposite hue.
  7968. */
  7969. get globalDensity(): number;
  7970. /**
  7971. * Sets the global Density value.
  7972. * 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.
  7973. * Values less than zero provide a filter of opposite hue.
  7974. */
  7975. set globalDensity(value: number);
  7976. /**
  7977. * Gets the global Saturation value.
  7978. * 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.
  7979. */
  7980. get globalSaturation(): number;
  7981. /**
  7982. * Sets the global Saturation value.
  7983. * 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.
  7984. */
  7985. set globalSaturation(value: number);
  7986. /**
  7987. * Gets the global Exposure value.
  7988. * 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.
  7989. */
  7990. get globalExposure(): number;
  7991. /**
  7992. * Sets the global Exposure value.
  7993. * 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.
  7994. */
  7995. set globalExposure(value: number);
  7996. private _highlightsHue;
  7997. private _highlightsDensity;
  7998. private _highlightsSaturation;
  7999. private _highlightsExposure;
  8000. /**
  8001. * Gets the highlights Hue value.
  8002. * 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).
  8003. */
  8004. get highlightsHue(): number;
  8005. /**
  8006. * Sets the highlights Hue value.
  8007. * 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).
  8008. */
  8009. set highlightsHue(value: number);
  8010. /**
  8011. * Gets the highlights Density value.
  8012. * 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.
  8013. * Values less than zero provide a filter of opposite hue.
  8014. */
  8015. get highlightsDensity(): number;
  8016. /**
  8017. * Sets the highlights Density value.
  8018. * 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.
  8019. * Values less than zero provide a filter of opposite hue.
  8020. */
  8021. set highlightsDensity(value: number);
  8022. /**
  8023. * Gets the highlights Saturation value.
  8024. * 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.
  8025. */
  8026. get highlightsSaturation(): number;
  8027. /**
  8028. * Sets the highlights Saturation value.
  8029. * 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.
  8030. */
  8031. set highlightsSaturation(value: number);
  8032. /**
  8033. * Gets the highlights Exposure value.
  8034. * 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.
  8035. */
  8036. get highlightsExposure(): number;
  8037. /**
  8038. * Sets the highlights Exposure value.
  8039. * 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.
  8040. */
  8041. set highlightsExposure(value: number);
  8042. private _midtonesHue;
  8043. private _midtonesDensity;
  8044. private _midtonesSaturation;
  8045. private _midtonesExposure;
  8046. /**
  8047. * Gets the midtones Hue value.
  8048. * 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).
  8049. */
  8050. get midtonesHue(): number;
  8051. /**
  8052. * Sets the midtones Hue value.
  8053. * 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).
  8054. */
  8055. set midtonesHue(value: number);
  8056. /**
  8057. * Gets the midtones Density value.
  8058. * 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.
  8059. * Values less than zero provide a filter of opposite hue.
  8060. */
  8061. get midtonesDensity(): number;
  8062. /**
  8063. * Sets the midtones Density value.
  8064. * 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.
  8065. * Values less than zero provide a filter of opposite hue.
  8066. */
  8067. set midtonesDensity(value: number);
  8068. /**
  8069. * Gets the midtones Saturation value.
  8070. * 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.
  8071. */
  8072. get midtonesSaturation(): number;
  8073. /**
  8074. * Sets the midtones Saturation value.
  8075. * 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.
  8076. */
  8077. set midtonesSaturation(value: number);
  8078. /**
  8079. * Gets the midtones Exposure value.
  8080. * 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.
  8081. */
  8082. get midtonesExposure(): number;
  8083. /**
  8084. * Sets the midtones Exposure value.
  8085. * 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.
  8086. */
  8087. set midtonesExposure(value: number);
  8088. private _shadowsHue;
  8089. private _shadowsDensity;
  8090. private _shadowsSaturation;
  8091. private _shadowsExposure;
  8092. /**
  8093. * Gets the shadows Hue value.
  8094. * 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).
  8095. */
  8096. get shadowsHue(): number;
  8097. /**
  8098. * Sets the shadows Hue value.
  8099. * 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).
  8100. */
  8101. set shadowsHue(value: number);
  8102. /**
  8103. * Gets the shadows Density value.
  8104. * 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.
  8105. * Values less than zero provide a filter of opposite hue.
  8106. */
  8107. get shadowsDensity(): number;
  8108. /**
  8109. * Sets the shadows Density value.
  8110. * 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.
  8111. * Values less than zero provide a filter of opposite hue.
  8112. */
  8113. set shadowsDensity(value: number);
  8114. /**
  8115. * Gets the shadows Saturation value.
  8116. * 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.
  8117. */
  8118. get shadowsSaturation(): number;
  8119. /**
  8120. * Sets the shadows Saturation value.
  8121. * 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.
  8122. */
  8123. set shadowsSaturation(value: number);
  8124. /**
  8125. * Gets the shadows Exposure value.
  8126. * 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.
  8127. */
  8128. get shadowsExposure(): number;
  8129. /**
  8130. * Sets the shadows Exposure value.
  8131. * 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.
  8132. */
  8133. set shadowsExposure(value: number);
  8134. /**
  8135. * Returns the class name
  8136. * @returns The class name
  8137. */
  8138. getClassName(): string;
  8139. /**
  8140. * Binds the color curves to the shader.
  8141. * @param colorCurves The color curve to bind
  8142. * @param effect The effect to bind to
  8143. * @param positiveUniform The positive uniform shader parameter
  8144. * @param neutralUniform The neutral uniform shader parameter
  8145. * @param negativeUniform The negative uniform shader parameter
  8146. */
  8147. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8148. /**
  8149. * Prepare the list of uniforms associated with the ColorCurves effects.
  8150. * @param uniformsList The list of uniforms used in the effect
  8151. */
  8152. static PrepareUniforms(uniformsList: string[]): void;
  8153. /**
  8154. * Returns color grading data based on a hue, density, saturation and exposure value.
  8155. * @param filterHue The hue of the color filter.
  8156. * @param filterDensity The density of the color filter.
  8157. * @param saturation The saturation.
  8158. * @param exposure The exposure.
  8159. * @param result The result data container.
  8160. */
  8161. private getColorGradingDataToRef;
  8162. /**
  8163. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8164. * @param value The input slider value in range [-100,100].
  8165. * @returns Adjusted value.
  8166. */
  8167. private static applyColorGradingSliderNonlinear;
  8168. /**
  8169. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8170. * @param hue The hue (H) input.
  8171. * @param saturation The saturation (S) input.
  8172. * @param brightness The brightness (B) input.
  8173. * @result An RGBA color represented as Vector4.
  8174. */
  8175. private static fromHSBToRef;
  8176. /**
  8177. * Returns a value clamped between min and max
  8178. * @param value The value to clamp
  8179. * @param min The minimum of value
  8180. * @param max The maximum of value
  8181. * @returns The clamped value.
  8182. */
  8183. private static clamp;
  8184. /**
  8185. * Clones the current color curve instance.
  8186. * @return The cloned curves
  8187. */
  8188. clone(): ColorCurves;
  8189. /**
  8190. * Serializes the current color curve instance to a json representation.
  8191. * @return a JSON representation
  8192. */
  8193. serialize(): any;
  8194. /**
  8195. * Parses the color curve from a json representation.
  8196. * @param source the JSON source to parse
  8197. * @return The parsed curves
  8198. */
  8199. static Parse(source: any): ColorCurves;
  8200. }
  8201. }
  8202. declare module BABYLON {
  8203. /**
  8204. * Interface to follow in your material defines to integrate easily the
  8205. * Image proccessing functions.
  8206. * @hidden
  8207. */
  8208. export interface IImageProcessingConfigurationDefines {
  8209. IMAGEPROCESSING: boolean;
  8210. VIGNETTE: boolean;
  8211. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8212. VIGNETTEBLENDMODEOPAQUE: boolean;
  8213. TONEMAPPING: boolean;
  8214. TONEMAPPING_ACES: boolean;
  8215. CONTRAST: boolean;
  8216. EXPOSURE: boolean;
  8217. COLORCURVES: boolean;
  8218. COLORGRADING: boolean;
  8219. COLORGRADING3D: boolean;
  8220. SAMPLER3DGREENDEPTH: boolean;
  8221. SAMPLER3DBGRMAP: boolean;
  8222. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8223. }
  8224. /**
  8225. * @hidden
  8226. */
  8227. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8228. IMAGEPROCESSING: boolean;
  8229. VIGNETTE: boolean;
  8230. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8231. VIGNETTEBLENDMODEOPAQUE: boolean;
  8232. TONEMAPPING: boolean;
  8233. TONEMAPPING_ACES: boolean;
  8234. CONTRAST: boolean;
  8235. COLORCURVES: boolean;
  8236. COLORGRADING: boolean;
  8237. COLORGRADING3D: boolean;
  8238. SAMPLER3DGREENDEPTH: boolean;
  8239. SAMPLER3DBGRMAP: boolean;
  8240. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8241. EXPOSURE: boolean;
  8242. constructor();
  8243. }
  8244. /**
  8245. * This groups together the common properties used for image processing either in direct forward pass
  8246. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8247. * or not.
  8248. */
  8249. export class ImageProcessingConfiguration {
  8250. /**
  8251. * Default tone mapping applied in BabylonJS.
  8252. */
  8253. static readonly TONEMAPPING_STANDARD: number;
  8254. /**
  8255. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8256. * to other engines rendering to increase portability.
  8257. */
  8258. static readonly TONEMAPPING_ACES: number;
  8259. /**
  8260. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8261. */
  8262. colorCurves: Nullable<ColorCurves>;
  8263. private _colorCurvesEnabled;
  8264. /**
  8265. * Gets wether the color curves effect is enabled.
  8266. */
  8267. get colorCurvesEnabled(): boolean;
  8268. /**
  8269. * Sets wether the color curves effect is enabled.
  8270. */
  8271. set colorCurvesEnabled(value: boolean);
  8272. private _colorGradingTexture;
  8273. /**
  8274. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8275. */
  8276. get colorGradingTexture(): Nullable<BaseTexture>;
  8277. /**
  8278. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8279. */
  8280. set colorGradingTexture(value: Nullable<BaseTexture>);
  8281. private _colorGradingEnabled;
  8282. /**
  8283. * Gets wether the color grading effect is enabled.
  8284. */
  8285. get colorGradingEnabled(): boolean;
  8286. /**
  8287. * Sets wether the color grading effect is enabled.
  8288. */
  8289. set colorGradingEnabled(value: boolean);
  8290. private _colorGradingWithGreenDepth;
  8291. /**
  8292. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8293. */
  8294. get colorGradingWithGreenDepth(): boolean;
  8295. /**
  8296. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8297. */
  8298. set colorGradingWithGreenDepth(value: boolean);
  8299. private _colorGradingBGR;
  8300. /**
  8301. * Gets wether the color grading texture contains BGR values.
  8302. */
  8303. get colorGradingBGR(): boolean;
  8304. /**
  8305. * Sets wether the color grading texture contains BGR values.
  8306. */
  8307. set colorGradingBGR(value: boolean);
  8308. /** @hidden */
  8309. _exposure: number;
  8310. /**
  8311. * Gets the Exposure used in the effect.
  8312. */
  8313. get exposure(): number;
  8314. /**
  8315. * Sets the Exposure used in the effect.
  8316. */
  8317. set exposure(value: number);
  8318. private _toneMappingEnabled;
  8319. /**
  8320. * Gets wether the tone mapping effect is enabled.
  8321. */
  8322. get toneMappingEnabled(): boolean;
  8323. /**
  8324. * Sets wether the tone mapping effect is enabled.
  8325. */
  8326. set toneMappingEnabled(value: boolean);
  8327. private _toneMappingType;
  8328. /**
  8329. * Gets the type of tone mapping effect.
  8330. */
  8331. get toneMappingType(): number;
  8332. /**
  8333. * Sets the type of tone mapping effect used in BabylonJS.
  8334. */
  8335. set toneMappingType(value: number);
  8336. protected _contrast: number;
  8337. /**
  8338. * Gets the contrast used in the effect.
  8339. */
  8340. get contrast(): number;
  8341. /**
  8342. * Sets the contrast used in the effect.
  8343. */
  8344. set contrast(value: number);
  8345. /**
  8346. * Vignette stretch size.
  8347. */
  8348. vignetteStretch: number;
  8349. /**
  8350. * Vignette centre X Offset.
  8351. */
  8352. vignetteCentreX: number;
  8353. /**
  8354. * Vignette centre Y Offset.
  8355. */
  8356. vignetteCentreY: number;
  8357. /**
  8358. * Vignette weight or intensity of the vignette effect.
  8359. */
  8360. vignetteWeight: number;
  8361. /**
  8362. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8363. * if vignetteEnabled is set to true.
  8364. */
  8365. vignetteColor: Color4;
  8366. /**
  8367. * Camera field of view used by the Vignette effect.
  8368. */
  8369. vignetteCameraFov: number;
  8370. private _vignetteBlendMode;
  8371. /**
  8372. * Gets the vignette blend mode allowing different kind of effect.
  8373. */
  8374. get vignetteBlendMode(): number;
  8375. /**
  8376. * Sets the vignette blend mode allowing different kind of effect.
  8377. */
  8378. set vignetteBlendMode(value: number);
  8379. private _vignetteEnabled;
  8380. /**
  8381. * Gets wether the vignette effect is enabled.
  8382. */
  8383. get vignetteEnabled(): boolean;
  8384. /**
  8385. * Sets wether the vignette effect is enabled.
  8386. */
  8387. set vignetteEnabled(value: boolean);
  8388. private _applyByPostProcess;
  8389. /**
  8390. * Gets wether the image processing is applied through a post process or not.
  8391. */
  8392. get applyByPostProcess(): boolean;
  8393. /**
  8394. * Sets wether the image processing is applied through a post process or not.
  8395. */
  8396. set applyByPostProcess(value: boolean);
  8397. private _isEnabled;
  8398. /**
  8399. * Gets wether the image processing is enabled or not.
  8400. */
  8401. get isEnabled(): boolean;
  8402. /**
  8403. * Sets wether the image processing is enabled or not.
  8404. */
  8405. set isEnabled(value: boolean);
  8406. /**
  8407. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8408. */
  8409. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8410. /**
  8411. * Method called each time the image processing information changes requires to recompile the effect.
  8412. */
  8413. protected _updateParameters(): void;
  8414. /**
  8415. * Gets the current class name.
  8416. * @return "ImageProcessingConfiguration"
  8417. */
  8418. getClassName(): string;
  8419. /**
  8420. * Prepare the list of uniforms associated with the Image Processing effects.
  8421. * @param uniforms The list of uniforms used in the effect
  8422. * @param defines the list of defines currently in use
  8423. */
  8424. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8425. /**
  8426. * Prepare the list of samplers associated with the Image Processing effects.
  8427. * @param samplersList The list of uniforms used in the effect
  8428. * @param defines the list of defines currently in use
  8429. */
  8430. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8431. /**
  8432. * Prepare the list of defines associated to the shader.
  8433. * @param defines the list of defines to complete
  8434. * @param forPostProcess Define if we are currently in post process mode or not
  8435. */
  8436. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8437. /**
  8438. * Returns true if all the image processing information are ready.
  8439. * @returns True if ready, otherwise, false
  8440. */
  8441. isReady(): boolean;
  8442. /**
  8443. * Binds the image processing to the shader.
  8444. * @param effect The effect to bind to
  8445. * @param overrideAspectRatio Override the aspect ratio of the effect
  8446. */
  8447. bind(effect: Effect, overrideAspectRatio?: number): void;
  8448. /**
  8449. * Clones the current image processing instance.
  8450. * @return The cloned image processing
  8451. */
  8452. clone(): ImageProcessingConfiguration;
  8453. /**
  8454. * Serializes the current image processing instance to a json representation.
  8455. * @return a JSON representation
  8456. */
  8457. serialize(): any;
  8458. /**
  8459. * Parses the image processing from a json representation.
  8460. * @param source the JSON source to parse
  8461. * @return The parsed image processing
  8462. */
  8463. static Parse(source: any): ImageProcessingConfiguration;
  8464. private static _VIGNETTEMODE_MULTIPLY;
  8465. private static _VIGNETTEMODE_OPAQUE;
  8466. /**
  8467. * Used to apply the vignette as a mix with the pixel color.
  8468. */
  8469. static get VIGNETTEMODE_MULTIPLY(): number;
  8470. /**
  8471. * Used to apply the vignette as a replacement of the pixel color.
  8472. */
  8473. static get VIGNETTEMODE_OPAQUE(): number;
  8474. }
  8475. }
  8476. declare module BABYLON {
  8477. /** @hidden */
  8478. export var postprocessVertexShader: {
  8479. name: string;
  8480. shader: string;
  8481. };
  8482. }
  8483. declare module BABYLON {
  8484. interface ThinEngine {
  8485. /**
  8486. * Creates a new render target texture
  8487. * @param size defines the size of the texture
  8488. * @param options defines the options used to create the texture
  8489. * @returns a new render target texture stored in an InternalTexture
  8490. */
  8491. createRenderTargetTexture(size: number | {
  8492. width: number;
  8493. height: number;
  8494. layers?: number;
  8495. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8496. /**
  8497. * Creates a depth stencil texture.
  8498. * This is only available in WebGL 2 or with the depth texture extension available.
  8499. * @param size The size of face edge in the texture.
  8500. * @param options The options defining the texture.
  8501. * @returns The texture
  8502. */
  8503. createDepthStencilTexture(size: number | {
  8504. width: number;
  8505. height: number;
  8506. layers?: number;
  8507. }, options: DepthTextureCreationOptions): InternalTexture;
  8508. /** @hidden */
  8509. _createDepthStencilTexture(size: number | {
  8510. width: number;
  8511. height: number;
  8512. layers?: number;
  8513. }, options: DepthTextureCreationOptions): InternalTexture;
  8514. }
  8515. }
  8516. declare module BABYLON {
  8517. /**
  8518. * Defines the kind of connection point for node based material
  8519. */
  8520. export enum NodeMaterialBlockConnectionPointTypes {
  8521. /** Float */
  8522. Float = 1,
  8523. /** Int */
  8524. Int = 2,
  8525. /** Vector2 */
  8526. Vector2 = 4,
  8527. /** Vector3 */
  8528. Vector3 = 8,
  8529. /** Vector4 */
  8530. Vector4 = 16,
  8531. /** Color3 */
  8532. Color3 = 32,
  8533. /** Color4 */
  8534. Color4 = 64,
  8535. /** Matrix */
  8536. Matrix = 128,
  8537. /** Custom object */
  8538. Object = 256,
  8539. /** Detect type based on connection */
  8540. AutoDetect = 1024,
  8541. /** Output type that will be defined by input type */
  8542. BasedOnInput = 2048
  8543. }
  8544. }
  8545. declare module BABYLON {
  8546. /**
  8547. * Enum used to define the target of a block
  8548. */
  8549. export enum NodeMaterialBlockTargets {
  8550. /** Vertex shader */
  8551. Vertex = 1,
  8552. /** Fragment shader */
  8553. Fragment = 2,
  8554. /** Neutral */
  8555. Neutral = 4,
  8556. /** Vertex and Fragment */
  8557. VertexAndFragment = 3
  8558. }
  8559. }
  8560. declare module BABYLON {
  8561. /**
  8562. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8563. */
  8564. export enum NodeMaterialBlockConnectionPointMode {
  8565. /** Value is an uniform */
  8566. Uniform = 0,
  8567. /** Value is a mesh attribute */
  8568. Attribute = 1,
  8569. /** Value is a varying between vertex and fragment shaders */
  8570. Varying = 2,
  8571. /** Mode is undefined */
  8572. Undefined = 3
  8573. }
  8574. }
  8575. declare module BABYLON {
  8576. /**
  8577. * Enum used to define system values e.g. values automatically provided by the system
  8578. */
  8579. export enum NodeMaterialSystemValues {
  8580. /** World */
  8581. World = 1,
  8582. /** View */
  8583. View = 2,
  8584. /** Projection */
  8585. Projection = 3,
  8586. /** ViewProjection */
  8587. ViewProjection = 4,
  8588. /** WorldView */
  8589. WorldView = 5,
  8590. /** WorldViewProjection */
  8591. WorldViewProjection = 6,
  8592. /** CameraPosition */
  8593. CameraPosition = 7,
  8594. /** Fog Color */
  8595. FogColor = 8,
  8596. /** Delta time */
  8597. DeltaTime = 9
  8598. }
  8599. }
  8600. declare module BABYLON {
  8601. /** Defines supported spaces */
  8602. export enum Space {
  8603. /** Local (object) space */
  8604. LOCAL = 0,
  8605. /** World space */
  8606. WORLD = 1,
  8607. /** Bone space */
  8608. BONE = 2
  8609. }
  8610. /** Defines the 3 main axes */
  8611. export class Axis {
  8612. /** X axis */
  8613. static X: Vector3;
  8614. /** Y axis */
  8615. static Y: Vector3;
  8616. /** Z axis */
  8617. static Z: Vector3;
  8618. }
  8619. }
  8620. declare module BABYLON {
  8621. /**
  8622. * Represents a camera frustum
  8623. */
  8624. export class Frustum {
  8625. /**
  8626. * Gets the planes representing the frustum
  8627. * @param transform matrix to be applied to the returned planes
  8628. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8629. */
  8630. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8631. /**
  8632. * Gets the near frustum plane transformed by the transform matrix
  8633. * @param transform transformation matrix to be applied to the resulting frustum plane
  8634. * @param frustumPlane the resuling frustum plane
  8635. */
  8636. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8637. /**
  8638. * Gets the far frustum plane transformed by the transform matrix
  8639. * @param transform transformation matrix to be applied to the resulting frustum plane
  8640. * @param frustumPlane the resuling frustum plane
  8641. */
  8642. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8643. /**
  8644. * Gets the left frustum plane transformed by the transform matrix
  8645. * @param transform transformation matrix to be applied to the resulting frustum plane
  8646. * @param frustumPlane the resuling frustum plane
  8647. */
  8648. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8649. /**
  8650. * Gets the right frustum plane transformed by the transform matrix
  8651. * @param transform transformation matrix to be applied to the resulting frustum plane
  8652. * @param frustumPlane the resuling frustum plane
  8653. */
  8654. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8655. /**
  8656. * Gets the top frustum plane transformed by the transform matrix
  8657. * @param transform transformation matrix to be applied to the resulting frustum plane
  8658. * @param frustumPlane the resuling frustum plane
  8659. */
  8660. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8661. /**
  8662. * Gets the bottom frustum plane transformed by the transform matrix
  8663. * @param transform transformation matrix to be applied to the resulting frustum plane
  8664. * @param frustumPlane the resuling frustum plane
  8665. */
  8666. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8667. /**
  8668. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8669. * @param transform transformation matrix to be applied to the resulting frustum planes
  8670. * @param frustumPlanes the resuling frustum planes
  8671. */
  8672. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8673. }
  8674. }
  8675. declare module BABYLON {
  8676. /**
  8677. * Interface for the size containing width and height
  8678. */
  8679. export interface ISize {
  8680. /**
  8681. * Width
  8682. */
  8683. width: number;
  8684. /**
  8685. * Heighht
  8686. */
  8687. height: number;
  8688. }
  8689. /**
  8690. * Size containing widht and height
  8691. */
  8692. export class Size implements ISize {
  8693. /**
  8694. * Width
  8695. */
  8696. width: number;
  8697. /**
  8698. * Height
  8699. */
  8700. height: number;
  8701. /**
  8702. * Creates a Size object from the given width and height (floats).
  8703. * @param width width of the new size
  8704. * @param height height of the new size
  8705. */
  8706. constructor(width: number, height: number);
  8707. /**
  8708. * Returns a string with the Size width and height
  8709. * @returns a string with the Size width and height
  8710. */
  8711. toString(): string;
  8712. /**
  8713. * "Size"
  8714. * @returns the string "Size"
  8715. */
  8716. getClassName(): string;
  8717. /**
  8718. * Returns the Size hash code.
  8719. * @returns a hash code for a unique width and height
  8720. */
  8721. getHashCode(): number;
  8722. /**
  8723. * Updates the current size from the given one.
  8724. * @param src the given size
  8725. */
  8726. copyFrom(src: Size): void;
  8727. /**
  8728. * Updates in place the current Size from the given floats.
  8729. * @param width width of the new size
  8730. * @param height height of the new size
  8731. * @returns the updated Size.
  8732. */
  8733. copyFromFloats(width: number, height: number): Size;
  8734. /**
  8735. * Updates in place the current Size from the given floats.
  8736. * @param width width to set
  8737. * @param height height to set
  8738. * @returns the updated Size.
  8739. */
  8740. set(width: number, height: number): Size;
  8741. /**
  8742. * Multiplies the width and height by numbers
  8743. * @param w factor to multiple the width by
  8744. * @param h factor to multiple the height by
  8745. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8746. */
  8747. multiplyByFloats(w: number, h: number): Size;
  8748. /**
  8749. * Clones the size
  8750. * @returns a new Size copied from the given one.
  8751. */
  8752. clone(): Size;
  8753. /**
  8754. * True if the current Size and the given one width and height are strictly equal.
  8755. * @param other the other size to compare against
  8756. * @returns True if the current Size and the given one width and height are strictly equal.
  8757. */
  8758. equals(other: Size): boolean;
  8759. /**
  8760. * The surface of the Size : width * height (float).
  8761. */
  8762. get surface(): number;
  8763. /**
  8764. * Create a new size of zero
  8765. * @returns a new Size set to (0.0, 0.0)
  8766. */
  8767. static Zero(): Size;
  8768. /**
  8769. * Sums the width and height of two sizes
  8770. * @param otherSize size to add to this size
  8771. * @returns a new Size set as the addition result of the current Size and the given one.
  8772. */
  8773. add(otherSize: Size): Size;
  8774. /**
  8775. * Subtracts the width and height of two
  8776. * @param otherSize size to subtract to this size
  8777. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8778. */
  8779. subtract(otherSize: Size): Size;
  8780. /**
  8781. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8782. * @param start starting size to lerp between
  8783. * @param end end size to lerp between
  8784. * @param amount amount to lerp between the start and end values
  8785. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8786. */
  8787. static Lerp(start: Size, end: Size, amount: number): Size;
  8788. }
  8789. }
  8790. declare module BABYLON {
  8791. /**
  8792. * Contains position and normal vectors for a vertex
  8793. */
  8794. export class PositionNormalVertex {
  8795. /** the position of the vertex (defaut: 0,0,0) */
  8796. position: Vector3;
  8797. /** the normal of the vertex (defaut: 0,1,0) */
  8798. normal: Vector3;
  8799. /**
  8800. * Creates a PositionNormalVertex
  8801. * @param position the position of the vertex (defaut: 0,0,0)
  8802. * @param normal the normal of the vertex (defaut: 0,1,0)
  8803. */
  8804. constructor(
  8805. /** the position of the vertex (defaut: 0,0,0) */
  8806. position?: Vector3,
  8807. /** the normal of the vertex (defaut: 0,1,0) */
  8808. normal?: Vector3);
  8809. /**
  8810. * Clones the PositionNormalVertex
  8811. * @returns the cloned PositionNormalVertex
  8812. */
  8813. clone(): PositionNormalVertex;
  8814. }
  8815. /**
  8816. * Contains position, normal and uv vectors for a vertex
  8817. */
  8818. export class PositionNormalTextureVertex {
  8819. /** the position of the vertex (defaut: 0,0,0) */
  8820. position: Vector3;
  8821. /** the normal of the vertex (defaut: 0,1,0) */
  8822. normal: Vector3;
  8823. /** the uv of the vertex (default: 0,0) */
  8824. uv: Vector2;
  8825. /**
  8826. * Creates a PositionNormalTextureVertex
  8827. * @param position the position of the vertex (defaut: 0,0,0)
  8828. * @param normal the normal of the vertex (defaut: 0,1,0)
  8829. * @param uv the uv of the vertex (default: 0,0)
  8830. */
  8831. constructor(
  8832. /** the position of the vertex (defaut: 0,0,0) */
  8833. position?: Vector3,
  8834. /** the normal of the vertex (defaut: 0,1,0) */
  8835. normal?: Vector3,
  8836. /** the uv of the vertex (default: 0,0) */
  8837. uv?: Vector2);
  8838. /**
  8839. * Clones the PositionNormalTextureVertex
  8840. * @returns the cloned PositionNormalTextureVertex
  8841. */
  8842. clone(): PositionNormalTextureVertex;
  8843. }
  8844. }
  8845. declare module BABYLON {
  8846. /**
  8847. * Enum defining the type of animations supported by InputBlock
  8848. */
  8849. export enum AnimatedInputBlockTypes {
  8850. /** No animation */
  8851. None = 0,
  8852. /** Time based animation. Will only work for floats */
  8853. Time = 1
  8854. }
  8855. }
  8856. declare module BABYLON {
  8857. /**
  8858. * Interface describing all the common properties and methods a shadow light needs to implement.
  8859. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8860. * as well as binding the different shadow properties to the effects.
  8861. */
  8862. export interface IShadowLight extends Light {
  8863. /**
  8864. * The light id in the scene (used in scene.findLighById for instance)
  8865. */
  8866. id: string;
  8867. /**
  8868. * The position the shdow will be casted from.
  8869. */
  8870. position: Vector3;
  8871. /**
  8872. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8873. */
  8874. direction: Vector3;
  8875. /**
  8876. * The transformed position. Position of the light in world space taking parenting in account.
  8877. */
  8878. transformedPosition: Vector3;
  8879. /**
  8880. * The transformed direction. Direction of the light in world space taking parenting in account.
  8881. */
  8882. transformedDirection: Vector3;
  8883. /**
  8884. * The friendly name of the light in the scene.
  8885. */
  8886. name: string;
  8887. /**
  8888. * Defines the shadow projection clipping minimum z value.
  8889. */
  8890. shadowMinZ: number;
  8891. /**
  8892. * Defines the shadow projection clipping maximum z value.
  8893. */
  8894. shadowMaxZ: number;
  8895. /**
  8896. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8897. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8898. */
  8899. computeTransformedInformation(): boolean;
  8900. /**
  8901. * Gets the scene the light belongs to.
  8902. * @returns The scene
  8903. */
  8904. getScene(): Scene;
  8905. /**
  8906. * Callback defining a custom Projection Matrix Builder.
  8907. * This can be used to override the default projection matrix computation.
  8908. */
  8909. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8910. /**
  8911. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8912. * @param matrix The materix to updated with the projection information
  8913. * @param viewMatrix The transform matrix of the light
  8914. * @param renderList The list of mesh to render in the map
  8915. * @returns The current light
  8916. */
  8917. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8918. /**
  8919. * Gets the current depth scale used in ESM.
  8920. * @returns The scale
  8921. */
  8922. getDepthScale(): number;
  8923. /**
  8924. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8925. * @returns true if a cube texture needs to be use
  8926. */
  8927. needCube(): boolean;
  8928. /**
  8929. * Detects if the projection matrix requires to be recomputed this frame.
  8930. * @returns true if it requires to be recomputed otherwise, false.
  8931. */
  8932. needProjectionMatrixCompute(): boolean;
  8933. /**
  8934. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8935. */
  8936. forceProjectionMatrixCompute(): void;
  8937. /**
  8938. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8939. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8940. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8941. */
  8942. getShadowDirection(faceIndex?: number): Vector3;
  8943. /**
  8944. * Gets the minZ used for shadow according to both the scene and the light.
  8945. * @param activeCamera The camera we are returning the min for
  8946. * @returns the depth min z
  8947. */
  8948. getDepthMinZ(activeCamera: Camera): number;
  8949. /**
  8950. * Gets the maxZ used for shadow according to both the scene and the light.
  8951. * @param activeCamera The camera we are returning the max for
  8952. * @returns the depth max z
  8953. */
  8954. getDepthMaxZ(activeCamera: Camera): number;
  8955. }
  8956. /**
  8957. * Base implementation IShadowLight
  8958. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8959. */
  8960. export abstract class ShadowLight extends Light implements IShadowLight {
  8961. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8962. protected _position: Vector3;
  8963. protected _setPosition(value: Vector3): void;
  8964. /**
  8965. * Sets the position the shadow will be casted from. Also use as the light position for both
  8966. * point and spot lights.
  8967. */
  8968. get position(): Vector3;
  8969. /**
  8970. * Sets the position the shadow will be casted from. Also use as the light position for both
  8971. * point and spot lights.
  8972. */
  8973. set position(value: Vector3);
  8974. protected _direction: Vector3;
  8975. protected _setDirection(value: Vector3): void;
  8976. /**
  8977. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8978. * Also use as the light direction on spot and directional lights.
  8979. */
  8980. get direction(): Vector3;
  8981. /**
  8982. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8983. * Also use as the light direction on spot and directional lights.
  8984. */
  8985. set direction(value: Vector3);
  8986. protected _shadowMinZ: number;
  8987. /**
  8988. * Gets the shadow projection clipping minimum z value.
  8989. */
  8990. get shadowMinZ(): number;
  8991. /**
  8992. * Sets the shadow projection clipping minimum z value.
  8993. */
  8994. set shadowMinZ(value: number);
  8995. protected _shadowMaxZ: number;
  8996. /**
  8997. * Sets the shadow projection clipping maximum z value.
  8998. */
  8999. get shadowMaxZ(): number;
  9000. /**
  9001. * Gets the shadow projection clipping maximum z value.
  9002. */
  9003. set shadowMaxZ(value: number);
  9004. /**
  9005. * Callback defining a custom Projection Matrix Builder.
  9006. * This can be used to override the default projection matrix computation.
  9007. */
  9008. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9009. /**
  9010. * The transformed position. Position of the light in world space taking parenting in account.
  9011. */
  9012. transformedPosition: Vector3;
  9013. /**
  9014. * The transformed direction. Direction of the light in world space taking parenting in account.
  9015. */
  9016. transformedDirection: Vector3;
  9017. private _needProjectionMatrixCompute;
  9018. /**
  9019. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9020. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9021. */
  9022. computeTransformedInformation(): boolean;
  9023. /**
  9024. * Return the depth scale used for the shadow map.
  9025. * @returns the depth scale.
  9026. */
  9027. getDepthScale(): number;
  9028. /**
  9029. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9030. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9031. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9032. */
  9033. getShadowDirection(faceIndex?: number): Vector3;
  9034. /**
  9035. * Returns the ShadowLight absolute position in the World.
  9036. * @returns the position vector in world space
  9037. */
  9038. getAbsolutePosition(): Vector3;
  9039. /**
  9040. * Sets the ShadowLight direction toward the passed target.
  9041. * @param target The point to target in local space
  9042. * @returns the updated ShadowLight direction
  9043. */
  9044. setDirectionToTarget(target: Vector3): Vector3;
  9045. /**
  9046. * Returns the light rotation in euler definition.
  9047. * @returns the x y z rotation in local space.
  9048. */
  9049. getRotation(): Vector3;
  9050. /**
  9051. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9052. * @returns true if a cube texture needs to be use
  9053. */
  9054. needCube(): boolean;
  9055. /**
  9056. * Detects if the projection matrix requires to be recomputed this frame.
  9057. * @returns true if it requires to be recomputed otherwise, false.
  9058. */
  9059. needProjectionMatrixCompute(): boolean;
  9060. /**
  9061. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9062. */
  9063. forceProjectionMatrixCompute(): void;
  9064. /** @hidden */
  9065. _initCache(): void;
  9066. /** @hidden */
  9067. _isSynchronized(): boolean;
  9068. /**
  9069. * Computes the world matrix of the node
  9070. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9071. * @returns the world matrix
  9072. */
  9073. computeWorldMatrix(force?: boolean): Matrix;
  9074. /**
  9075. * Gets the minZ used for shadow according to both the scene and the light.
  9076. * @param activeCamera The camera we are returning the min for
  9077. * @returns the depth min z
  9078. */
  9079. getDepthMinZ(activeCamera: Camera): number;
  9080. /**
  9081. * Gets the maxZ used for shadow according to both the scene and the light.
  9082. * @param activeCamera The camera we are returning the max for
  9083. * @returns the depth max z
  9084. */
  9085. getDepthMaxZ(activeCamera: Camera): number;
  9086. /**
  9087. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9088. * @param matrix The materix to updated with the projection information
  9089. * @param viewMatrix The transform matrix of the light
  9090. * @param renderList The list of mesh to render in the map
  9091. * @returns The current light
  9092. */
  9093. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9094. }
  9095. }
  9096. declare module BABYLON {
  9097. /** @hidden */
  9098. export var packingFunctions: {
  9099. name: string;
  9100. shader: string;
  9101. };
  9102. }
  9103. declare module BABYLON {
  9104. /** @hidden */
  9105. export var bayerDitherFunctions: {
  9106. name: string;
  9107. shader: string;
  9108. };
  9109. }
  9110. declare module BABYLON {
  9111. /** @hidden */
  9112. export var shadowMapFragmentDeclaration: {
  9113. name: string;
  9114. shader: string;
  9115. };
  9116. }
  9117. declare module BABYLON {
  9118. /** @hidden */
  9119. export var clipPlaneFragmentDeclaration: {
  9120. name: string;
  9121. shader: string;
  9122. };
  9123. }
  9124. declare module BABYLON {
  9125. /** @hidden */
  9126. export var clipPlaneFragment: {
  9127. name: string;
  9128. shader: string;
  9129. };
  9130. }
  9131. declare module BABYLON {
  9132. /** @hidden */
  9133. export var shadowMapFragment: {
  9134. name: string;
  9135. shader: string;
  9136. };
  9137. }
  9138. declare module BABYLON {
  9139. /** @hidden */
  9140. export var shadowMapPixelShader: {
  9141. name: string;
  9142. shader: string;
  9143. };
  9144. }
  9145. declare module BABYLON {
  9146. /** @hidden */
  9147. export var bonesDeclaration: {
  9148. name: string;
  9149. shader: string;
  9150. };
  9151. }
  9152. declare module BABYLON {
  9153. /** @hidden */
  9154. export var morphTargetsVertexGlobalDeclaration: {
  9155. name: string;
  9156. shader: string;
  9157. };
  9158. }
  9159. declare module BABYLON {
  9160. /** @hidden */
  9161. export var morphTargetsVertexDeclaration: {
  9162. name: string;
  9163. shader: string;
  9164. };
  9165. }
  9166. declare module BABYLON {
  9167. /** @hidden */
  9168. export var instancesDeclaration: {
  9169. name: string;
  9170. shader: string;
  9171. };
  9172. }
  9173. declare module BABYLON {
  9174. /** @hidden */
  9175. export var helperFunctions: {
  9176. name: string;
  9177. shader: string;
  9178. };
  9179. }
  9180. declare module BABYLON {
  9181. /** @hidden */
  9182. export var shadowMapVertexDeclaration: {
  9183. name: string;
  9184. shader: string;
  9185. };
  9186. }
  9187. declare module BABYLON {
  9188. /** @hidden */
  9189. export var clipPlaneVertexDeclaration: {
  9190. name: string;
  9191. shader: string;
  9192. };
  9193. }
  9194. declare module BABYLON {
  9195. /** @hidden */
  9196. export var morphTargetsVertex: {
  9197. name: string;
  9198. shader: string;
  9199. };
  9200. }
  9201. declare module BABYLON {
  9202. /** @hidden */
  9203. export var instancesVertex: {
  9204. name: string;
  9205. shader: string;
  9206. };
  9207. }
  9208. declare module BABYLON {
  9209. /** @hidden */
  9210. export var bonesVertex: {
  9211. name: string;
  9212. shader: string;
  9213. };
  9214. }
  9215. declare module BABYLON {
  9216. /** @hidden */
  9217. export var shadowMapVertexNormalBias: {
  9218. name: string;
  9219. shader: string;
  9220. };
  9221. }
  9222. declare module BABYLON {
  9223. /** @hidden */
  9224. export var shadowMapVertexMetric: {
  9225. name: string;
  9226. shader: string;
  9227. };
  9228. }
  9229. declare module BABYLON {
  9230. /** @hidden */
  9231. export var clipPlaneVertex: {
  9232. name: string;
  9233. shader: string;
  9234. };
  9235. }
  9236. declare module BABYLON {
  9237. /** @hidden */
  9238. export var shadowMapVertexShader: {
  9239. name: string;
  9240. shader: string;
  9241. };
  9242. }
  9243. declare module BABYLON {
  9244. /** @hidden */
  9245. export var depthBoxBlurPixelShader: {
  9246. name: string;
  9247. shader: string;
  9248. };
  9249. }
  9250. declare module BABYLON {
  9251. /** @hidden */
  9252. export var shadowMapFragmentSoftTransparentShadow: {
  9253. name: string;
  9254. shader: string;
  9255. };
  9256. }
  9257. declare module BABYLON {
  9258. /**
  9259. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9260. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9261. */
  9262. export class EffectFallbacks implements IEffectFallbacks {
  9263. private _defines;
  9264. private _currentRank;
  9265. private _maxRank;
  9266. private _mesh;
  9267. /**
  9268. * Removes the fallback from the bound mesh.
  9269. */
  9270. unBindMesh(): void;
  9271. /**
  9272. * Adds a fallback on the specified property.
  9273. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9274. * @param define The name of the define in the shader
  9275. */
  9276. addFallback(rank: number, define: string): void;
  9277. /**
  9278. * Sets the mesh to use CPU skinning when needing to fallback.
  9279. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9280. * @param mesh The mesh to use the fallbacks.
  9281. */
  9282. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9283. /**
  9284. * Checks to see if more fallbacks are still availible.
  9285. */
  9286. get hasMoreFallbacks(): boolean;
  9287. /**
  9288. * Removes the defines that should be removed when falling back.
  9289. * @param currentDefines defines the current define statements for the shader.
  9290. * @param effect defines the current effect we try to compile
  9291. * @returns The resulting defines with defines of the current rank removed.
  9292. */
  9293. reduce(currentDefines: string, effect: Effect): string;
  9294. }
  9295. }
  9296. declare module BABYLON {
  9297. /**
  9298. * Interface used to define Action
  9299. */
  9300. export interface IAction {
  9301. /**
  9302. * Trigger for the action
  9303. */
  9304. trigger: number;
  9305. /** Options of the trigger */
  9306. triggerOptions: any;
  9307. /**
  9308. * Gets the trigger parameters
  9309. * @returns the trigger parameters
  9310. */
  9311. getTriggerParameter(): any;
  9312. /**
  9313. * Internal only - executes current action event
  9314. * @hidden
  9315. */
  9316. _executeCurrent(evt?: ActionEvent): void;
  9317. /**
  9318. * Serialize placeholder for child classes
  9319. * @param parent of child
  9320. * @returns the serialized object
  9321. */
  9322. serialize(parent: any): any;
  9323. /**
  9324. * Internal only
  9325. * @hidden
  9326. */
  9327. _prepare(): void;
  9328. /**
  9329. * Internal only - manager for action
  9330. * @hidden
  9331. */
  9332. _actionManager: AbstractActionManager;
  9333. /**
  9334. * Adds action to chain of actions, may be a DoNothingAction
  9335. * @param action defines the next action to execute
  9336. * @returns The action passed in
  9337. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9338. */
  9339. then(action: IAction): IAction;
  9340. }
  9341. /**
  9342. * The action to be carried out following a trigger
  9343. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9344. */
  9345. export class Action implements IAction {
  9346. /** the trigger, with or without parameters, for the action */
  9347. triggerOptions: any;
  9348. /**
  9349. * Trigger for the action
  9350. */
  9351. trigger: number;
  9352. /**
  9353. * Internal only - manager for action
  9354. * @hidden
  9355. */
  9356. _actionManager: ActionManager;
  9357. private _nextActiveAction;
  9358. private _child;
  9359. private _condition?;
  9360. private _triggerParameter;
  9361. /**
  9362. * An event triggered prior to action being executed.
  9363. */
  9364. onBeforeExecuteObservable: Observable<Action>;
  9365. /**
  9366. * Creates a new Action
  9367. * @param triggerOptions the trigger, with or without parameters, for the action
  9368. * @param condition an optional determinant of action
  9369. */
  9370. constructor(
  9371. /** the trigger, with or without parameters, for the action */
  9372. triggerOptions: any, condition?: Condition);
  9373. /**
  9374. * Internal only
  9375. * @hidden
  9376. */
  9377. _prepare(): void;
  9378. /**
  9379. * Gets the trigger parameters
  9380. * @returns the trigger parameters
  9381. */
  9382. getTriggerParameter(): any;
  9383. /**
  9384. * Internal only - executes current action event
  9385. * @hidden
  9386. */
  9387. _executeCurrent(evt?: ActionEvent): void;
  9388. /**
  9389. * Execute placeholder for child classes
  9390. * @param evt optional action event
  9391. */
  9392. execute(evt?: ActionEvent): void;
  9393. /**
  9394. * Skips to next active action
  9395. */
  9396. skipToNextActiveAction(): void;
  9397. /**
  9398. * Adds action to chain of actions, may be a DoNothingAction
  9399. * @param action defines the next action to execute
  9400. * @returns The action passed in
  9401. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9402. */
  9403. then(action: Action): Action;
  9404. /**
  9405. * Internal only
  9406. * @hidden
  9407. */
  9408. _getProperty(propertyPath: string): string;
  9409. /**
  9410. * Internal only
  9411. * @hidden
  9412. */
  9413. _getEffectiveTarget(target: any, propertyPath: string): any;
  9414. /**
  9415. * Serialize placeholder for child classes
  9416. * @param parent of child
  9417. * @returns the serialized object
  9418. */
  9419. serialize(parent: any): any;
  9420. /**
  9421. * Internal only called by serialize
  9422. * @hidden
  9423. */
  9424. protected _serialize(serializedAction: any, parent?: any): any;
  9425. /**
  9426. * Internal only
  9427. * @hidden
  9428. */
  9429. static _SerializeValueAsString: (value: any) => string;
  9430. /**
  9431. * Internal only
  9432. * @hidden
  9433. */
  9434. static _GetTargetProperty: (target: Scene | Node) => {
  9435. name: string;
  9436. targetType: string;
  9437. value: string;
  9438. };
  9439. }
  9440. }
  9441. declare module BABYLON {
  9442. /**
  9443. * A Condition applied to an Action
  9444. */
  9445. export class Condition {
  9446. /**
  9447. * Internal only - manager for action
  9448. * @hidden
  9449. */
  9450. _actionManager: ActionManager;
  9451. /**
  9452. * Internal only
  9453. * @hidden
  9454. */
  9455. _evaluationId: number;
  9456. /**
  9457. * Internal only
  9458. * @hidden
  9459. */
  9460. _currentResult: boolean;
  9461. /**
  9462. * Creates a new Condition
  9463. * @param actionManager the manager of the action the condition is applied to
  9464. */
  9465. constructor(actionManager: ActionManager);
  9466. /**
  9467. * Check if the current condition is valid
  9468. * @returns a boolean
  9469. */
  9470. isValid(): boolean;
  9471. /**
  9472. * Internal only
  9473. * @hidden
  9474. */
  9475. _getProperty(propertyPath: string): string;
  9476. /**
  9477. * Internal only
  9478. * @hidden
  9479. */
  9480. _getEffectiveTarget(target: any, propertyPath: string): any;
  9481. /**
  9482. * Serialize placeholder for child classes
  9483. * @returns the serialized object
  9484. */
  9485. serialize(): any;
  9486. /**
  9487. * Internal only
  9488. * @hidden
  9489. */
  9490. protected _serialize(serializedCondition: any): any;
  9491. }
  9492. /**
  9493. * Defines specific conditional operators as extensions of Condition
  9494. */
  9495. export class ValueCondition extends Condition {
  9496. /** path to specify the property of the target the conditional operator uses */
  9497. propertyPath: string;
  9498. /** the value compared by the conditional operator against the current value of the property */
  9499. value: any;
  9500. /** the conditional operator, default ValueCondition.IsEqual */
  9501. operator: number;
  9502. /**
  9503. * Internal only
  9504. * @hidden
  9505. */
  9506. private static _IsEqual;
  9507. /**
  9508. * Internal only
  9509. * @hidden
  9510. */
  9511. private static _IsDifferent;
  9512. /**
  9513. * Internal only
  9514. * @hidden
  9515. */
  9516. private static _IsGreater;
  9517. /**
  9518. * Internal only
  9519. * @hidden
  9520. */
  9521. private static _IsLesser;
  9522. /**
  9523. * returns the number for IsEqual
  9524. */
  9525. static get IsEqual(): number;
  9526. /**
  9527. * Returns the number for IsDifferent
  9528. */
  9529. static get IsDifferent(): number;
  9530. /**
  9531. * Returns the number for IsGreater
  9532. */
  9533. static get IsGreater(): number;
  9534. /**
  9535. * Returns the number for IsLesser
  9536. */
  9537. static get IsLesser(): number;
  9538. /**
  9539. * Internal only The action manager for the condition
  9540. * @hidden
  9541. */
  9542. _actionManager: ActionManager;
  9543. /**
  9544. * Internal only
  9545. * @hidden
  9546. */
  9547. private _target;
  9548. /**
  9549. * Internal only
  9550. * @hidden
  9551. */
  9552. private _effectiveTarget;
  9553. /**
  9554. * Internal only
  9555. * @hidden
  9556. */
  9557. private _property;
  9558. /**
  9559. * Creates a new ValueCondition
  9560. * @param actionManager manager for the action the condition applies to
  9561. * @param target for the action
  9562. * @param propertyPath path to specify the property of the target the conditional operator uses
  9563. * @param value the value compared by the conditional operator against the current value of the property
  9564. * @param operator the conditional operator, default ValueCondition.IsEqual
  9565. */
  9566. constructor(actionManager: ActionManager, target: any,
  9567. /** path to specify the property of the target the conditional operator uses */
  9568. propertyPath: string,
  9569. /** the value compared by the conditional operator against the current value of the property */
  9570. value: any,
  9571. /** the conditional operator, default ValueCondition.IsEqual */
  9572. operator?: number);
  9573. /**
  9574. * Compares the given value with the property value for the specified conditional operator
  9575. * @returns the result of the comparison
  9576. */
  9577. isValid(): boolean;
  9578. /**
  9579. * Serialize the ValueCondition into a JSON compatible object
  9580. * @returns serialization object
  9581. */
  9582. serialize(): any;
  9583. /**
  9584. * Gets the name of the conditional operator for the ValueCondition
  9585. * @param operator the conditional operator
  9586. * @returns the name
  9587. */
  9588. static GetOperatorName(operator: number): string;
  9589. }
  9590. /**
  9591. * Defines a predicate condition as an extension of Condition
  9592. */
  9593. export class PredicateCondition extends Condition {
  9594. /** defines the predicate function used to validate the condition */
  9595. predicate: () => boolean;
  9596. /**
  9597. * Internal only - manager for action
  9598. * @hidden
  9599. */
  9600. _actionManager: ActionManager;
  9601. /**
  9602. * Creates a new PredicateCondition
  9603. * @param actionManager manager for the action the condition applies to
  9604. * @param predicate defines the predicate function used to validate the condition
  9605. */
  9606. constructor(actionManager: ActionManager,
  9607. /** defines the predicate function used to validate the condition */
  9608. predicate: () => boolean);
  9609. /**
  9610. * @returns the validity of the predicate condition
  9611. */
  9612. isValid(): boolean;
  9613. }
  9614. /**
  9615. * Defines a state condition as an extension of Condition
  9616. */
  9617. export class StateCondition extends Condition {
  9618. /** Value to compare with target state */
  9619. value: string;
  9620. /**
  9621. * Internal only - manager for action
  9622. * @hidden
  9623. */
  9624. _actionManager: ActionManager;
  9625. /**
  9626. * Internal only
  9627. * @hidden
  9628. */
  9629. private _target;
  9630. /**
  9631. * Creates a new StateCondition
  9632. * @param actionManager manager for the action the condition applies to
  9633. * @param target of the condition
  9634. * @param value to compare with target state
  9635. */
  9636. constructor(actionManager: ActionManager, target: any,
  9637. /** Value to compare with target state */
  9638. value: string);
  9639. /**
  9640. * Gets a boolean indicating if the current condition is met
  9641. * @returns the validity of the state
  9642. */
  9643. isValid(): boolean;
  9644. /**
  9645. * Serialize the StateCondition into a JSON compatible object
  9646. * @returns serialization object
  9647. */
  9648. serialize(): any;
  9649. }
  9650. }
  9651. declare module BABYLON {
  9652. /**
  9653. * This defines an action responsible to toggle a boolean once triggered.
  9654. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9655. */
  9656. export class SwitchBooleanAction extends Action {
  9657. /**
  9658. * The path to the boolean property in the target object
  9659. */
  9660. propertyPath: string;
  9661. private _target;
  9662. private _effectiveTarget;
  9663. private _property;
  9664. /**
  9665. * Instantiate the action
  9666. * @param triggerOptions defines the trigger options
  9667. * @param target defines the object containing the boolean
  9668. * @param propertyPath defines the path to the boolean property in the target object
  9669. * @param condition defines the trigger related conditions
  9670. */
  9671. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9672. /** @hidden */
  9673. _prepare(): void;
  9674. /**
  9675. * Execute the action toggle the boolean value.
  9676. */
  9677. execute(): void;
  9678. /**
  9679. * Serializes the actions and its related information.
  9680. * @param parent defines the object to serialize in
  9681. * @returns the serialized object
  9682. */
  9683. serialize(parent: any): any;
  9684. }
  9685. /**
  9686. * This defines an action responsible to set a the state field of the target
  9687. * to a desired value once triggered.
  9688. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9689. */
  9690. export class SetStateAction extends Action {
  9691. /**
  9692. * The value to store in the state field.
  9693. */
  9694. value: string;
  9695. private _target;
  9696. /**
  9697. * Instantiate the action
  9698. * @param triggerOptions defines the trigger options
  9699. * @param target defines the object containing the state property
  9700. * @param value defines the value to store in the state field
  9701. * @param condition defines the trigger related conditions
  9702. */
  9703. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9704. /**
  9705. * Execute the action and store the value on the target state property.
  9706. */
  9707. execute(): void;
  9708. /**
  9709. * Serializes the actions and its related information.
  9710. * @param parent defines the object to serialize in
  9711. * @returns the serialized object
  9712. */
  9713. serialize(parent: any): any;
  9714. }
  9715. /**
  9716. * This defines an action responsible to set a property of the target
  9717. * to a desired value once triggered.
  9718. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9719. */
  9720. export class SetValueAction extends Action {
  9721. /**
  9722. * The path of the property to set in the target.
  9723. */
  9724. propertyPath: string;
  9725. /**
  9726. * The value to set in the property
  9727. */
  9728. value: any;
  9729. private _target;
  9730. private _effectiveTarget;
  9731. private _property;
  9732. /**
  9733. * Instantiate the action
  9734. * @param triggerOptions defines the trigger options
  9735. * @param target defines the object containing the property
  9736. * @param propertyPath defines the path of the property to set in the target
  9737. * @param value defines the value to set in the property
  9738. * @param condition defines the trigger related conditions
  9739. */
  9740. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9741. /** @hidden */
  9742. _prepare(): void;
  9743. /**
  9744. * Execute the action and set the targetted property to the desired value.
  9745. */
  9746. execute(): void;
  9747. /**
  9748. * Serializes the actions and its related information.
  9749. * @param parent defines the object to serialize in
  9750. * @returns the serialized object
  9751. */
  9752. serialize(parent: any): any;
  9753. }
  9754. /**
  9755. * This defines an action responsible to increment the target value
  9756. * to a desired value once triggered.
  9757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9758. */
  9759. export class IncrementValueAction extends Action {
  9760. /**
  9761. * The path of the property to increment in the target.
  9762. */
  9763. propertyPath: string;
  9764. /**
  9765. * The value we should increment the property by.
  9766. */
  9767. value: any;
  9768. private _target;
  9769. private _effectiveTarget;
  9770. private _property;
  9771. /**
  9772. * Instantiate the action
  9773. * @param triggerOptions defines the trigger options
  9774. * @param target defines the object containing the property
  9775. * @param propertyPath defines the path of the property to increment in the target
  9776. * @param value defines the value value we should increment the property by
  9777. * @param condition defines the trigger related conditions
  9778. */
  9779. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9780. /** @hidden */
  9781. _prepare(): void;
  9782. /**
  9783. * Execute the action and increment the target of the value amount.
  9784. */
  9785. execute(): void;
  9786. /**
  9787. * Serializes the actions and its related information.
  9788. * @param parent defines the object to serialize in
  9789. * @returns the serialized object
  9790. */
  9791. serialize(parent: any): any;
  9792. }
  9793. /**
  9794. * This defines an action responsible to start an animation once triggered.
  9795. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9796. */
  9797. export class PlayAnimationAction extends Action {
  9798. /**
  9799. * Where the animation should start (animation frame)
  9800. */
  9801. from: number;
  9802. /**
  9803. * Where the animation should stop (animation frame)
  9804. */
  9805. to: number;
  9806. /**
  9807. * Define if the animation should loop or stop after the first play.
  9808. */
  9809. loop?: boolean;
  9810. private _target;
  9811. /**
  9812. * Instantiate the action
  9813. * @param triggerOptions defines the trigger options
  9814. * @param target defines the target animation or animation name
  9815. * @param from defines from where the animation should start (animation frame)
  9816. * @param end defines where the animation should stop (animation frame)
  9817. * @param loop defines if the animation should loop or stop after the first play
  9818. * @param condition defines the trigger related conditions
  9819. */
  9820. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9821. /** @hidden */
  9822. _prepare(): void;
  9823. /**
  9824. * Execute the action and play the animation.
  9825. */
  9826. execute(): void;
  9827. /**
  9828. * Serializes the actions and its related information.
  9829. * @param parent defines the object to serialize in
  9830. * @returns the serialized object
  9831. */
  9832. serialize(parent: any): any;
  9833. }
  9834. /**
  9835. * This defines an action responsible to stop an animation once triggered.
  9836. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9837. */
  9838. export class StopAnimationAction extends Action {
  9839. private _target;
  9840. /**
  9841. * Instantiate the action
  9842. * @param triggerOptions defines the trigger options
  9843. * @param target defines the target animation or animation name
  9844. * @param condition defines the trigger related conditions
  9845. */
  9846. constructor(triggerOptions: any, target: any, condition?: Condition);
  9847. /** @hidden */
  9848. _prepare(): void;
  9849. /**
  9850. * Execute the action and stop the animation.
  9851. */
  9852. execute(): void;
  9853. /**
  9854. * Serializes the actions and its related information.
  9855. * @param parent defines the object to serialize in
  9856. * @returns the serialized object
  9857. */
  9858. serialize(parent: any): any;
  9859. }
  9860. /**
  9861. * This defines an action responsible that does nothing once triggered.
  9862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9863. */
  9864. export class DoNothingAction extends Action {
  9865. /**
  9866. * Instantiate the action
  9867. * @param triggerOptions defines the trigger options
  9868. * @param condition defines the trigger related conditions
  9869. */
  9870. constructor(triggerOptions?: any, condition?: Condition);
  9871. /**
  9872. * Execute the action and do nothing.
  9873. */
  9874. execute(): void;
  9875. /**
  9876. * Serializes the actions and its related information.
  9877. * @param parent defines the object to serialize in
  9878. * @returns the serialized object
  9879. */
  9880. serialize(parent: any): any;
  9881. }
  9882. /**
  9883. * This defines an action responsible to trigger several actions once triggered.
  9884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9885. */
  9886. export class CombineAction extends Action {
  9887. /**
  9888. * The list of aggregated animations to run.
  9889. */
  9890. children: Action[];
  9891. /**
  9892. * Instantiate the action
  9893. * @param triggerOptions defines the trigger options
  9894. * @param children defines the list of aggregated animations to run
  9895. * @param condition defines the trigger related conditions
  9896. */
  9897. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  9898. /** @hidden */
  9899. _prepare(): void;
  9900. /**
  9901. * Execute the action and executes all the aggregated actions.
  9902. */
  9903. execute(evt: ActionEvent): void;
  9904. /**
  9905. * Serializes the actions and its related information.
  9906. * @param parent defines the object to serialize in
  9907. * @returns the serialized object
  9908. */
  9909. serialize(parent: any): any;
  9910. }
  9911. /**
  9912. * This defines an action responsible to run code (external event) once triggered.
  9913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9914. */
  9915. export class ExecuteCodeAction extends Action {
  9916. /**
  9917. * The callback function to run.
  9918. */
  9919. func: (evt: ActionEvent) => void;
  9920. /**
  9921. * Instantiate the action
  9922. * @param triggerOptions defines the trigger options
  9923. * @param func defines the callback function to run
  9924. * @param condition defines the trigger related conditions
  9925. */
  9926. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  9927. /**
  9928. * Execute the action and run the attached code.
  9929. */
  9930. execute(evt: ActionEvent): void;
  9931. }
  9932. /**
  9933. * This defines an action responsible to set the parent property of the target once triggered.
  9934. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9935. */
  9936. export class SetParentAction extends Action {
  9937. private _parent;
  9938. private _target;
  9939. /**
  9940. * Instantiate the action
  9941. * @param triggerOptions defines the trigger options
  9942. * @param target defines the target containing the parent property
  9943. * @param parent defines from where the animation should start (animation frame)
  9944. * @param condition defines the trigger related conditions
  9945. */
  9946. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  9947. /** @hidden */
  9948. _prepare(): void;
  9949. /**
  9950. * Execute the action and set the parent property.
  9951. */
  9952. execute(): void;
  9953. /**
  9954. * Serializes the actions and its related information.
  9955. * @param parent defines the object to serialize in
  9956. * @returns the serialized object
  9957. */
  9958. serialize(parent: any): any;
  9959. }
  9960. }
  9961. declare module BABYLON {
  9962. /**
  9963. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  9964. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  9965. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9966. */
  9967. export class ActionManager extends AbstractActionManager {
  9968. /**
  9969. * Nothing
  9970. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9971. */
  9972. static readonly NothingTrigger: number;
  9973. /**
  9974. * On pick
  9975. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9976. */
  9977. static readonly OnPickTrigger: number;
  9978. /**
  9979. * On left pick
  9980. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9981. */
  9982. static readonly OnLeftPickTrigger: number;
  9983. /**
  9984. * On right pick
  9985. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9986. */
  9987. static readonly OnRightPickTrigger: number;
  9988. /**
  9989. * On center pick
  9990. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9991. */
  9992. static readonly OnCenterPickTrigger: number;
  9993. /**
  9994. * On pick down
  9995. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9996. */
  9997. static readonly OnPickDownTrigger: number;
  9998. /**
  9999. * On double pick
  10000. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10001. */
  10002. static readonly OnDoublePickTrigger: number;
  10003. /**
  10004. * On pick up
  10005. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10006. */
  10007. static readonly OnPickUpTrigger: number;
  10008. /**
  10009. * On pick out.
  10010. * This trigger will only be raised if you also declared a OnPickDown
  10011. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10012. */
  10013. static readonly OnPickOutTrigger: number;
  10014. /**
  10015. * On long press
  10016. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10017. */
  10018. static readonly OnLongPressTrigger: number;
  10019. /**
  10020. * On pointer over
  10021. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10022. */
  10023. static readonly OnPointerOverTrigger: number;
  10024. /**
  10025. * On pointer out
  10026. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10027. */
  10028. static readonly OnPointerOutTrigger: number;
  10029. /**
  10030. * On every frame
  10031. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10032. */
  10033. static readonly OnEveryFrameTrigger: number;
  10034. /**
  10035. * On intersection enter
  10036. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10037. */
  10038. static readonly OnIntersectionEnterTrigger: number;
  10039. /**
  10040. * On intersection exit
  10041. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10042. */
  10043. static readonly OnIntersectionExitTrigger: number;
  10044. /**
  10045. * On key down
  10046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10047. */
  10048. static readonly OnKeyDownTrigger: number;
  10049. /**
  10050. * On key up
  10051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10052. */
  10053. static readonly OnKeyUpTrigger: number;
  10054. private _scene;
  10055. /**
  10056. * Creates a new action manager
  10057. * @param scene defines the hosting scene
  10058. */
  10059. constructor(scene: Scene);
  10060. /**
  10061. * Releases all associated resources
  10062. */
  10063. dispose(): void;
  10064. /**
  10065. * Gets hosting scene
  10066. * @returns the hosting scene
  10067. */
  10068. getScene(): Scene;
  10069. /**
  10070. * Does this action manager handles actions of any of the given triggers
  10071. * @param triggers defines the triggers to be tested
  10072. * @return a boolean indicating whether one (or more) of the triggers is handled
  10073. */
  10074. hasSpecificTriggers(triggers: number[]): boolean;
  10075. /**
  10076. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10077. * speed.
  10078. * @param triggerA defines the trigger to be tested
  10079. * @param triggerB defines the trigger to be tested
  10080. * @return a boolean indicating whether one (or more) of the triggers is handled
  10081. */
  10082. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10083. /**
  10084. * Does this action manager handles actions of a given trigger
  10085. * @param trigger defines the trigger to be tested
  10086. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10087. * @return whether the trigger is handled
  10088. */
  10089. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10090. /**
  10091. * Does this action manager has pointer triggers
  10092. */
  10093. get hasPointerTriggers(): boolean;
  10094. /**
  10095. * Does this action manager has pick triggers
  10096. */
  10097. get hasPickTriggers(): boolean;
  10098. /**
  10099. * Registers an action to this action manager
  10100. * @param action defines the action to be registered
  10101. * @return the action amended (prepared) after registration
  10102. */
  10103. registerAction(action: IAction): Nullable<IAction>;
  10104. /**
  10105. * Unregisters an action to this action manager
  10106. * @param action defines the action to be unregistered
  10107. * @return a boolean indicating whether the action has been unregistered
  10108. */
  10109. unregisterAction(action: IAction): Boolean;
  10110. /**
  10111. * Process a specific trigger
  10112. * @param trigger defines the trigger to process
  10113. * @param evt defines the event details to be processed
  10114. */
  10115. processTrigger(trigger: number, evt?: IActionEvent): void;
  10116. /** @hidden */
  10117. _getEffectiveTarget(target: any, propertyPath: string): any;
  10118. /** @hidden */
  10119. _getProperty(propertyPath: string): string;
  10120. /**
  10121. * Serialize this manager to a JSON object
  10122. * @param name defines the property name to store this manager
  10123. * @returns a JSON representation of this manager
  10124. */
  10125. serialize(name: string): any;
  10126. /**
  10127. * Creates a new ActionManager from a JSON data
  10128. * @param parsedActions defines the JSON data to read from
  10129. * @param object defines the hosting mesh
  10130. * @param scene defines the hosting scene
  10131. */
  10132. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10133. /**
  10134. * Get a trigger name by index
  10135. * @param trigger defines the trigger index
  10136. * @returns a trigger name
  10137. */
  10138. static GetTriggerName(trigger: number): string;
  10139. }
  10140. }
  10141. declare module BABYLON {
  10142. /**
  10143. * Class used to represent a sprite
  10144. * @see http://doc.babylonjs.com/babylon101/sprites
  10145. */
  10146. export class Sprite implements IAnimatable {
  10147. /** defines the name */
  10148. name: string;
  10149. /** Gets or sets the current world position */
  10150. position: Vector3;
  10151. /** Gets or sets the main color */
  10152. color: Color4;
  10153. /** Gets or sets the width */
  10154. width: number;
  10155. /** Gets or sets the height */
  10156. height: number;
  10157. /** Gets or sets rotation angle */
  10158. angle: number;
  10159. /** Gets or sets the cell index in the sprite sheet */
  10160. cellIndex: number;
  10161. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10162. cellRef: string;
  10163. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10164. invertU: boolean;
  10165. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10166. invertV: boolean;
  10167. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10168. disposeWhenFinishedAnimating: boolean;
  10169. /** Gets the list of attached animations */
  10170. animations: Nullable<Array<Animation>>;
  10171. /** Gets or sets a boolean indicating if the sprite can be picked */
  10172. isPickable: boolean;
  10173. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10174. useAlphaForPicking: boolean;
  10175. /** @hidden */
  10176. _xOffset: number;
  10177. /** @hidden */
  10178. _yOffset: number;
  10179. /** @hidden */
  10180. _xSize: number;
  10181. /** @hidden */
  10182. _ySize: number;
  10183. /**
  10184. * Gets or sets the associated action manager
  10185. */
  10186. actionManager: Nullable<ActionManager>;
  10187. /**
  10188. * An event triggered when the control has been disposed
  10189. */
  10190. onDisposeObservable: Observable<Sprite>;
  10191. private _animationStarted;
  10192. private _loopAnimation;
  10193. private _fromIndex;
  10194. private _toIndex;
  10195. private _delay;
  10196. private _direction;
  10197. private _manager;
  10198. private _time;
  10199. private _onAnimationEnd;
  10200. /**
  10201. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10202. */
  10203. isVisible: boolean;
  10204. /**
  10205. * Gets or sets the sprite size
  10206. */
  10207. get size(): number;
  10208. set size(value: number);
  10209. /**
  10210. * Returns a boolean indicating if the animation is started
  10211. */
  10212. get animationStarted(): boolean;
  10213. /**
  10214. * Gets or sets the unique id of the sprite
  10215. */
  10216. uniqueId: number;
  10217. /**
  10218. * Gets the manager of this sprite
  10219. */
  10220. get manager(): ISpriteManager;
  10221. /**
  10222. * Creates a new Sprite
  10223. * @param name defines the name
  10224. * @param manager defines the manager
  10225. */
  10226. constructor(
  10227. /** defines the name */
  10228. name: string, manager: ISpriteManager);
  10229. /**
  10230. * Returns the string "Sprite"
  10231. * @returns "Sprite"
  10232. */
  10233. getClassName(): string;
  10234. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10235. get fromIndex(): number;
  10236. set fromIndex(value: number);
  10237. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10238. get toIndex(): number;
  10239. set toIndex(value: number);
  10240. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10241. get loopAnimation(): boolean;
  10242. set loopAnimation(value: boolean);
  10243. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10244. get delay(): number;
  10245. set delay(value: number);
  10246. /**
  10247. * Starts an animation
  10248. * @param from defines the initial key
  10249. * @param to defines the end key
  10250. * @param loop defines if the animation must loop
  10251. * @param delay defines the start delay (in ms)
  10252. * @param onAnimationEnd defines a callback to call when animation ends
  10253. */
  10254. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10255. /** Stops current animation (if any) */
  10256. stopAnimation(): void;
  10257. /** @hidden */
  10258. _animate(deltaTime: number): void;
  10259. /** Release associated resources */
  10260. dispose(): void;
  10261. /**
  10262. * Serializes the sprite to a JSON object
  10263. * @returns the JSON object
  10264. */
  10265. serialize(): any;
  10266. /**
  10267. * Parses a JSON object to create a new sprite
  10268. * @param parsedSprite The JSON object to parse
  10269. * @param manager defines the hosting manager
  10270. * @returns the new sprite
  10271. */
  10272. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10273. }
  10274. }
  10275. declare module BABYLON {
  10276. /**
  10277. * Information about the result of picking within a scene
  10278. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10279. */
  10280. export class PickingInfo {
  10281. /** @hidden */
  10282. _pickingUnavailable: boolean;
  10283. /**
  10284. * If the pick collided with an object
  10285. */
  10286. hit: boolean;
  10287. /**
  10288. * Distance away where the pick collided
  10289. */
  10290. distance: number;
  10291. /**
  10292. * The location of pick collision
  10293. */
  10294. pickedPoint: Nullable<Vector3>;
  10295. /**
  10296. * The mesh corresponding the the pick collision
  10297. */
  10298. pickedMesh: Nullable<AbstractMesh>;
  10299. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10300. bu: number;
  10301. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10302. bv: number;
  10303. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10304. faceId: number;
  10305. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10306. subMeshFaceId: number;
  10307. /** Id of the the submesh that was picked */
  10308. subMeshId: number;
  10309. /** If a sprite was picked, this will be the sprite the pick collided with */
  10310. pickedSprite: Nullable<Sprite>;
  10311. /**
  10312. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10313. */
  10314. originMesh: Nullable<AbstractMesh>;
  10315. /**
  10316. * The ray that was used to perform the picking.
  10317. */
  10318. ray: Nullable<Ray>;
  10319. /**
  10320. * Gets the normal correspodning to the face the pick collided with
  10321. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10322. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10323. * @returns The normal correspodning to the face the pick collided with
  10324. */
  10325. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10326. /**
  10327. * Gets the texture coordinates of where the pick occured
  10328. * @returns the vector containing the coordnates of the texture
  10329. */
  10330. getTextureCoordinates(): Nullable<Vector2>;
  10331. }
  10332. }
  10333. declare module BABYLON {
  10334. /**
  10335. * Class representing a ray with position and direction
  10336. */
  10337. export class Ray {
  10338. /** origin point */
  10339. origin: Vector3;
  10340. /** direction */
  10341. direction: Vector3;
  10342. /** length of the ray */
  10343. length: number;
  10344. private static readonly TmpVector3;
  10345. private _tmpRay;
  10346. /**
  10347. * Creates a new ray
  10348. * @param origin origin point
  10349. * @param direction direction
  10350. * @param length length of the ray
  10351. */
  10352. constructor(
  10353. /** origin point */
  10354. origin: Vector3,
  10355. /** direction */
  10356. direction: Vector3,
  10357. /** length of the ray */
  10358. length?: number);
  10359. /**
  10360. * Checks if the ray intersects a box
  10361. * This does not account for the ray lenght by design to improve perfs.
  10362. * @param minimum bound of the box
  10363. * @param maximum bound of the box
  10364. * @param intersectionTreshold extra extend to be added to the box in all direction
  10365. * @returns if the box was hit
  10366. */
  10367. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10368. /**
  10369. * Checks if the ray intersects a box
  10370. * This does not account for the ray lenght by design to improve perfs.
  10371. * @param box the bounding box to check
  10372. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10373. * @returns if the box was hit
  10374. */
  10375. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10376. /**
  10377. * If the ray hits a sphere
  10378. * @param sphere the bounding sphere to check
  10379. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10380. * @returns true if it hits the sphere
  10381. */
  10382. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10383. /**
  10384. * If the ray hits a triange
  10385. * @param vertex0 triangle vertex
  10386. * @param vertex1 triangle vertex
  10387. * @param vertex2 triangle vertex
  10388. * @returns intersection information if hit
  10389. */
  10390. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10391. /**
  10392. * Checks if ray intersects a plane
  10393. * @param plane the plane to check
  10394. * @returns the distance away it was hit
  10395. */
  10396. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10397. /**
  10398. * Calculate the intercept of a ray on a given axis
  10399. * @param axis to check 'x' | 'y' | 'z'
  10400. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10401. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10402. */
  10403. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10404. /**
  10405. * Checks if ray intersects a mesh
  10406. * @param mesh the mesh to check
  10407. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10408. * @returns picking info of the intersecton
  10409. */
  10410. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10411. /**
  10412. * Checks if ray intersects a mesh
  10413. * @param meshes the meshes to check
  10414. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10415. * @param results array to store result in
  10416. * @returns Array of picking infos
  10417. */
  10418. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10419. private _comparePickingInfo;
  10420. private static smallnum;
  10421. private static rayl;
  10422. /**
  10423. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10424. * @param sega the first point of the segment to test the intersection against
  10425. * @param segb the second point of the segment to test the intersection against
  10426. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10427. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10428. */
  10429. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10430. /**
  10431. * Update the ray from viewport position
  10432. * @param x position
  10433. * @param y y position
  10434. * @param viewportWidth viewport width
  10435. * @param viewportHeight viewport height
  10436. * @param world world matrix
  10437. * @param view view matrix
  10438. * @param projection projection matrix
  10439. * @returns this ray updated
  10440. */
  10441. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10442. /**
  10443. * Creates a ray with origin and direction of 0,0,0
  10444. * @returns the new ray
  10445. */
  10446. static Zero(): Ray;
  10447. /**
  10448. * Creates a new ray from screen space and viewport
  10449. * @param x position
  10450. * @param y y position
  10451. * @param viewportWidth viewport width
  10452. * @param viewportHeight viewport height
  10453. * @param world world matrix
  10454. * @param view view matrix
  10455. * @param projection projection matrix
  10456. * @returns new ray
  10457. */
  10458. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10459. /**
  10460. * 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
  10461. * transformed to the given world matrix.
  10462. * @param origin The origin point
  10463. * @param end The end point
  10464. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10465. * @returns the new ray
  10466. */
  10467. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10468. /**
  10469. * Transforms a ray by a matrix
  10470. * @param ray ray to transform
  10471. * @param matrix matrix to apply
  10472. * @returns the resulting new ray
  10473. */
  10474. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10475. /**
  10476. * Transforms a ray by a matrix
  10477. * @param ray ray to transform
  10478. * @param matrix matrix to apply
  10479. * @param result ray to store result in
  10480. */
  10481. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10482. /**
  10483. * Unproject a ray from screen space to object space
  10484. * @param sourceX defines the screen space x coordinate to use
  10485. * @param sourceY defines the screen space y coordinate to use
  10486. * @param viewportWidth defines the current width of the viewport
  10487. * @param viewportHeight defines the current height of the viewport
  10488. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10489. * @param view defines the view matrix to use
  10490. * @param projection defines the projection matrix to use
  10491. */
  10492. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10493. }
  10494. /**
  10495. * Type used to define predicate used to select faces when a mesh intersection is detected
  10496. */
  10497. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10498. interface Scene {
  10499. /** @hidden */
  10500. _tempPickingRay: Nullable<Ray>;
  10501. /** @hidden */
  10502. _cachedRayForTransform: Ray;
  10503. /** @hidden */
  10504. _pickWithRayInverseMatrix: Matrix;
  10505. /** @hidden */
  10506. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10507. /** @hidden */
  10508. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10509. }
  10510. }
  10511. declare module BABYLON {
  10512. /**
  10513. * Groups all the scene component constants in one place to ease maintenance.
  10514. * @hidden
  10515. */
  10516. export class SceneComponentConstants {
  10517. static readonly NAME_EFFECTLAYER: string;
  10518. static readonly NAME_LAYER: string;
  10519. static readonly NAME_LENSFLARESYSTEM: string;
  10520. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10521. static readonly NAME_PARTICLESYSTEM: string;
  10522. static readonly NAME_GAMEPAD: string;
  10523. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10524. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10525. static readonly NAME_DEPTHRENDERER: string;
  10526. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10527. static readonly NAME_SPRITE: string;
  10528. static readonly NAME_OUTLINERENDERER: string;
  10529. static readonly NAME_PROCEDURALTEXTURE: string;
  10530. static readonly NAME_SHADOWGENERATOR: string;
  10531. static readonly NAME_OCTREE: string;
  10532. static readonly NAME_PHYSICSENGINE: string;
  10533. static readonly NAME_AUDIO: string;
  10534. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10535. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10536. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10537. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10538. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10539. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10540. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10541. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10542. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10543. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10544. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10545. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10546. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10547. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10548. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10549. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10550. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10551. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10552. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10553. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10554. static readonly STEP_AFTERRENDER_AUDIO: number;
  10555. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10556. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10557. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10558. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10559. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10560. static readonly STEP_POINTERMOVE_SPRITE: number;
  10561. static readonly STEP_POINTERDOWN_SPRITE: number;
  10562. static readonly STEP_POINTERUP_SPRITE: number;
  10563. }
  10564. /**
  10565. * This represents a scene component.
  10566. *
  10567. * This is used to decouple the dependency the scene is having on the different workloads like
  10568. * layers, post processes...
  10569. */
  10570. export interface ISceneComponent {
  10571. /**
  10572. * The name of the component. Each component must have a unique name.
  10573. */
  10574. name: string;
  10575. /**
  10576. * The scene the component belongs to.
  10577. */
  10578. scene: Scene;
  10579. /**
  10580. * Register the component to one instance of a scene.
  10581. */
  10582. register(): void;
  10583. /**
  10584. * Rebuilds the elements related to this component in case of
  10585. * context lost for instance.
  10586. */
  10587. rebuild(): void;
  10588. /**
  10589. * Disposes the component and the associated ressources.
  10590. */
  10591. dispose(): void;
  10592. }
  10593. /**
  10594. * This represents a SERIALIZABLE scene component.
  10595. *
  10596. * This extends Scene Component to add Serialization methods on top.
  10597. */
  10598. export interface ISceneSerializableComponent extends ISceneComponent {
  10599. /**
  10600. * Adds all the elements from the container to the scene
  10601. * @param container the container holding the elements
  10602. */
  10603. addFromContainer(container: AbstractScene): void;
  10604. /**
  10605. * Removes all the elements in the container from the scene
  10606. * @param container contains the elements to remove
  10607. * @param dispose if the removed element should be disposed (default: false)
  10608. */
  10609. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10610. /**
  10611. * Serializes the component data to the specified json object
  10612. * @param serializationObject The object to serialize to
  10613. */
  10614. serialize(serializationObject: any): void;
  10615. }
  10616. /**
  10617. * Strong typing of a Mesh related stage step action
  10618. */
  10619. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10620. /**
  10621. * Strong typing of a Evaluate Sub Mesh related stage step action
  10622. */
  10623. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10624. /**
  10625. * Strong typing of a Active Mesh related stage step action
  10626. */
  10627. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10628. /**
  10629. * Strong typing of a Camera related stage step action
  10630. */
  10631. export type CameraStageAction = (camera: Camera) => void;
  10632. /**
  10633. * Strong typing of a Camera Frame buffer related stage step action
  10634. */
  10635. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10636. /**
  10637. * Strong typing of a Render Target related stage step action
  10638. */
  10639. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10640. /**
  10641. * Strong typing of a RenderingGroup related stage step action
  10642. */
  10643. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10644. /**
  10645. * Strong typing of a Mesh Render related stage step action
  10646. */
  10647. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10648. /**
  10649. * Strong typing of a simple stage step action
  10650. */
  10651. export type SimpleStageAction = () => void;
  10652. /**
  10653. * Strong typing of a render target action.
  10654. */
  10655. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10656. /**
  10657. * Strong typing of a pointer move action.
  10658. */
  10659. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10660. /**
  10661. * Strong typing of a pointer up/down action.
  10662. */
  10663. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10664. /**
  10665. * Representation of a stage in the scene (Basically a list of ordered steps)
  10666. * @hidden
  10667. */
  10668. export class Stage<T extends Function> extends Array<{
  10669. index: number;
  10670. component: ISceneComponent;
  10671. action: T;
  10672. }> {
  10673. /**
  10674. * Hide ctor from the rest of the world.
  10675. * @param items The items to add.
  10676. */
  10677. private constructor();
  10678. /**
  10679. * Creates a new Stage.
  10680. * @returns A new instance of a Stage
  10681. */
  10682. static Create<T extends Function>(): Stage<T>;
  10683. /**
  10684. * Registers a step in an ordered way in the targeted stage.
  10685. * @param index Defines the position to register the step in
  10686. * @param component Defines the component attached to the step
  10687. * @param action Defines the action to launch during the step
  10688. */
  10689. registerStep(index: number, component: ISceneComponent, action: T): void;
  10690. /**
  10691. * Clears all the steps from the stage.
  10692. */
  10693. clear(): void;
  10694. }
  10695. }
  10696. declare module BABYLON {
  10697. interface Scene {
  10698. /** @hidden */
  10699. _pointerOverSprite: Nullable<Sprite>;
  10700. /** @hidden */
  10701. _pickedDownSprite: Nullable<Sprite>;
  10702. /** @hidden */
  10703. _tempSpritePickingRay: Nullable<Ray>;
  10704. /**
  10705. * All of the sprite managers added to this scene
  10706. * @see http://doc.babylonjs.com/babylon101/sprites
  10707. */
  10708. spriteManagers: Array<ISpriteManager>;
  10709. /**
  10710. * An event triggered when sprites rendering is about to start
  10711. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10712. */
  10713. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10714. /**
  10715. * An event triggered when sprites rendering is done
  10716. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10717. */
  10718. onAfterSpritesRenderingObservable: Observable<Scene>;
  10719. /** @hidden */
  10720. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10721. /** Launch a ray to try to pick a sprite in the scene
  10722. * @param x position on screen
  10723. * @param y position on screen
  10724. * @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
  10725. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10726. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10727. * @returns a PickingInfo
  10728. */
  10729. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10730. /** Use the given ray to pick a sprite in the scene
  10731. * @param ray The ray (in world space) to use to pick meshes
  10732. * @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
  10733. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10734. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10735. * @returns a PickingInfo
  10736. */
  10737. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10738. /** @hidden */
  10739. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10740. /** Launch a ray to try to pick sprites in the scene
  10741. * @param x position on screen
  10742. * @param y position on screen
  10743. * @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
  10744. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10745. * @returns a PickingInfo array
  10746. */
  10747. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10748. /** Use the given ray to pick sprites in the scene
  10749. * @param ray The ray (in world space) to use to pick meshes
  10750. * @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
  10751. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10752. * @returns a PickingInfo array
  10753. */
  10754. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10755. /**
  10756. * Force the sprite under the pointer
  10757. * @param sprite defines the sprite to use
  10758. */
  10759. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10760. /**
  10761. * Gets the sprite under the pointer
  10762. * @returns a Sprite or null if no sprite is under the pointer
  10763. */
  10764. getPointerOverSprite(): Nullable<Sprite>;
  10765. }
  10766. /**
  10767. * Defines the sprite scene component responsible to manage sprites
  10768. * in a given scene.
  10769. */
  10770. export class SpriteSceneComponent implements ISceneComponent {
  10771. /**
  10772. * The component name helpfull to identify the component in the list of scene components.
  10773. */
  10774. readonly name: string;
  10775. /**
  10776. * The scene the component belongs to.
  10777. */
  10778. scene: Scene;
  10779. /** @hidden */
  10780. private _spritePredicate;
  10781. /**
  10782. * Creates a new instance of the component for the given scene
  10783. * @param scene Defines the scene to register the component in
  10784. */
  10785. constructor(scene: Scene);
  10786. /**
  10787. * Registers the component in a given scene
  10788. */
  10789. register(): void;
  10790. /**
  10791. * Rebuilds the elements related to this component in case of
  10792. * context lost for instance.
  10793. */
  10794. rebuild(): void;
  10795. /**
  10796. * Disposes the component and the associated ressources.
  10797. */
  10798. dispose(): void;
  10799. private _pickSpriteButKeepRay;
  10800. private _pointerMove;
  10801. private _pointerDown;
  10802. private _pointerUp;
  10803. }
  10804. }
  10805. declare module BABYLON {
  10806. /** @hidden */
  10807. export var fogFragmentDeclaration: {
  10808. name: string;
  10809. shader: string;
  10810. };
  10811. }
  10812. declare module BABYLON {
  10813. /** @hidden */
  10814. export var fogFragment: {
  10815. name: string;
  10816. shader: string;
  10817. };
  10818. }
  10819. declare module BABYLON {
  10820. /** @hidden */
  10821. export var spritesPixelShader: {
  10822. name: string;
  10823. shader: string;
  10824. };
  10825. }
  10826. declare module BABYLON {
  10827. /** @hidden */
  10828. export var fogVertexDeclaration: {
  10829. name: string;
  10830. shader: string;
  10831. };
  10832. }
  10833. declare module BABYLON {
  10834. /** @hidden */
  10835. export var spritesVertexShader: {
  10836. name: string;
  10837. shader: string;
  10838. };
  10839. }
  10840. declare module BABYLON {
  10841. /**
  10842. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10843. */
  10844. export interface ISpriteManager extends IDisposable {
  10845. /**
  10846. * Gets manager's name
  10847. */
  10848. name: string;
  10849. /**
  10850. * Restricts the camera to viewing objects with the same layerMask.
  10851. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10852. */
  10853. layerMask: number;
  10854. /**
  10855. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10856. */
  10857. isPickable: boolean;
  10858. /**
  10859. * Gets the hosting scene
  10860. */
  10861. scene: Scene;
  10862. /**
  10863. * Specifies the rendering group id for this mesh (0 by default)
  10864. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10865. */
  10866. renderingGroupId: number;
  10867. /**
  10868. * Defines the list of sprites managed by the manager.
  10869. */
  10870. sprites: Array<Sprite>;
  10871. /**
  10872. * Gets or sets the spritesheet texture
  10873. */
  10874. texture: Texture;
  10875. /** Defines the default width of a cell in the spritesheet */
  10876. cellWidth: number;
  10877. /** Defines the default height of a cell in the spritesheet */
  10878. cellHeight: number;
  10879. /**
  10880. * Tests the intersection of a sprite with a specific ray.
  10881. * @param ray The ray we are sending to test the collision
  10882. * @param camera The camera space we are sending rays in
  10883. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10884. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10885. * @returns picking info or null.
  10886. */
  10887. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10888. /**
  10889. * Intersects the sprites with a ray
  10890. * @param ray defines the ray to intersect with
  10891. * @param camera defines the current active camera
  10892. * @param predicate defines a predicate used to select candidate sprites
  10893. * @returns null if no hit or a PickingInfo array
  10894. */
  10895. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10896. /**
  10897. * Renders the list of sprites on screen.
  10898. */
  10899. render(): void;
  10900. }
  10901. /**
  10902. * Class used to manage multiple sprites on the same spritesheet
  10903. * @see http://doc.babylonjs.com/babylon101/sprites
  10904. */
  10905. export class SpriteManager implements ISpriteManager {
  10906. /** defines the manager's name */
  10907. name: string;
  10908. /** Define the Url to load snippets */
  10909. static SnippetUrl: string;
  10910. /** Snippet ID if the manager was created from the snippet server */
  10911. snippetId: string;
  10912. /** Gets the list of sprites */
  10913. sprites: Sprite[];
  10914. /** Gets or sets the rendering group id (0 by default) */
  10915. renderingGroupId: number;
  10916. /** Gets or sets camera layer mask */
  10917. layerMask: number;
  10918. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10919. fogEnabled: boolean;
  10920. /** Gets or sets a boolean indicating if the sprites are pickable */
  10921. isPickable: boolean;
  10922. /** Defines the default width of a cell in the spritesheet */
  10923. cellWidth: number;
  10924. /** Defines the default height of a cell in the spritesheet */
  10925. cellHeight: number;
  10926. /** Associative array from JSON sprite data file */
  10927. private _cellData;
  10928. /** Array of sprite names from JSON sprite data file */
  10929. private _spriteMap;
  10930. /** True when packed cell data from JSON file is ready*/
  10931. private _packedAndReady;
  10932. private _textureContent;
  10933. /**
  10934. * An event triggered when the manager is disposed.
  10935. */
  10936. onDisposeObservable: Observable<SpriteManager>;
  10937. private _onDisposeObserver;
  10938. /**
  10939. * Callback called when the manager is disposed
  10940. */
  10941. set onDispose(callback: () => void);
  10942. private _capacity;
  10943. private _fromPacked;
  10944. private _spriteTexture;
  10945. private _epsilon;
  10946. private _scene;
  10947. private _vertexData;
  10948. private _buffer;
  10949. private _vertexBuffers;
  10950. private _indexBuffer;
  10951. private _effectBase;
  10952. private _effectFog;
  10953. /**
  10954. * Gets or sets the unique id of the sprite
  10955. */
  10956. uniqueId: number;
  10957. /**
  10958. * Gets the array of sprites
  10959. */
  10960. get children(): Sprite[];
  10961. /**
  10962. * Gets the hosting scene
  10963. */
  10964. get scene(): Scene;
  10965. /**
  10966. * Gets the capacity of the manager
  10967. */
  10968. get capacity(): number;
  10969. /**
  10970. * Gets or sets the spritesheet texture
  10971. */
  10972. get texture(): Texture;
  10973. set texture(value: Texture);
  10974. private _blendMode;
  10975. /**
  10976. * Blend mode use to render the particle, it can be any of
  10977. * the static Constants.ALPHA_x properties provided in this class.
  10978. * Default value is Constants.ALPHA_COMBINE
  10979. */
  10980. get blendMode(): number;
  10981. set blendMode(blendMode: number);
  10982. /** Disables writing to the depth buffer when rendering the sprites.
  10983. * It can be handy to disable depth writing when using textures without alpha channel
  10984. * and setting some specific blend modes.
  10985. */
  10986. disableDepthWrite: boolean;
  10987. /**
  10988. * Creates a new sprite manager
  10989. * @param name defines the manager's name
  10990. * @param imgUrl defines the sprite sheet url
  10991. * @param capacity defines the maximum allowed number of sprites
  10992. * @param cellSize defines the size of a sprite cell
  10993. * @param scene defines the hosting scene
  10994. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10995. * @param samplingMode defines the smapling mode to use with spritesheet
  10996. * @param fromPacked set to false; do not alter
  10997. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10998. */
  10999. constructor(
  11000. /** defines the manager's name */
  11001. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11002. /**
  11003. * Returns the string "SpriteManager"
  11004. * @returns "SpriteManager"
  11005. */
  11006. getClassName(): string;
  11007. private _makePacked;
  11008. private _appendSpriteVertex;
  11009. private _checkTextureAlpha;
  11010. /**
  11011. * Intersects the sprites with a ray
  11012. * @param ray defines the ray to intersect with
  11013. * @param camera defines the current active camera
  11014. * @param predicate defines a predicate used to select candidate sprites
  11015. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11016. * @returns null if no hit or a PickingInfo
  11017. */
  11018. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11019. /**
  11020. * Intersects the sprites with a ray
  11021. * @param ray defines the ray to intersect with
  11022. * @param camera defines the current active camera
  11023. * @param predicate defines a predicate used to select candidate sprites
  11024. * @returns null if no hit or a PickingInfo array
  11025. */
  11026. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11027. /**
  11028. * Render all child sprites
  11029. */
  11030. render(): void;
  11031. /**
  11032. * Release associated resources
  11033. */
  11034. dispose(): void;
  11035. /**
  11036. * Serializes the sprite manager to a JSON object
  11037. * @param serializeTexture defines if the texture must be serialized as well
  11038. * @returns the JSON object
  11039. */
  11040. serialize(serializeTexture?: boolean): any;
  11041. /**
  11042. * Parses a JSON object to create a new sprite manager.
  11043. * @param parsedManager The JSON object to parse
  11044. * @param scene The scene to create the sprite managerin
  11045. * @param rootUrl The root url to use to load external dependencies like texture
  11046. * @returns the new sprite manager
  11047. */
  11048. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11049. /**
  11050. * Creates a sprite manager from a snippet saved in a remote file
  11051. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11052. * @param url defines the url to load from
  11053. * @param scene defines the hosting scene
  11054. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11055. * @returns a promise that will resolve to the new sprite manager
  11056. */
  11057. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11058. /**
  11059. * Creates a sprite manager from a snippet saved by the sprite editor
  11060. * @param snippetId defines the snippet to load
  11061. * @param scene defines the hosting scene
  11062. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11063. * @returns a promise that will resolve to the new sprite manager
  11064. */
  11065. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11066. }
  11067. }
  11068. declare module BABYLON {
  11069. /** Interface used by value gradients (color, factor, ...) */
  11070. export interface IValueGradient {
  11071. /**
  11072. * Gets or sets the gradient value (between 0 and 1)
  11073. */
  11074. gradient: number;
  11075. }
  11076. /** Class used to store color4 gradient */
  11077. export class ColorGradient implements IValueGradient {
  11078. /**
  11079. * Gets or sets the gradient value (between 0 and 1)
  11080. */
  11081. gradient: number;
  11082. /**
  11083. * Gets or sets first associated color
  11084. */
  11085. color1: Color4;
  11086. /**
  11087. * Gets or sets second associated color
  11088. */
  11089. color2?: Color4 | undefined;
  11090. /**
  11091. * Creates a new color4 gradient
  11092. * @param gradient gets or sets the gradient value (between 0 and 1)
  11093. * @param color1 gets or sets first associated color
  11094. * @param color2 gets or sets first second color
  11095. */
  11096. constructor(
  11097. /**
  11098. * Gets or sets the gradient value (between 0 and 1)
  11099. */
  11100. gradient: number,
  11101. /**
  11102. * Gets or sets first associated color
  11103. */
  11104. color1: Color4,
  11105. /**
  11106. * Gets or sets second associated color
  11107. */
  11108. color2?: Color4 | undefined);
  11109. /**
  11110. * Will get a color picked randomly between color1 and color2.
  11111. * If color2 is undefined then color1 will be used
  11112. * @param result defines the target Color4 to store the result in
  11113. */
  11114. getColorToRef(result: Color4): void;
  11115. }
  11116. /** Class used to store color 3 gradient */
  11117. export class Color3Gradient implements IValueGradient {
  11118. /**
  11119. * Gets or sets the gradient value (between 0 and 1)
  11120. */
  11121. gradient: number;
  11122. /**
  11123. * Gets or sets the associated color
  11124. */
  11125. color: Color3;
  11126. /**
  11127. * Creates a new color3 gradient
  11128. * @param gradient gets or sets the gradient value (between 0 and 1)
  11129. * @param color gets or sets associated color
  11130. */
  11131. constructor(
  11132. /**
  11133. * Gets or sets the gradient value (between 0 and 1)
  11134. */
  11135. gradient: number,
  11136. /**
  11137. * Gets or sets the associated color
  11138. */
  11139. color: Color3);
  11140. }
  11141. /** Class used to store factor gradient */
  11142. export class FactorGradient implements IValueGradient {
  11143. /**
  11144. * Gets or sets the gradient value (between 0 and 1)
  11145. */
  11146. gradient: number;
  11147. /**
  11148. * Gets or sets first associated factor
  11149. */
  11150. factor1: number;
  11151. /**
  11152. * Gets or sets second associated factor
  11153. */
  11154. factor2?: number | undefined;
  11155. /**
  11156. * Creates a new factor gradient
  11157. * @param gradient gets or sets the gradient value (between 0 and 1)
  11158. * @param factor1 gets or sets first associated factor
  11159. * @param factor2 gets or sets second associated factor
  11160. */
  11161. constructor(
  11162. /**
  11163. * Gets or sets the gradient value (between 0 and 1)
  11164. */
  11165. gradient: number,
  11166. /**
  11167. * Gets or sets first associated factor
  11168. */
  11169. factor1: number,
  11170. /**
  11171. * Gets or sets second associated factor
  11172. */
  11173. factor2?: number | undefined);
  11174. /**
  11175. * Will get a number picked randomly between factor1 and factor2.
  11176. * If factor2 is undefined then factor1 will be used
  11177. * @returns the picked number
  11178. */
  11179. getFactor(): number;
  11180. }
  11181. /**
  11182. * Helper used to simplify some generic gradient tasks
  11183. */
  11184. export class GradientHelper {
  11185. /**
  11186. * Gets the current gradient from an array of IValueGradient
  11187. * @param ratio defines the current ratio to get
  11188. * @param gradients defines the array of IValueGradient
  11189. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11190. */
  11191. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11192. }
  11193. }
  11194. declare module BABYLON {
  11195. interface ThinEngine {
  11196. /**
  11197. * Creates a raw texture
  11198. * @param data defines the data to store in the texture
  11199. * @param width defines the width of the texture
  11200. * @param height defines the height of the texture
  11201. * @param format defines the format of the data
  11202. * @param generateMipMaps defines if the engine should generate the mip levels
  11203. * @param invertY defines if data must be stored with Y axis inverted
  11204. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11205. * @param compression defines the compression used (null by default)
  11206. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11207. * @returns the raw texture inside an InternalTexture
  11208. */
  11209. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11210. /**
  11211. * Update a raw texture
  11212. * @param texture defines the texture to update
  11213. * @param data defines the data to store in the texture
  11214. * @param format defines the format of the data
  11215. * @param invertY defines if data must be stored with Y axis inverted
  11216. */
  11217. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11218. /**
  11219. * Update a raw texture
  11220. * @param texture defines the texture to update
  11221. * @param data defines the data to store in the texture
  11222. * @param format defines the format of the data
  11223. * @param invertY defines if data must be stored with Y axis inverted
  11224. * @param compression defines the compression used (null by default)
  11225. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11226. */
  11227. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11228. /**
  11229. * Creates a new raw cube texture
  11230. * @param data defines the array of data to use to create each face
  11231. * @param size defines the size of the textures
  11232. * @param format defines the format of the data
  11233. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11234. * @param generateMipMaps defines if the engine should generate the mip levels
  11235. * @param invertY defines if data must be stored with Y axis inverted
  11236. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11237. * @param compression defines the compression used (null by default)
  11238. * @returns the cube texture as an InternalTexture
  11239. */
  11240. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11241. /**
  11242. * Update a raw cube texture
  11243. * @param texture defines the texture to udpdate
  11244. * @param data defines the data to store
  11245. * @param format defines the data format
  11246. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11247. * @param invertY defines if data must be stored with Y axis inverted
  11248. */
  11249. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11250. /**
  11251. * Update a raw cube texture
  11252. * @param texture defines the texture to udpdate
  11253. * @param data defines the data to store
  11254. * @param format defines the data format
  11255. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11256. * @param invertY defines if data must be stored with Y axis inverted
  11257. * @param compression defines the compression used (null by default)
  11258. */
  11259. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11260. /**
  11261. * Update a raw cube texture
  11262. * @param texture defines the texture to udpdate
  11263. * @param data defines the data to store
  11264. * @param format defines the data format
  11265. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11266. * @param invertY defines if data must be stored with Y axis inverted
  11267. * @param compression defines the compression used (null by default)
  11268. * @param level defines which level of the texture to update
  11269. */
  11270. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11271. /**
  11272. * Creates a new raw cube texture from a specified url
  11273. * @param url defines the url where the data is located
  11274. * @param scene defines the current scene
  11275. * @param size defines the size of the textures
  11276. * @param format defines the format of the data
  11277. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11278. * @param noMipmap defines if the engine should avoid generating the mip levels
  11279. * @param callback defines a callback used to extract texture data from loaded data
  11280. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11281. * @param onLoad defines a callback called when texture is loaded
  11282. * @param onError defines a callback called if there is an error
  11283. * @returns the cube texture as an InternalTexture
  11284. */
  11285. 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;
  11286. /**
  11287. * Creates a new raw cube texture from a specified url
  11288. * @param url defines the url where the data is located
  11289. * @param scene defines the current scene
  11290. * @param size defines the size of the textures
  11291. * @param format defines the format of the data
  11292. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11293. * @param noMipmap defines if the engine should avoid generating the mip levels
  11294. * @param callback defines a callback used to extract texture data from loaded data
  11295. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11296. * @param onLoad defines a callback called when texture is loaded
  11297. * @param onError defines a callback called if there is an error
  11298. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11299. * @param invertY defines if data must be stored with Y axis inverted
  11300. * @returns the cube texture as an InternalTexture
  11301. */
  11302. 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;
  11303. /**
  11304. * Creates a new raw 3D texture
  11305. * @param data defines the data used to create the texture
  11306. * @param width defines the width of the texture
  11307. * @param height defines the height of the texture
  11308. * @param depth defines the depth of the texture
  11309. * @param format defines the format of the texture
  11310. * @param generateMipMaps defines if the engine must generate mip levels
  11311. * @param invertY defines if data must be stored with Y axis inverted
  11312. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11313. * @param compression defines the compressed used (can be null)
  11314. * @param textureType defines the compressed used (can be null)
  11315. * @returns a new raw 3D texture (stored in an InternalTexture)
  11316. */
  11317. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11318. /**
  11319. * Update a raw 3D texture
  11320. * @param texture defines the texture to update
  11321. * @param data defines the data to store
  11322. * @param format defines the data format
  11323. * @param invertY defines if data must be stored with Y axis inverted
  11324. */
  11325. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11326. /**
  11327. * Update a raw 3D texture
  11328. * @param texture defines the texture to update
  11329. * @param data defines the data to store
  11330. * @param format defines the data format
  11331. * @param invertY defines if data must be stored with Y axis inverted
  11332. * @param compression defines the used compression (can be null)
  11333. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11334. */
  11335. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11336. /**
  11337. * Creates a new raw 2D array texture
  11338. * @param data defines the data used to create the texture
  11339. * @param width defines the width of the texture
  11340. * @param height defines the height of the texture
  11341. * @param depth defines the number of layers of the texture
  11342. * @param format defines the format of the texture
  11343. * @param generateMipMaps defines if the engine must generate mip levels
  11344. * @param invertY defines if data must be stored with Y axis inverted
  11345. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11346. * @param compression defines the compressed used (can be null)
  11347. * @param textureType defines the compressed used (can be null)
  11348. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11349. */
  11350. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11351. /**
  11352. * Update a raw 2D array texture
  11353. * @param texture defines the texture to update
  11354. * @param data defines the data to store
  11355. * @param format defines the data format
  11356. * @param invertY defines if data must be stored with Y axis inverted
  11357. */
  11358. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11359. /**
  11360. * Update a raw 2D array texture
  11361. * @param texture defines the texture to update
  11362. * @param data defines the data to store
  11363. * @param format defines the data format
  11364. * @param invertY defines if data must be stored with Y axis inverted
  11365. * @param compression defines the used compression (can be null)
  11366. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11367. */
  11368. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11369. }
  11370. }
  11371. declare module BABYLON {
  11372. /**
  11373. * Raw texture can help creating a texture directly from an array of data.
  11374. * This can be super useful if you either get the data from an uncompressed source or
  11375. * if you wish to create your texture pixel by pixel.
  11376. */
  11377. export class RawTexture extends Texture {
  11378. /**
  11379. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11380. */
  11381. format: number;
  11382. /**
  11383. * Instantiates a new RawTexture.
  11384. * Raw texture can help creating a texture directly from an array of data.
  11385. * This can be super useful if you either get the data from an uncompressed source or
  11386. * if you wish to create your texture pixel by pixel.
  11387. * @param data define the array of data to use to create the texture
  11388. * @param width define the width of the texture
  11389. * @param height define the height of the texture
  11390. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11391. * @param scene define the scene the texture belongs to
  11392. * @param generateMipMaps define whether mip maps should be generated or not
  11393. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11394. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11395. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11396. */
  11397. constructor(data: ArrayBufferView, width: number, height: number,
  11398. /**
  11399. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11400. */
  11401. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11402. /**
  11403. * Updates the texture underlying data.
  11404. * @param data Define the new data of the texture
  11405. */
  11406. update(data: ArrayBufferView): void;
  11407. /**
  11408. * Creates a luminance texture from some data.
  11409. * @param data Define the texture data
  11410. * @param width Define the width of the texture
  11411. * @param height Define the height of the texture
  11412. * @param scene Define the scene the texture belongs to
  11413. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11414. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11415. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11416. * @returns the luminance texture
  11417. */
  11418. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11419. /**
  11420. * Creates a luminance alpha texture from some data.
  11421. * @param data Define the texture data
  11422. * @param width Define the width of the texture
  11423. * @param height Define the height of the texture
  11424. * @param scene Define the scene the texture belongs to
  11425. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11426. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11427. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11428. * @returns the luminance alpha texture
  11429. */
  11430. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11431. /**
  11432. * Creates an alpha texture from some data.
  11433. * @param data Define the texture data
  11434. * @param width Define the width of the texture
  11435. * @param height Define the height of the texture
  11436. * @param scene Define the scene the texture belongs to
  11437. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11438. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11439. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11440. * @returns the alpha texture
  11441. */
  11442. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11443. /**
  11444. * Creates a RGB texture from some data.
  11445. * @param data Define the texture data
  11446. * @param width Define the width of the texture
  11447. * @param height Define the height of the texture
  11448. * @param scene Define the scene the texture belongs to
  11449. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11450. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11451. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11452. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11453. * @returns the RGB alpha texture
  11454. */
  11455. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11456. /**
  11457. * Creates a RGBA texture from some data.
  11458. * @param data Define the texture data
  11459. * @param width Define the width of the texture
  11460. * @param height Define the height of the texture
  11461. * @param scene Define the scene the texture belongs to
  11462. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11463. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11464. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11465. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11466. * @returns the RGBA texture
  11467. */
  11468. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11469. /**
  11470. * Creates a R texture from some data.
  11471. * @param data Define the texture data
  11472. * @param width Define the width of the texture
  11473. * @param height Define the height of the texture
  11474. * @param scene Define the scene the texture belongs to
  11475. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11476. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11477. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11478. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11479. * @returns the R texture
  11480. */
  11481. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11482. }
  11483. }
  11484. declare module BABYLON {
  11485. interface AbstractScene {
  11486. /**
  11487. * The list of procedural textures added to the scene
  11488. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11489. */
  11490. proceduralTextures: Array<ProceduralTexture>;
  11491. }
  11492. /**
  11493. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11494. * in a given scene.
  11495. */
  11496. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11497. /**
  11498. * The component name helpfull to identify the component in the list of scene components.
  11499. */
  11500. readonly name: string;
  11501. /**
  11502. * The scene the component belongs to.
  11503. */
  11504. scene: Scene;
  11505. /**
  11506. * Creates a new instance of the component for the given scene
  11507. * @param scene Defines the scene to register the component in
  11508. */
  11509. constructor(scene: Scene);
  11510. /**
  11511. * Registers the component in a given scene
  11512. */
  11513. register(): void;
  11514. /**
  11515. * Rebuilds the elements related to this component in case of
  11516. * context lost for instance.
  11517. */
  11518. rebuild(): void;
  11519. /**
  11520. * Disposes the component and the associated ressources.
  11521. */
  11522. dispose(): void;
  11523. private _beforeClear;
  11524. }
  11525. }
  11526. declare module BABYLON {
  11527. interface ThinEngine {
  11528. /**
  11529. * Creates a new render target cube texture
  11530. * @param size defines the size of the texture
  11531. * @param options defines the options used to create the texture
  11532. * @returns a new render target cube texture stored in an InternalTexture
  11533. */
  11534. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11535. }
  11536. }
  11537. declare module BABYLON {
  11538. /** @hidden */
  11539. export var proceduralVertexShader: {
  11540. name: string;
  11541. shader: string;
  11542. };
  11543. }
  11544. declare module BABYLON {
  11545. /**
  11546. * 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.
  11547. * This is the base class of any Procedural texture and contains most of the shareable code.
  11548. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11549. */
  11550. export class ProceduralTexture extends Texture {
  11551. isCube: boolean;
  11552. /**
  11553. * Define if the texture is enabled or not (disabled texture will not render)
  11554. */
  11555. isEnabled: boolean;
  11556. /**
  11557. * Define if the texture must be cleared before rendering (default is true)
  11558. */
  11559. autoClear: boolean;
  11560. /**
  11561. * Callback called when the texture is generated
  11562. */
  11563. onGenerated: () => void;
  11564. /**
  11565. * Event raised when the texture is generated
  11566. */
  11567. onGeneratedObservable: Observable<ProceduralTexture>;
  11568. /** @hidden */
  11569. _generateMipMaps: boolean;
  11570. /** @hidden **/
  11571. _effect: Effect;
  11572. /** @hidden */
  11573. _textures: {
  11574. [key: string]: Texture;
  11575. };
  11576. /** @hidden */
  11577. protected _fallbackTexture: Nullable<Texture>;
  11578. private _size;
  11579. private _currentRefreshId;
  11580. private _frameId;
  11581. private _refreshRate;
  11582. private _vertexBuffers;
  11583. private _indexBuffer;
  11584. private _uniforms;
  11585. private _samplers;
  11586. private _fragment;
  11587. private _floats;
  11588. private _ints;
  11589. private _floatsArrays;
  11590. private _colors3;
  11591. private _colors4;
  11592. private _vectors2;
  11593. private _vectors3;
  11594. private _matrices;
  11595. private _fallbackTextureUsed;
  11596. private _fullEngine;
  11597. private _cachedDefines;
  11598. private _contentUpdateId;
  11599. private _contentData;
  11600. /**
  11601. * Instantiates a new procedural texture.
  11602. * 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.
  11603. * This is the base class of any Procedural texture and contains most of the shareable code.
  11604. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11605. * @param name Define the name of the texture
  11606. * @param size Define the size of the texture to create
  11607. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11608. * @param scene Define the scene the texture belongs to
  11609. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11610. * @param generateMipMaps Define if the texture should creates mip maps or not
  11611. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11612. */
  11613. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11614. /**
  11615. * The effect that is created when initializing the post process.
  11616. * @returns The created effect corresponding the the postprocess.
  11617. */
  11618. getEffect(): Effect;
  11619. /**
  11620. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11621. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11622. */
  11623. getContent(): Nullable<ArrayBufferView>;
  11624. private _createIndexBuffer;
  11625. /** @hidden */
  11626. _rebuild(): void;
  11627. /**
  11628. * Resets the texture in order to recreate its associated resources.
  11629. * This can be called in case of context loss
  11630. */
  11631. reset(): void;
  11632. protected _getDefines(): string;
  11633. /**
  11634. * Is the texture ready to be used ? (rendered at least once)
  11635. * @returns true if ready, otherwise, false.
  11636. */
  11637. isReady(): boolean;
  11638. /**
  11639. * Resets the refresh counter of the texture and start bak from scratch.
  11640. * Could be useful to regenerate the texture if it is setup to render only once.
  11641. */
  11642. resetRefreshCounter(): void;
  11643. /**
  11644. * Set the fragment shader to use in order to render the texture.
  11645. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11646. */
  11647. setFragment(fragment: any): void;
  11648. /**
  11649. * Define the refresh rate of the texture or the rendering frequency.
  11650. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11651. */
  11652. get refreshRate(): number;
  11653. set refreshRate(value: number);
  11654. /** @hidden */
  11655. _shouldRender(): boolean;
  11656. /**
  11657. * Get the size the texture is rendering at.
  11658. * @returns the size (texture is always squared)
  11659. */
  11660. getRenderSize(): number;
  11661. /**
  11662. * Resize the texture to new value.
  11663. * @param size Define the new size the texture should have
  11664. * @param generateMipMaps Define whether the new texture should create mip maps
  11665. */
  11666. resize(size: number, generateMipMaps: boolean): void;
  11667. private _checkUniform;
  11668. /**
  11669. * Set a texture in the shader program used to render.
  11670. * @param name Define the name of the uniform samplers as defined in the shader
  11671. * @param texture Define the texture to bind to this sampler
  11672. * @return the texture itself allowing "fluent" like uniform updates
  11673. */
  11674. setTexture(name: string, texture: Texture): ProceduralTexture;
  11675. /**
  11676. * Set a float in the shader.
  11677. * @param name Define the name of the uniform as defined in the shader
  11678. * @param value Define the value to give to the uniform
  11679. * @return the texture itself allowing "fluent" like uniform updates
  11680. */
  11681. setFloat(name: string, value: number): ProceduralTexture;
  11682. /**
  11683. * Set a int in the shader.
  11684. * @param name Define the name of the uniform as defined in the shader
  11685. * @param value Define the value to give to the uniform
  11686. * @return the texture itself allowing "fluent" like uniform updates
  11687. */
  11688. setInt(name: string, value: number): ProceduralTexture;
  11689. /**
  11690. * Set an array of floats in the shader.
  11691. * @param name Define the name of the uniform as defined in the shader
  11692. * @param value Define the value to give to the uniform
  11693. * @return the texture itself allowing "fluent" like uniform updates
  11694. */
  11695. setFloats(name: string, value: number[]): ProceduralTexture;
  11696. /**
  11697. * Set a vec3 in the shader from a Color3.
  11698. * @param name Define the name of the uniform as defined in the shader
  11699. * @param value Define the value to give to the uniform
  11700. * @return the texture itself allowing "fluent" like uniform updates
  11701. */
  11702. setColor3(name: string, value: Color3): ProceduralTexture;
  11703. /**
  11704. * Set a vec4 in the shader from a Color4.
  11705. * @param name Define the name of the uniform as defined in the shader
  11706. * @param value Define the value to give to the uniform
  11707. * @return the texture itself allowing "fluent" like uniform updates
  11708. */
  11709. setColor4(name: string, value: Color4): ProceduralTexture;
  11710. /**
  11711. * Set a vec2 in the shader from a Vector2.
  11712. * @param name Define the name of the uniform as defined in the shader
  11713. * @param value Define the value to give to the uniform
  11714. * @return the texture itself allowing "fluent" like uniform updates
  11715. */
  11716. setVector2(name: string, value: Vector2): ProceduralTexture;
  11717. /**
  11718. * Set a vec3 in the shader from a Vector3.
  11719. * @param name Define the name of the uniform as defined in the shader
  11720. * @param value Define the value to give to the uniform
  11721. * @return the texture itself allowing "fluent" like uniform updates
  11722. */
  11723. setVector3(name: string, value: Vector3): ProceduralTexture;
  11724. /**
  11725. * Set a mat4 in the shader from a MAtrix.
  11726. * @param name Define the name of the uniform as defined in the shader
  11727. * @param value Define the value to give to the uniform
  11728. * @return the texture itself allowing "fluent" like uniform updates
  11729. */
  11730. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11731. /**
  11732. * Render the texture to its associated render target.
  11733. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11734. */
  11735. render(useCameraPostProcess?: boolean): void;
  11736. /**
  11737. * Clone the texture.
  11738. * @returns the cloned texture
  11739. */
  11740. clone(): ProceduralTexture;
  11741. /**
  11742. * Dispose the texture and release its asoociated resources.
  11743. */
  11744. dispose(): void;
  11745. }
  11746. }
  11747. declare module BABYLON {
  11748. /**
  11749. * This represents the base class for particle system in Babylon.
  11750. * 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.
  11751. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11752. * @example https://doc.babylonjs.com/babylon101/particles
  11753. */
  11754. export class BaseParticleSystem {
  11755. /**
  11756. * Source color is added to the destination color without alpha affecting the result
  11757. */
  11758. static BLENDMODE_ONEONE: number;
  11759. /**
  11760. * Blend current color and particle color using particle’s alpha
  11761. */
  11762. static BLENDMODE_STANDARD: number;
  11763. /**
  11764. * Add current color and particle color multiplied by particle’s alpha
  11765. */
  11766. static BLENDMODE_ADD: number;
  11767. /**
  11768. * Multiply current color with particle color
  11769. */
  11770. static BLENDMODE_MULTIPLY: number;
  11771. /**
  11772. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11773. */
  11774. static BLENDMODE_MULTIPLYADD: number;
  11775. /**
  11776. * List of animations used by the particle system.
  11777. */
  11778. animations: Animation[];
  11779. /**
  11780. * Gets or sets the unique id of the particle system
  11781. */
  11782. uniqueId: number;
  11783. /**
  11784. * The id of the Particle system.
  11785. */
  11786. id: string;
  11787. /**
  11788. * The friendly name of the Particle system.
  11789. */
  11790. name: string;
  11791. /**
  11792. * Snippet ID if the particle system was created from the snippet server
  11793. */
  11794. snippetId: string;
  11795. /**
  11796. * The rendering group used by the Particle system to chose when to render.
  11797. */
  11798. renderingGroupId: number;
  11799. /**
  11800. * The emitter represents the Mesh or position we are attaching the particle system to.
  11801. */
  11802. emitter: Nullable<AbstractMesh | Vector3>;
  11803. /**
  11804. * The maximum number of particles to emit per frame
  11805. */
  11806. emitRate: number;
  11807. /**
  11808. * If you want to launch only a few particles at once, that can be done, as well.
  11809. */
  11810. manualEmitCount: number;
  11811. /**
  11812. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11813. */
  11814. updateSpeed: number;
  11815. /**
  11816. * The amount of time the particle system is running (depends of the overall update speed).
  11817. */
  11818. targetStopDuration: number;
  11819. /**
  11820. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11821. */
  11822. disposeOnStop: boolean;
  11823. /**
  11824. * Minimum power of emitting particles.
  11825. */
  11826. minEmitPower: number;
  11827. /**
  11828. * Maximum power of emitting particles.
  11829. */
  11830. maxEmitPower: number;
  11831. /**
  11832. * Minimum life time of emitting particles.
  11833. */
  11834. minLifeTime: number;
  11835. /**
  11836. * Maximum life time of emitting particles.
  11837. */
  11838. maxLifeTime: number;
  11839. /**
  11840. * Minimum Size of emitting particles.
  11841. */
  11842. minSize: number;
  11843. /**
  11844. * Maximum Size of emitting particles.
  11845. */
  11846. maxSize: number;
  11847. /**
  11848. * Minimum scale of emitting particles on X axis.
  11849. */
  11850. minScaleX: number;
  11851. /**
  11852. * Maximum scale of emitting particles on X axis.
  11853. */
  11854. maxScaleX: number;
  11855. /**
  11856. * Minimum scale of emitting particles on Y axis.
  11857. */
  11858. minScaleY: number;
  11859. /**
  11860. * Maximum scale of emitting particles on Y axis.
  11861. */
  11862. maxScaleY: number;
  11863. /**
  11864. * Gets or sets the minimal initial rotation in radians.
  11865. */
  11866. minInitialRotation: number;
  11867. /**
  11868. * Gets or sets the maximal initial rotation in radians.
  11869. */
  11870. maxInitialRotation: number;
  11871. /**
  11872. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11873. */
  11874. minAngularSpeed: number;
  11875. /**
  11876. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11877. */
  11878. maxAngularSpeed: number;
  11879. /**
  11880. * The texture used to render each particle. (this can be a spritesheet)
  11881. */
  11882. particleTexture: Nullable<Texture>;
  11883. /**
  11884. * The layer mask we are rendering the particles through.
  11885. */
  11886. layerMask: number;
  11887. /**
  11888. * This can help using your own shader to render the particle system.
  11889. * The according effect will be created
  11890. */
  11891. customShader: any;
  11892. /**
  11893. * By default particle system starts as soon as they are created. This prevents the
  11894. * automatic start to happen and let you decide when to start emitting particles.
  11895. */
  11896. preventAutoStart: boolean;
  11897. private _noiseTexture;
  11898. /**
  11899. * Gets or sets a texture used to add random noise to particle positions
  11900. */
  11901. get noiseTexture(): Nullable<ProceduralTexture>;
  11902. set noiseTexture(value: Nullable<ProceduralTexture>);
  11903. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11904. noiseStrength: Vector3;
  11905. /**
  11906. * Callback triggered when the particle animation is ending.
  11907. */
  11908. onAnimationEnd: Nullable<() => void>;
  11909. /**
  11910. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11911. */
  11912. blendMode: number;
  11913. /**
  11914. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11915. * to override the particles.
  11916. */
  11917. forceDepthWrite: boolean;
  11918. /** 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 */
  11919. preWarmCycles: number;
  11920. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11921. preWarmStepOffset: number;
  11922. /**
  11923. * 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)
  11924. */
  11925. spriteCellChangeSpeed: number;
  11926. /**
  11927. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11928. */
  11929. startSpriteCellID: number;
  11930. /**
  11931. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11932. */
  11933. endSpriteCellID: number;
  11934. /**
  11935. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11936. */
  11937. spriteCellWidth: number;
  11938. /**
  11939. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11940. */
  11941. spriteCellHeight: number;
  11942. /**
  11943. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11944. */
  11945. spriteRandomStartCell: boolean;
  11946. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11947. translationPivot: Vector2;
  11948. /** @hidden */
  11949. protected _isAnimationSheetEnabled: boolean;
  11950. /**
  11951. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11952. */
  11953. beginAnimationOnStart: boolean;
  11954. /**
  11955. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11956. */
  11957. beginAnimationFrom: number;
  11958. /**
  11959. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11960. */
  11961. beginAnimationTo: number;
  11962. /**
  11963. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11964. */
  11965. beginAnimationLoop: boolean;
  11966. /**
  11967. * Gets or sets a world offset applied to all particles
  11968. */
  11969. worldOffset: Vector3;
  11970. /**
  11971. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11972. */
  11973. get isAnimationSheetEnabled(): boolean;
  11974. set isAnimationSheetEnabled(value: boolean);
  11975. /**
  11976. * Get hosting scene
  11977. * @returns the scene
  11978. */
  11979. getScene(): Scene;
  11980. /**
  11981. * You can use gravity if you want to give an orientation to your particles.
  11982. */
  11983. gravity: Vector3;
  11984. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11985. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11986. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11987. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11988. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11989. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11990. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11991. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11992. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11993. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11994. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11995. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11996. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11997. /**
  11998. * Defines the delay in milliseconds before starting the system (0 by default)
  11999. */
  12000. startDelay: number;
  12001. /**
  12002. * Gets the current list of drag gradients.
  12003. * You must use addDragGradient and removeDragGradient to udpate this list
  12004. * @returns the list of drag gradients
  12005. */
  12006. getDragGradients(): Nullable<Array<FactorGradient>>;
  12007. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12008. limitVelocityDamping: number;
  12009. /**
  12010. * Gets the current list of limit velocity gradients.
  12011. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12012. * @returns the list of limit velocity gradients
  12013. */
  12014. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12015. /**
  12016. * Gets the current list of color gradients.
  12017. * You must use addColorGradient and removeColorGradient to udpate this list
  12018. * @returns the list of color gradients
  12019. */
  12020. getColorGradients(): Nullable<Array<ColorGradient>>;
  12021. /**
  12022. * Gets the current list of size gradients.
  12023. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12024. * @returns the list of size gradients
  12025. */
  12026. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12027. /**
  12028. * Gets the current list of color remap gradients.
  12029. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12030. * @returns the list of color remap gradients
  12031. */
  12032. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12033. /**
  12034. * Gets the current list of alpha remap gradients.
  12035. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12036. * @returns the list of alpha remap gradients
  12037. */
  12038. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12039. /**
  12040. * Gets the current list of life time gradients.
  12041. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12042. * @returns the list of life time gradients
  12043. */
  12044. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12045. /**
  12046. * Gets the current list of angular speed gradients.
  12047. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12048. * @returns the list of angular speed gradients
  12049. */
  12050. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12051. /**
  12052. * Gets the current list of velocity gradients.
  12053. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12054. * @returns the list of velocity gradients
  12055. */
  12056. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12057. /**
  12058. * Gets the current list of start size gradients.
  12059. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12060. * @returns the list of start size gradients
  12061. */
  12062. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12063. /**
  12064. * Gets the current list of emit rate gradients.
  12065. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12066. * @returns the list of emit rate gradients
  12067. */
  12068. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12069. /**
  12070. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12071. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12072. */
  12073. get direction1(): Vector3;
  12074. set direction1(value: Vector3);
  12075. /**
  12076. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12077. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12078. */
  12079. get direction2(): Vector3;
  12080. set direction2(value: Vector3);
  12081. /**
  12082. * 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.
  12083. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12084. */
  12085. get minEmitBox(): Vector3;
  12086. set minEmitBox(value: Vector3);
  12087. /**
  12088. * 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.
  12089. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12090. */
  12091. get maxEmitBox(): Vector3;
  12092. set maxEmitBox(value: Vector3);
  12093. /**
  12094. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12095. */
  12096. color1: Color4;
  12097. /**
  12098. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12099. */
  12100. color2: Color4;
  12101. /**
  12102. * Color the particle will have at the end of its lifetime
  12103. */
  12104. colorDead: Color4;
  12105. /**
  12106. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12107. */
  12108. textureMask: Color4;
  12109. /**
  12110. * The particle emitter type defines the emitter used by the particle system.
  12111. * It can be for example box, sphere, or cone...
  12112. */
  12113. particleEmitterType: IParticleEmitterType;
  12114. /** @hidden */
  12115. _isSubEmitter: boolean;
  12116. /**
  12117. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12118. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12119. */
  12120. billboardMode: number;
  12121. protected _isBillboardBased: boolean;
  12122. /**
  12123. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12124. */
  12125. get isBillboardBased(): boolean;
  12126. set isBillboardBased(value: boolean);
  12127. /**
  12128. * The scene the particle system belongs to.
  12129. */
  12130. protected _scene: Scene;
  12131. /**
  12132. * Local cache of defines for image processing.
  12133. */
  12134. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12135. /**
  12136. * Default configuration related to image processing available in the standard Material.
  12137. */
  12138. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12139. /**
  12140. * Gets the image processing configuration used either in this material.
  12141. */
  12142. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  12143. /**
  12144. * Sets the Default image processing configuration used either in the this material.
  12145. *
  12146. * If sets to null, the scene one is in use.
  12147. */
  12148. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  12149. /**
  12150. * Attaches a new image processing configuration to the Standard Material.
  12151. * @param configuration
  12152. */
  12153. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12154. /** @hidden */
  12155. protected _reset(): void;
  12156. /** @hidden */
  12157. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12158. /**
  12159. * Instantiates a particle system.
  12160. * 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.
  12161. * @param name The name of the particle system
  12162. */
  12163. constructor(name: string);
  12164. /**
  12165. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12166. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12167. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12168. * @returns the emitter
  12169. */
  12170. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12171. /**
  12172. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12173. * @param radius The radius of the hemisphere to emit from
  12174. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12175. * @returns the emitter
  12176. */
  12177. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12178. /**
  12179. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12180. * @param radius The radius of the sphere to emit from
  12181. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12182. * @returns the emitter
  12183. */
  12184. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12185. /**
  12186. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12187. * @param radius The radius of the sphere to emit from
  12188. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12189. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12190. * @returns the emitter
  12191. */
  12192. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12193. /**
  12194. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12195. * @param radius The radius of the emission cylinder
  12196. * @param height The height of the emission cylinder
  12197. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12198. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12199. * @returns the emitter
  12200. */
  12201. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12202. /**
  12203. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12204. * @param radius The radius of the cylinder to emit from
  12205. * @param height The height of the emission cylinder
  12206. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12207. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12208. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12209. * @returns the emitter
  12210. */
  12211. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12212. /**
  12213. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12214. * @param radius The radius of the cone to emit from
  12215. * @param angle The base angle of the cone
  12216. * @returns the emitter
  12217. */
  12218. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12219. /**
  12220. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12221. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12222. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12223. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12224. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12225. * @returns the emitter
  12226. */
  12227. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12228. }
  12229. }
  12230. declare module BABYLON {
  12231. /**
  12232. * Type of sub emitter
  12233. */
  12234. export enum SubEmitterType {
  12235. /**
  12236. * Attached to the particle over it's lifetime
  12237. */
  12238. ATTACHED = 0,
  12239. /**
  12240. * Created when the particle dies
  12241. */
  12242. END = 1
  12243. }
  12244. /**
  12245. * Sub emitter class used to emit particles from an existing particle
  12246. */
  12247. export class SubEmitter {
  12248. /**
  12249. * the particle system to be used by the sub emitter
  12250. */
  12251. particleSystem: ParticleSystem;
  12252. /**
  12253. * Type of the submitter (Default: END)
  12254. */
  12255. type: SubEmitterType;
  12256. /**
  12257. * 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)
  12258. * Note: This only is supported when using an emitter of type Mesh
  12259. */
  12260. inheritDirection: boolean;
  12261. /**
  12262. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12263. */
  12264. inheritedVelocityAmount: number;
  12265. /**
  12266. * Creates a sub emitter
  12267. * @param particleSystem the particle system to be used by the sub emitter
  12268. */
  12269. constructor(
  12270. /**
  12271. * the particle system to be used by the sub emitter
  12272. */
  12273. particleSystem: ParticleSystem);
  12274. /**
  12275. * Clones the sub emitter
  12276. * @returns the cloned sub emitter
  12277. */
  12278. clone(): SubEmitter;
  12279. /**
  12280. * Serialize current object to a JSON object
  12281. * @returns the serialized object
  12282. */
  12283. serialize(): any;
  12284. /** @hidden */
  12285. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  12286. /**
  12287. * Creates a new SubEmitter from a serialized JSON version
  12288. * @param serializationObject defines the JSON object to read from
  12289. * @param scene defines the hosting scene
  12290. * @param rootUrl defines the rootUrl for data loading
  12291. * @returns a new SubEmitter
  12292. */
  12293. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  12294. /** Release associated resources */
  12295. dispose(): void;
  12296. }
  12297. }
  12298. declare module BABYLON {
  12299. /** @hidden */
  12300. export var imageProcessingDeclaration: {
  12301. name: string;
  12302. shader: string;
  12303. };
  12304. }
  12305. declare module BABYLON {
  12306. /** @hidden */
  12307. export var imageProcessingFunctions: {
  12308. name: string;
  12309. shader: string;
  12310. };
  12311. }
  12312. declare module BABYLON {
  12313. /** @hidden */
  12314. export var particlesPixelShader: {
  12315. name: string;
  12316. shader: string;
  12317. };
  12318. }
  12319. declare module BABYLON {
  12320. /** @hidden */
  12321. export var particlesVertexShader: {
  12322. name: string;
  12323. shader: string;
  12324. };
  12325. }
  12326. declare module BABYLON {
  12327. /**
  12328. * This represents a particle system in Babylon.
  12329. * 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.
  12330. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12331. * @example https://doc.babylonjs.com/babylon101/particles
  12332. */
  12333. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12334. /**
  12335. * Billboard mode will only apply to Y axis
  12336. */
  12337. static readonly BILLBOARDMODE_Y: number;
  12338. /**
  12339. * Billboard mode will apply to all axes
  12340. */
  12341. static readonly BILLBOARDMODE_ALL: number;
  12342. /**
  12343. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12344. */
  12345. static readonly BILLBOARDMODE_STRETCHED: number;
  12346. /**
  12347. * This function can be defined to provide custom update for active particles.
  12348. * This function will be called instead of regular update (age, position, color, etc.).
  12349. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12350. */
  12351. updateFunction: (particles: Particle[]) => void;
  12352. private _emitterWorldMatrix;
  12353. /**
  12354. * This function can be defined to specify initial direction for every new particle.
  12355. * It by default use the emitterType defined function
  12356. */
  12357. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12358. /**
  12359. * This function can be defined to specify initial position for every new particle.
  12360. * It by default use the emitterType defined function
  12361. */
  12362. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12363. /**
  12364. * @hidden
  12365. */
  12366. _inheritedVelocityOffset: Vector3;
  12367. /**
  12368. * An event triggered when the system is disposed
  12369. */
  12370. onDisposeObservable: Observable<IParticleSystem>;
  12371. private _onDisposeObserver;
  12372. /**
  12373. * Sets a callback that will be triggered when the system is disposed
  12374. */
  12375. set onDispose(callback: () => void);
  12376. private _particles;
  12377. private _epsilon;
  12378. private _capacity;
  12379. private _stockParticles;
  12380. private _newPartsExcess;
  12381. private _vertexData;
  12382. private _vertexBuffer;
  12383. private _vertexBuffers;
  12384. private _spriteBuffer;
  12385. private _indexBuffer;
  12386. private _effect;
  12387. private _customEffect;
  12388. private _cachedDefines;
  12389. private _scaledColorStep;
  12390. private _colorDiff;
  12391. private _scaledDirection;
  12392. private _scaledGravity;
  12393. private _currentRenderId;
  12394. private _alive;
  12395. private _useInstancing;
  12396. private _started;
  12397. private _stopped;
  12398. private _actualFrame;
  12399. private _scaledUpdateSpeed;
  12400. private _vertexBufferSize;
  12401. /** @hidden */
  12402. _currentEmitRateGradient: Nullable<FactorGradient>;
  12403. /** @hidden */
  12404. _currentEmitRate1: number;
  12405. /** @hidden */
  12406. _currentEmitRate2: number;
  12407. /** @hidden */
  12408. _currentStartSizeGradient: Nullable<FactorGradient>;
  12409. /** @hidden */
  12410. _currentStartSize1: number;
  12411. /** @hidden */
  12412. _currentStartSize2: number;
  12413. private readonly _rawTextureWidth;
  12414. private _rampGradientsTexture;
  12415. private _useRampGradients;
  12416. /** Gets or sets a boolean indicating that ramp gradients must be used
  12417. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12418. */
  12419. get useRampGradients(): boolean;
  12420. set useRampGradients(value: boolean);
  12421. /**
  12422. * 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.
  12423. * 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: [])
  12424. */
  12425. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12426. private _subEmitters;
  12427. /**
  12428. * @hidden
  12429. * If the particle systems emitter should be disposed when the particle system is disposed
  12430. */
  12431. _disposeEmitterOnDispose: boolean;
  12432. /**
  12433. * The current active Sub-systems, this property is used by the root particle system only.
  12434. */
  12435. activeSubSystems: Array<ParticleSystem>;
  12436. /**
  12437. * Specifies if the particles are updated in emitter local space or world space
  12438. */
  12439. isLocal: boolean;
  12440. private _rootParticleSystem;
  12441. /**
  12442. * Gets the current list of active particles
  12443. */
  12444. get particles(): Particle[];
  12445. /**
  12446. * Gets the number of particles active at the same time.
  12447. * @returns The number of active particles.
  12448. */
  12449. getActiveCount(): number;
  12450. /**
  12451. * Returns the string "ParticleSystem"
  12452. * @returns a string containing the class name
  12453. */
  12454. getClassName(): string;
  12455. /**
  12456. * Gets a boolean indicating that the system is stopping
  12457. * @returns true if the system is currently stopping
  12458. */
  12459. isStopping(): boolean;
  12460. /**
  12461. * Gets the custom effect used to render the particles
  12462. * @param blendMode Blend mode for which the effect should be retrieved
  12463. * @returns The effect
  12464. */
  12465. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12466. /**
  12467. * Sets the custom effect used to render the particles
  12468. * @param effect The effect to set
  12469. * @param blendMode Blend mode for which the effect should be set
  12470. */
  12471. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12472. /** @hidden */
  12473. private _onBeforeDrawParticlesObservable;
  12474. /**
  12475. * Observable that will be called just before the particles are drawn
  12476. */
  12477. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12478. /**
  12479. * Gets the name of the particle vertex shader
  12480. */
  12481. get vertexShaderName(): string;
  12482. /**
  12483. * Instantiates a particle system.
  12484. * 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.
  12485. * @param name The name of the particle system
  12486. * @param capacity The max number of particles alive at the same time
  12487. * @param scene The scene the particle system belongs to
  12488. * @param customEffect a custom effect used to change the way particles are rendered by default
  12489. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12490. * @param epsilon Offset used to render the particles
  12491. */
  12492. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12493. private _addFactorGradient;
  12494. private _removeFactorGradient;
  12495. /**
  12496. * Adds a new life time gradient
  12497. * @param gradient defines the gradient to use (between 0 and 1)
  12498. * @param factor defines the life time factor to affect to the specified gradient
  12499. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12500. * @returns the current particle system
  12501. */
  12502. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12503. /**
  12504. * Remove a specific life time gradient
  12505. * @param gradient defines the gradient to remove
  12506. * @returns the current particle system
  12507. */
  12508. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12509. /**
  12510. * Adds a new size gradient
  12511. * @param gradient defines the gradient to use (between 0 and 1)
  12512. * @param factor defines the size factor to affect to the specified gradient
  12513. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12514. * @returns the current particle system
  12515. */
  12516. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12517. /**
  12518. * Remove a specific size gradient
  12519. * @param gradient defines the gradient to remove
  12520. * @returns the current particle system
  12521. */
  12522. removeSizeGradient(gradient: number): IParticleSystem;
  12523. /**
  12524. * Adds a new color remap gradient
  12525. * @param gradient defines the gradient to use (between 0 and 1)
  12526. * @param min defines the color remap minimal range
  12527. * @param max defines the color remap maximal range
  12528. * @returns the current particle system
  12529. */
  12530. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12531. /**
  12532. * Remove a specific color remap gradient
  12533. * @param gradient defines the gradient to remove
  12534. * @returns the current particle system
  12535. */
  12536. removeColorRemapGradient(gradient: number): IParticleSystem;
  12537. /**
  12538. * Adds a new alpha remap gradient
  12539. * @param gradient defines the gradient to use (between 0 and 1)
  12540. * @param min defines the alpha remap minimal range
  12541. * @param max defines the alpha remap maximal range
  12542. * @returns the current particle system
  12543. */
  12544. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12545. /**
  12546. * Remove a specific alpha remap gradient
  12547. * @param gradient defines the gradient to remove
  12548. * @returns the current particle system
  12549. */
  12550. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12551. /**
  12552. * Adds a new angular speed gradient
  12553. * @param gradient defines the gradient to use (between 0 and 1)
  12554. * @param factor defines the angular speed to affect to the specified gradient
  12555. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12556. * @returns the current particle system
  12557. */
  12558. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12559. /**
  12560. * Remove a specific angular speed gradient
  12561. * @param gradient defines the gradient to remove
  12562. * @returns the current particle system
  12563. */
  12564. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12565. /**
  12566. * Adds a new velocity gradient
  12567. * @param gradient defines the gradient to use (between 0 and 1)
  12568. * @param factor defines the velocity to affect to the specified gradient
  12569. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12570. * @returns the current particle system
  12571. */
  12572. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12573. /**
  12574. * Remove a specific velocity gradient
  12575. * @param gradient defines the gradient to remove
  12576. * @returns the current particle system
  12577. */
  12578. removeVelocityGradient(gradient: number): IParticleSystem;
  12579. /**
  12580. * Adds a new limit velocity gradient
  12581. * @param gradient defines the gradient to use (between 0 and 1)
  12582. * @param factor defines the limit velocity value to affect to the specified gradient
  12583. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12584. * @returns the current particle system
  12585. */
  12586. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12587. /**
  12588. * Remove a specific limit velocity gradient
  12589. * @param gradient defines the gradient to remove
  12590. * @returns the current particle system
  12591. */
  12592. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12593. /**
  12594. * Adds a new drag gradient
  12595. * @param gradient defines the gradient to use (between 0 and 1)
  12596. * @param factor defines the drag value to affect to the specified gradient
  12597. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12598. * @returns the current particle system
  12599. */
  12600. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12601. /**
  12602. * Remove a specific drag gradient
  12603. * @param gradient defines the gradient to remove
  12604. * @returns the current particle system
  12605. */
  12606. removeDragGradient(gradient: number): IParticleSystem;
  12607. /**
  12608. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12609. * @param gradient defines the gradient to use (between 0 and 1)
  12610. * @param factor defines the emit rate value to affect to the specified gradient
  12611. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12612. * @returns the current particle system
  12613. */
  12614. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12615. /**
  12616. * Remove a specific emit rate gradient
  12617. * @param gradient defines the gradient to remove
  12618. * @returns the current particle system
  12619. */
  12620. removeEmitRateGradient(gradient: number): IParticleSystem;
  12621. /**
  12622. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12623. * @param gradient defines the gradient to use (between 0 and 1)
  12624. * @param factor defines the start size value to affect to the specified gradient
  12625. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12626. * @returns the current particle system
  12627. */
  12628. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12629. /**
  12630. * Remove a specific start size gradient
  12631. * @param gradient defines the gradient to remove
  12632. * @returns the current particle system
  12633. */
  12634. removeStartSizeGradient(gradient: number): IParticleSystem;
  12635. private _createRampGradientTexture;
  12636. /**
  12637. * Gets the current list of ramp gradients.
  12638. * You must use addRampGradient and removeRampGradient to udpate this list
  12639. * @returns the list of ramp gradients
  12640. */
  12641. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12642. /** Force the system to rebuild all gradients that need to be resync */
  12643. forceRefreshGradients(): void;
  12644. private _syncRampGradientTexture;
  12645. /**
  12646. * Adds a new ramp gradient used to remap particle colors
  12647. * @param gradient defines the gradient to use (between 0 and 1)
  12648. * @param color defines the color to affect to the specified gradient
  12649. * @returns the current particle system
  12650. */
  12651. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12652. /**
  12653. * Remove a specific ramp gradient
  12654. * @param gradient defines the gradient to remove
  12655. * @returns the current particle system
  12656. */
  12657. removeRampGradient(gradient: number): ParticleSystem;
  12658. /**
  12659. * Adds a new color gradient
  12660. * @param gradient defines the gradient to use (between 0 and 1)
  12661. * @param color1 defines the color to affect to the specified gradient
  12662. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12663. * @returns this particle system
  12664. */
  12665. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12666. /**
  12667. * Remove a specific color gradient
  12668. * @param gradient defines the gradient to remove
  12669. * @returns this particle system
  12670. */
  12671. removeColorGradient(gradient: number): IParticleSystem;
  12672. private _fetchR;
  12673. protected _reset(): void;
  12674. private _resetEffect;
  12675. private _createVertexBuffers;
  12676. private _createIndexBuffer;
  12677. /**
  12678. * Gets the maximum number of particles active at the same time.
  12679. * @returns The max number of active particles.
  12680. */
  12681. getCapacity(): number;
  12682. /**
  12683. * Gets whether there are still active particles in the system.
  12684. * @returns True if it is alive, otherwise false.
  12685. */
  12686. isAlive(): boolean;
  12687. /**
  12688. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12689. * @returns True if it has been started, otherwise false.
  12690. */
  12691. isStarted(): boolean;
  12692. private _prepareSubEmitterInternalArray;
  12693. /**
  12694. * Starts the particle system and begins to emit
  12695. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12696. */
  12697. start(delay?: number): void;
  12698. /**
  12699. * Stops the particle system.
  12700. * @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.
  12701. */
  12702. stop(stopSubEmitters?: boolean): void;
  12703. /**
  12704. * Remove all active particles
  12705. */
  12706. reset(): void;
  12707. /**
  12708. * @hidden (for internal use only)
  12709. */
  12710. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12711. /**
  12712. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12713. * Its lifetime will start back at 0.
  12714. */
  12715. recycleParticle: (particle: Particle) => void;
  12716. private _stopSubEmitters;
  12717. private _createParticle;
  12718. private _removeFromRoot;
  12719. private _emitFromParticle;
  12720. private _update;
  12721. /** @hidden */
  12722. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12723. /** @hidden */
  12724. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12725. /**
  12726. * Fill the defines array according to the current settings of the particle system
  12727. * @param defines Array to be updated
  12728. * @param blendMode blend mode to take into account when updating the array
  12729. */
  12730. fillDefines(defines: Array<string>, blendMode: number): void;
  12731. /**
  12732. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  12733. * @param uniforms Uniforms array to fill
  12734. * @param attributes Attributes array to fill
  12735. * @param samplers Samplers array to fill
  12736. */
  12737. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  12738. /** @hidden */
  12739. private _getEffect;
  12740. /**
  12741. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12742. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12743. */
  12744. animate(preWarmOnly?: boolean): void;
  12745. private _appendParticleVertices;
  12746. /**
  12747. * Rebuilds the particle system.
  12748. */
  12749. rebuild(): void;
  12750. /**
  12751. * Is this system ready to be used/rendered
  12752. * @return true if the system is ready
  12753. */
  12754. isReady(): boolean;
  12755. private _render;
  12756. /**
  12757. * Renders the particle system in its current state.
  12758. * @returns the current number of particles
  12759. */
  12760. render(): number;
  12761. /**
  12762. * Disposes the particle system and free the associated resources
  12763. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12764. */
  12765. dispose(disposeTexture?: boolean): void;
  12766. /**
  12767. * Clones the particle system.
  12768. * @param name The name of the cloned object
  12769. * @param newEmitter The new emitter to use
  12770. * @returns the cloned particle system
  12771. */
  12772. clone(name: string, newEmitter: any): ParticleSystem;
  12773. /**
  12774. * Serializes the particle system to a JSON object
  12775. * @param serializeTexture defines if the texture must be serialized as well
  12776. * @returns the JSON object
  12777. */
  12778. serialize(serializeTexture?: boolean): any;
  12779. /** @hidden */
  12780. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12781. /** @hidden */
  12782. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12783. /**
  12784. * Parses a JSON object to create a particle system.
  12785. * @param parsedParticleSystem The JSON object to parse
  12786. * @param scene The scene to create the particle system in
  12787. * @param rootUrl The root url to use to load external dependencies like texture
  12788. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12789. * @returns the Parsed particle system
  12790. */
  12791. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12792. }
  12793. }
  12794. declare module BABYLON {
  12795. /**
  12796. * A particle represents one of the element emitted by a particle system.
  12797. * This is mainly define by its coordinates, direction, velocity and age.
  12798. */
  12799. export class Particle {
  12800. /**
  12801. * The particle system the particle belongs to.
  12802. */
  12803. particleSystem: ParticleSystem;
  12804. private static _Count;
  12805. /**
  12806. * Unique ID of the particle
  12807. */
  12808. id: number;
  12809. /**
  12810. * The world position of the particle in the scene.
  12811. */
  12812. position: Vector3;
  12813. /**
  12814. * The world direction of the particle in the scene.
  12815. */
  12816. direction: Vector3;
  12817. /**
  12818. * The color of the particle.
  12819. */
  12820. color: Color4;
  12821. /**
  12822. * The color change of the particle per step.
  12823. */
  12824. colorStep: Color4;
  12825. /**
  12826. * Defines how long will the life of the particle be.
  12827. */
  12828. lifeTime: number;
  12829. /**
  12830. * The current age of the particle.
  12831. */
  12832. age: number;
  12833. /**
  12834. * The current size of the particle.
  12835. */
  12836. size: number;
  12837. /**
  12838. * The current scale of the particle.
  12839. */
  12840. scale: Vector2;
  12841. /**
  12842. * The current angle of the particle.
  12843. */
  12844. angle: number;
  12845. /**
  12846. * Defines how fast is the angle changing.
  12847. */
  12848. angularSpeed: number;
  12849. /**
  12850. * Defines the cell index used by the particle to be rendered from a sprite.
  12851. */
  12852. cellIndex: number;
  12853. /**
  12854. * The information required to support color remapping
  12855. */
  12856. remapData: Vector4;
  12857. /** @hidden */
  12858. _randomCellOffset?: number;
  12859. /** @hidden */
  12860. _initialDirection: Nullable<Vector3>;
  12861. /** @hidden */
  12862. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12863. /** @hidden */
  12864. _initialStartSpriteCellID: number;
  12865. /** @hidden */
  12866. _initialEndSpriteCellID: number;
  12867. /** @hidden */
  12868. _currentColorGradient: Nullable<ColorGradient>;
  12869. /** @hidden */
  12870. _currentColor1: Color4;
  12871. /** @hidden */
  12872. _currentColor2: Color4;
  12873. /** @hidden */
  12874. _currentSizeGradient: Nullable<FactorGradient>;
  12875. /** @hidden */
  12876. _currentSize1: number;
  12877. /** @hidden */
  12878. _currentSize2: number;
  12879. /** @hidden */
  12880. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12881. /** @hidden */
  12882. _currentAngularSpeed1: number;
  12883. /** @hidden */
  12884. _currentAngularSpeed2: number;
  12885. /** @hidden */
  12886. _currentVelocityGradient: Nullable<FactorGradient>;
  12887. /** @hidden */
  12888. _currentVelocity1: number;
  12889. /** @hidden */
  12890. _currentVelocity2: number;
  12891. /** @hidden */
  12892. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12893. /** @hidden */
  12894. _currentLimitVelocity1: number;
  12895. /** @hidden */
  12896. _currentLimitVelocity2: number;
  12897. /** @hidden */
  12898. _currentDragGradient: Nullable<FactorGradient>;
  12899. /** @hidden */
  12900. _currentDrag1: number;
  12901. /** @hidden */
  12902. _currentDrag2: number;
  12903. /** @hidden */
  12904. _randomNoiseCoordinates1: Vector3;
  12905. /** @hidden */
  12906. _randomNoiseCoordinates2: Vector3;
  12907. /** @hidden */
  12908. _localPosition?: Vector3;
  12909. /**
  12910. * Creates a new instance Particle
  12911. * @param particleSystem the particle system the particle belongs to
  12912. */
  12913. constructor(
  12914. /**
  12915. * The particle system the particle belongs to.
  12916. */
  12917. particleSystem: ParticleSystem);
  12918. private updateCellInfoFromSystem;
  12919. /**
  12920. * Defines how the sprite cell index is updated for the particle
  12921. */
  12922. updateCellIndex(): void;
  12923. /** @hidden */
  12924. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12925. /** @hidden */
  12926. _inheritParticleInfoToSubEmitters(): void;
  12927. /** @hidden */
  12928. _reset(): void;
  12929. /**
  12930. * Copy the properties of particle to another one.
  12931. * @param other the particle to copy the information to.
  12932. */
  12933. copyTo(other: Particle): void;
  12934. }
  12935. }
  12936. declare module BABYLON {
  12937. /**
  12938. * Particle emitter represents a volume emitting particles.
  12939. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12940. */
  12941. export interface IParticleEmitterType {
  12942. /**
  12943. * Called by the particle System when the direction is computed for the created particle.
  12944. * @param worldMatrix is the world matrix of the particle system
  12945. * @param directionToUpdate is the direction vector to update with the result
  12946. * @param particle is the particle we are computed the direction for
  12947. * @param isLocal defines if the direction should be set in local space
  12948. */
  12949. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12950. /**
  12951. * Called by the particle System when the position is computed for the created particle.
  12952. * @param worldMatrix is the world matrix of the particle system
  12953. * @param positionToUpdate is the position vector to update with the result
  12954. * @param particle is the particle we are computed the position for
  12955. * @param isLocal defines if the position should be set in local space
  12956. */
  12957. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12958. /**
  12959. * Clones the current emitter and returns a copy of it
  12960. * @returns the new emitter
  12961. */
  12962. clone(): IParticleEmitterType;
  12963. /**
  12964. * Called by the GPUParticleSystem to setup the update shader
  12965. * @param effect defines the update shader
  12966. */
  12967. applyToShader(effect: Effect): void;
  12968. /**
  12969. * Returns a string to use to update the GPU particles update shader
  12970. * @returns the effect defines string
  12971. */
  12972. getEffectDefines(): string;
  12973. /**
  12974. * Returns a string representing the class name
  12975. * @returns a string containing the class name
  12976. */
  12977. getClassName(): string;
  12978. /**
  12979. * Serializes the particle system to a JSON object.
  12980. * @returns the JSON object
  12981. */
  12982. serialize(): any;
  12983. /**
  12984. * Parse properties from a JSON object
  12985. * @param serializationObject defines the JSON object
  12986. * @param scene defines the hosting scene
  12987. */
  12988. parse(serializationObject: any, scene: Scene): void;
  12989. }
  12990. }
  12991. declare module BABYLON {
  12992. /**
  12993. * Particle emitter emitting particles from the inside of a box.
  12994. * It emits the particles randomly between 2 given directions.
  12995. */
  12996. export class BoxParticleEmitter implements IParticleEmitterType {
  12997. /**
  12998. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12999. */
  13000. direction1: Vector3;
  13001. /**
  13002. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13003. */
  13004. direction2: Vector3;
  13005. /**
  13006. * 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.
  13007. */
  13008. minEmitBox: Vector3;
  13009. /**
  13010. * 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.
  13011. */
  13012. maxEmitBox: Vector3;
  13013. /**
  13014. * Creates a new instance BoxParticleEmitter
  13015. */
  13016. constructor();
  13017. /**
  13018. * Called by the particle System when the direction is computed for the created particle.
  13019. * @param worldMatrix is the world matrix of the particle system
  13020. * @param directionToUpdate is the direction vector to update with the result
  13021. * @param particle is the particle we are computed the direction for
  13022. * @param isLocal defines if the direction should be set in local space
  13023. */
  13024. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13025. /**
  13026. * Called by the particle System when the position is computed for the created particle.
  13027. * @param worldMatrix is the world matrix of the particle system
  13028. * @param positionToUpdate is the position vector to update with the result
  13029. * @param particle is the particle we are computed the position for
  13030. * @param isLocal defines if the position should be set in local space
  13031. */
  13032. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13033. /**
  13034. * Clones the current emitter and returns a copy of it
  13035. * @returns the new emitter
  13036. */
  13037. clone(): BoxParticleEmitter;
  13038. /**
  13039. * Called by the GPUParticleSystem to setup the update shader
  13040. * @param effect defines the update shader
  13041. */
  13042. applyToShader(effect: Effect): void;
  13043. /**
  13044. * Returns a string to use to update the GPU particles update shader
  13045. * @returns a string containng the defines string
  13046. */
  13047. getEffectDefines(): string;
  13048. /**
  13049. * Returns the string "BoxParticleEmitter"
  13050. * @returns a string containing the class name
  13051. */
  13052. getClassName(): string;
  13053. /**
  13054. * Serializes the particle system to a JSON object.
  13055. * @returns the JSON object
  13056. */
  13057. serialize(): any;
  13058. /**
  13059. * Parse properties from a JSON object
  13060. * @param serializationObject defines the JSON object
  13061. */
  13062. parse(serializationObject: any): void;
  13063. }
  13064. }
  13065. declare module BABYLON {
  13066. /**
  13067. * Particle emitter emitting particles from the inside of a cone.
  13068. * It emits the particles alongside the cone volume from the base to the particle.
  13069. * The emission direction might be randomized.
  13070. */
  13071. export class ConeParticleEmitter implements IParticleEmitterType {
  13072. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13073. directionRandomizer: number;
  13074. private _radius;
  13075. private _angle;
  13076. private _height;
  13077. /**
  13078. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13079. */
  13080. radiusRange: number;
  13081. /**
  13082. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13083. */
  13084. heightRange: number;
  13085. /**
  13086. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13087. */
  13088. emitFromSpawnPointOnly: boolean;
  13089. /**
  13090. * Gets or sets the radius of the emission cone
  13091. */
  13092. get radius(): number;
  13093. set radius(value: number);
  13094. /**
  13095. * Gets or sets the angle of the emission cone
  13096. */
  13097. get angle(): number;
  13098. set angle(value: number);
  13099. private _buildHeight;
  13100. /**
  13101. * Creates a new instance ConeParticleEmitter
  13102. * @param radius the radius of the emission cone (1 by default)
  13103. * @param angle the cone base angle (PI by default)
  13104. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13105. */
  13106. constructor(radius?: number, angle?: number,
  13107. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13108. directionRandomizer?: number);
  13109. /**
  13110. * Called by the particle System when the direction is computed for the created particle.
  13111. * @param worldMatrix is the world matrix of the particle system
  13112. * @param directionToUpdate is the direction vector to update with the result
  13113. * @param particle is the particle we are computed the direction for
  13114. * @param isLocal defines if the direction should be set in local space
  13115. */
  13116. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13117. /**
  13118. * Called by the particle System when the position is computed for the created particle.
  13119. * @param worldMatrix is the world matrix of the particle system
  13120. * @param positionToUpdate is the position vector to update with the result
  13121. * @param particle is the particle we are computed the position for
  13122. * @param isLocal defines if the position should be set in local space
  13123. */
  13124. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13125. /**
  13126. * Clones the current emitter and returns a copy of it
  13127. * @returns the new emitter
  13128. */
  13129. clone(): ConeParticleEmitter;
  13130. /**
  13131. * Called by the GPUParticleSystem to setup the update shader
  13132. * @param effect defines the update shader
  13133. */
  13134. applyToShader(effect: Effect): void;
  13135. /**
  13136. * Returns a string to use to update the GPU particles update shader
  13137. * @returns a string containng the defines string
  13138. */
  13139. getEffectDefines(): string;
  13140. /**
  13141. * Returns the string "ConeParticleEmitter"
  13142. * @returns a string containing the class name
  13143. */
  13144. getClassName(): string;
  13145. /**
  13146. * Serializes the particle system to a JSON object.
  13147. * @returns the JSON object
  13148. */
  13149. serialize(): any;
  13150. /**
  13151. * Parse properties from a JSON object
  13152. * @param serializationObject defines the JSON object
  13153. */
  13154. parse(serializationObject: any): void;
  13155. }
  13156. }
  13157. declare module BABYLON {
  13158. /**
  13159. * Particle emitter emitting particles from the inside of a cylinder.
  13160. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13161. */
  13162. export class CylinderParticleEmitter implements IParticleEmitterType {
  13163. /**
  13164. * The radius of the emission cylinder.
  13165. */
  13166. radius: number;
  13167. /**
  13168. * The height of the emission cylinder.
  13169. */
  13170. height: number;
  13171. /**
  13172. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13173. */
  13174. radiusRange: number;
  13175. /**
  13176. * How much to randomize the particle direction [0-1].
  13177. */
  13178. directionRandomizer: number;
  13179. /**
  13180. * Creates a new instance CylinderParticleEmitter
  13181. * @param radius the radius of the emission cylinder (1 by default)
  13182. * @param height the height of the emission cylinder (1 by default)
  13183. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13184. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13185. */
  13186. constructor(
  13187. /**
  13188. * The radius of the emission cylinder.
  13189. */
  13190. radius?: number,
  13191. /**
  13192. * The height of the emission cylinder.
  13193. */
  13194. height?: number,
  13195. /**
  13196. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13197. */
  13198. radiusRange?: number,
  13199. /**
  13200. * How much to randomize the particle direction [0-1].
  13201. */
  13202. directionRandomizer?: number);
  13203. /**
  13204. * Called by the particle System when the direction is computed for the created particle.
  13205. * @param worldMatrix is the world matrix of the particle system
  13206. * @param directionToUpdate is the direction vector to update with the result
  13207. * @param particle is the particle we are computed the direction for
  13208. * @param isLocal defines if the direction should be set in local space
  13209. */
  13210. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13211. /**
  13212. * Called by the particle System when the position is computed for the created particle.
  13213. * @param worldMatrix is the world matrix of the particle system
  13214. * @param positionToUpdate is the position vector to update with the result
  13215. * @param particle is the particle we are computed the position for
  13216. * @param isLocal defines if the position should be set in local space
  13217. */
  13218. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13219. /**
  13220. * Clones the current emitter and returns a copy of it
  13221. * @returns the new emitter
  13222. */
  13223. clone(): CylinderParticleEmitter;
  13224. /**
  13225. * Called by the GPUParticleSystem to setup the update shader
  13226. * @param effect defines the update shader
  13227. */
  13228. applyToShader(effect: Effect): void;
  13229. /**
  13230. * Returns a string to use to update the GPU particles update shader
  13231. * @returns a string containng the defines string
  13232. */
  13233. getEffectDefines(): string;
  13234. /**
  13235. * Returns the string "CylinderParticleEmitter"
  13236. * @returns a string containing the class name
  13237. */
  13238. getClassName(): string;
  13239. /**
  13240. * Serializes the particle system to a JSON object.
  13241. * @returns the JSON object
  13242. */
  13243. serialize(): any;
  13244. /**
  13245. * Parse properties from a JSON object
  13246. * @param serializationObject defines the JSON object
  13247. */
  13248. parse(serializationObject: any): void;
  13249. }
  13250. /**
  13251. * Particle emitter emitting particles from the inside of a cylinder.
  13252. * It emits the particles randomly between two vectors.
  13253. */
  13254. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13255. /**
  13256. * The min limit of the emission direction.
  13257. */
  13258. direction1: Vector3;
  13259. /**
  13260. * The max limit of the emission direction.
  13261. */
  13262. direction2: Vector3;
  13263. /**
  13264. * Creates a new instance CylinderDirectedParticleEmitter
  13265. * @param radius the radius of the emission cylinder (1 by default)
  13266. * @param height the height of the emission cylinder (1 by default)
  13267. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13268. * @param direction1 the min limit of the emission direction (up vector by default)
  13269. * @param direction2 the max limit of the emission direction (up vector by default)
  13270. */
  13271. constructor(radius?: number, height?: number, radiusRange?: number,
  13272. /**
  13273. * The min limit of the emission direction.
  13274. */
  13275. direction1?: Vector3,
  13276. /**
  13277. * The max limit of the emission direction.
  13278. */
  13279. direction2?: Vector3);
  13280. /**
  13281. * Called by the particle System when the direction is computed for the created particle.
  13282. * @param worldMatrix is the world matrix of the particle system
  13283. * @param directionToUpdate is the direction vector to update with the result
  13284. * @param particle is the particle we are computed the direction for
  13285. */
  13286. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13287. /**
  13288. * Clones the current emitter and returns a copy of it
  13289. * @returns the new emitter
  13290. */
  13291. clone(): CylinderDirectedParticleEmitter;
  13292. /**
  13293. * Called by the GPUParticleSystem to setup the update shader
  13294. * @param effect defines the update shader
  13295. */
  13296. applyToShader(effect: Effect): void;
  13297. /**
  13298. * Returns a string to use to update the GPU particles update shader
  13299. * @returns a string containng the defines string
  13300. */
  13301. getEffectDefines(): string;
  13302. /**
  13303. * Returns the string "CylinderDirectedParticleEmitter"
  13304. * @returns a string containing the class name
  13305. */
  13306. getClassName(): string;
  13307. /**
  13308. * Serializes the particle system to a JSON object.
  13309. * @returns the JSON object
  13310. */
  13311. serialize(): any;
  13312. /**
  13313. * Parse properties from a JSON object
  13314. * @param serializationObject defines the JSON object
  13315. */
  13316. parse(serializationObject: any): void;
  13317. }
  13318. }
  13319. declare module BABYLON {
  13320. /**
  13321. * Particle emitter emitting particles from the inside of a hemisphere.
  13322. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13323. */
  13324. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13325. /**
  13326. * The radius of the emission hemisphere.
  13327. */
  13328. radius: number;
  13329. /**
  13330. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13331. */
  13332. radiusRange: number;
  13333. /**
  13334. * How much to randomize the particle direction [0-1].
  13335. */
  13336. directionRandomizer: number;
  13337. /**
  13338. * Creates a new instance HemisphericParticleEmitter
  13339. * @param radius the radius of the emission hemisphere (1 by default)
  13340. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13341. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13342. */
  13343. constructor(
  13344. /**
  13345. * The radius of the emission hemisphere.
  13346. */
  13347. radius?: number,
  13348. /**
  13349. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13350. */
  13351. radiusRange?: number,
  13352. /**
  13353. * How much to randomize the particle direction [0-1].
  13354. */
  13355. directionRandomizer?: number);
  13356. /**
  13357. * Called by the particle System when the direction is computed for the created particle.
  13358. * @param worldMatrix is the world matrix of the particle system
  13359. * @param directionToUpdate is the direction vector to update with the result
  13360. * @param particle is the particle we are computed the direction for
  13361. * @param isLocal defines if the direction should be set in local space
  13362. */
  13363. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13364. /**
  13365. * Called by the particle System when the position is computed for the created particle.
  13366. * @param worldMatrix is the world matrix of the particle system
  13367. * @param positionToUpdate is the position vector to update with the result
  13368. * @param particle is the particle we are computed the position for
  13369. * @param isLocal defines if the position should be set in local space
  13370. */
  13371. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13372. /**
  13373. * Clones the current emitter and returns a copy of it
  13374. * @returns the new emitter
  13375. */
  13376. clone(): HemisphericParticleEmitter;
  13377. /**
  13378. * Called by the GPUParticleSystem to setup the update shader
  13379. * @param effect defines the update shader
  13380. */
  13381. applyToShader(effect: Effect): void;
  13382. /**
  13383. * Returns a string to use to update the GPU particles update shader
  13384. * @returns a string containng the defines string
  13385. */
  13386. getEffectDefines(): string;
  13387. /**
  13388. * Returns the string "HemisphericParticleEmitter"
  13389. * @returns a string containing the class name
  13390. */
  13391. getClassName(): string;
  13392. /**
  13393. * Serializes the particle system to a JSON object.
  13394. * @returns the JSON object
  13395. */
  13396. serialize(): any;
  13397. /**
  13398. * Parse properties from a JSON object
  13399. * @param serializationObject defines the JSON object
  13400. */
  13401. parse(serializationObject: any): void;
  13402. }
  13403. }
  13404. declare module BABYLON {
  13405. /**
  13406. * Particle emitter emitting particles from a point.
  13407. * It emits the particles randomly between 2 given directions.
  13408. */
  13409. export class PointParticleEmitter implements IParticleEmitterType {
  13410. /**
  13411. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13412. */
  13413. direction1: Vector3;
  13414. /**
  13415. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13416. */
  13417. direction2: Vector3;
  13418. /**
  13419. * Creates a new instance PointParticleEmitter
  13420. */
  13421. constructor();
  13422. /**
  13423. * Called by the particle System when the direction is computed for the created particle.
  13424. * @param worldMatrix is the world matrix of the particle system
  13425. * @param directionToUpdate is the direction vector to update with the result
  13426. * @param particle is the particle we are computed the direction for
  13427. * @param isLocal defines if the direction should be set in local space
  13428. */
  13429. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13430. /**
  13431. * Called by the particle System when the position is computed for the created particle.
  13432. * @param worldMatrix is the world matrix of the particle system
  13433. * @param positionToUpdate is the position vector to update with the result
  13434. * @param particle is the particle we are computed the position for
  13435. * @param isLocal defines if the position should be set in local space
  13436. */
  13437. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13438. /**
  13439. * Clones the current emitter and returns a copy of it
  13440. * @returns the new emitter
  13441. */
  13442. clone(): PointParticleEmitter;
  13443. /**
  13444. * Called by the GPUParticleSystem to setup the update shader
  13445. * @param effect defines the update shader
  13446. */
  13447. applyToShader(effect: Effect): void;
  13448. /**
  13449. * Returns a string to use to update the GPU particles update shader
  13450. * @returns a string containng the defines string
  13451. */
  13452. getEffectDefines(): string;
  13453. /**
  13454. * Returns the string "PointParticleEmitter"
  13455. * @returns a string containing the class name
  13456. */
  13457. getClassName(): string;
  13458. /**
  13459. * Serializes the particle system to a JSON object.
  13460. * @returns the JSON object
  13461. */
  13462. serialize(): any;
  13463. /**
  13464. * Parse properties from a JSON object
  13465. * @param serializationObject defines the JSON object
  13466. */
  13467. parse(serializationObject: any): void;
  13468. }
  13469. }
  13470. declare module BABYLON {
  13471. /**
  13472. * Particle emitter emitting particles from the inside of a sphere.
  13473. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13474. */
  13475. export class SphereParticleEmitter implements IParticleEmitterType {
  13476. /**
  13477. * The radius of the emission sphere.
  13478. */
  13479. radius: number;
  13480. /**
  13481. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13482. */
  13483. radiusRange: number;
  13484. /**
  13485. * How much to randomize the particle direction [0-1].
  13486. */
  13487. directionRandomizer: number;
  13488. /**
  13489. * Creates a new instance SphereParticleEmitter
  13490. * @param radius the radius of the emission sphere (1 by default)
  13491. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13492. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13493. */
  13494. constructor(
  13495. /**
  13496. * The radius of the emission sphere.
  13497. */
  13498. radius?: number,
  13499. /**
  13500. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13501. */
  13502. radiusRange?: number,
  13503. /**
  13504. * How much to randomize the particle direction [0-1].
  13505. */
  13506. directionRandomizer?: number);
  13507. /**
  13508. * Called by the particle System when the direction is computed for the created particle.
  13509. * @param worldMatrix is the world matrix of the particle system
  13510. * @param directionToUpdate is the direction vector to update with the result
  13511. * @param particle is the particle we are computed the direction for
  13512. * @param isLocal defines if the direction should be set in local space
  13513. */
  13514. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13515. /**
  13516. * Called by the particle System when the position is computed for the created particle.
  13517. * @param worldMatrix is the world matrix of the particle system
  13518. * @param positionToUpdate is the position vector to update with the result
  13519. * @param particle is the particle we are computed the position for
  13520. * @param isLocal defines if the position should be set in local space
  13521. */
  13522. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13523. /**
  13524. * Clones the current emitter and returns a copy of it
  13525. * @returns the new emitter
  13526. */
  13527. clone(): SphereParticleEmitter;
  13528. /**
  13529. * Called by the GPUParticleSystem to setup the update shader
  13530. * @param effect defines the update shader
  13531. */
  13532. applyToShader(effect: Effect): void;
  13533. /**
  13534. * Returns a string to use to update the GPU particles update shader
  13535. * @returns a string containng the defines string
  13536. */
  13537. getEffectDefines(): string;
  13538. /**
  13539. * Returns the string "SphereParticleEmitter"
  13540. * @returns a string containing the class name
  13541. */
  13542. getClassName(): string;
  13543. /**
  13544. * Serializes the particle system to a JSON object.
  13545. * @returns the JSON object
  13546. */
  13547. serialize(): any;
  13548. /**
  13549. * Parse properties from a JSON object
  13550. * @param serializationObject defines the JSON object
  13551. */
  13552. parse(serializationObject: any): void;
  13553. }
  13554. /**
  13555. * Particle emitter emitting particles from the inside of a sphere.
  13556. * It emits the particles randomly between two vectors.
  13557. */
  13558. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13559. /**
  13560. * The min limit of the emission direction.
  13561. */
  13562. direction1: Vector3;
  13563. /**
  13564. * The max limit of the emission direction.
  13565. */
  13566. direction2: Vector3;
  13567. /**
  13568. * Creates a new instance SphereDirectedParticleEmitter
  13569. * @param radius the radius of the emission sphere (1 by default)
  13570. * @param direction1 the min limit of the emission direction (up vector by default)
  13571. * @param direction2 the max limit of the emission direction (up vector by default)
  13572. */
  13573. constructor(radius?: number,
  13574. /**
  13575. * The min limit of the emission direction.
  13576. */
  13577. direction1?: Vector3,
  13578. /**
  13579. * The max limit of the emission direction.
  13580. */
  13581. direction2?: Vector3);
  13582. /**
  13583. * Called by the particle System when the direction is computed for the created particle.
  13584. * @param worldMatrix is the world matrix of the particle system
  13585. * @param directionToUpdate is the direction vector to update with the result
  13586. * @param particle is the particle we are computed the direction for
  13587. */
  13588. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13589. /**
  13590. * Clones the current emitter and returns a copy of it
  13591. * @returns the new emitter
  13592. */
  13593. clone(): SphereDirectedParticleEmitter;
  13594. /**
  13595. * Called by the GPUParticleSystem to setup the update shader
  13596. * @param effect defines the update shader
  13597. */
  13598. applyToShader(effect: Effect): void;
  13599. /**
  13600. * Returns a string to use to update the GPU particles update shader
  13601. * @returns a string containng the defines string
  13602. */
  13603. getEffectDefines(): string;
  13604. /**
  13605. * Returns the string "SphereDirectedParticleEmitter"
  13606. * @returns a string containing the class name
  13607. */
  13608. getClassName(): string;
  13609. /**
  13610. * Serializes the particle system to a JSON object.
  13611. * @returns the JSON object
  13612. */
  13613. serialize(): any;
  13614. /**
  13615. * Parse properties from a JSON object
  13616. * @param serializationObject defines the JSON object
  13617. */
  13618. parse(serializationObject: any): void;
  13619. }
  13620. }
  13621. declare module BABYLON {
  13622. /**
  13623. * Particle emitter emitting particles from a custom list of positions.
  13624. */
  13625. export class CustomParticleEmitter implements IParticleEmitterType {
  13626. /**
  13627. * Gets or sets the position generator that will create the inital position of each particle.
  13628. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13629. */
  13630. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13631. /**
  13632. * Gets or sets the destination generator that will create the final destination of each particle.
  13633. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13634. */
  13635. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13636. /**
  13637. * Creates a new instance CustomParticleEmitter
  13638. */
  13639. constructor();
  13640. /**
  13641. * Called by the particle System when the direction is computed for the created particle.
  13642. * @param worldMatrix is the world matrix of the particle system
  13643. * @param directionToUpdate is the direction vector to update with the result
  13644. * @param particle is the particle we are computed the direction for
  13645. * @param isLocal defines if the direction should be set in local space
  13646. */
  13647. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13648. /**
  13649. * Called by the particle System when the position is computed for the created particle.
  13650. * @param worldMatrix is the world matrix of the particle system
  13651. * @param positionToUpdate is the position vector to update with the result
  13652. * @param particle is the particle we are computed the position for
  13653. * @param isLocal defines if the position should be set in local space
  13654. */
  13655. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13656. /**
  13657. * Clones the current emitter and returns a copy of it
  13658. * @returns the new emitter
  13659. */
  13660. clone(): CustomParticleEmitter;
  13661. /**
  13662. * Called by the GPUParticleSystem to setup the update shader
  13663. * @param effect defines the update shader
  13664. */
  13665. applyToShader(effect: Effect): void;
  13666. /**
  13667. * Returns a string to use to update the GPU particles update shader
  13668. * @returns a string containng the defines string
  13669. */
  13670. getEffectDefines(): string;
  13671. /**
  13672. * Returns the string "PointParticleEmitter"
  13673. * @returns a string containing the class name
  13674. */
  13675. getClassName(): string;
  13676. /**
  13677. * Serializes the particle system to a JSON object.
  13678. * @returns the JSON object
  13679. */
  13680. serialize(): any;
  13681. /**
  13682. * Parse properties from a JSON object
  13683. * @param serializationObject defines the JSON object
  13684. */
  13685. parse(serializationObject: any): void;
  13686. }
  13687. }
  13688. declare module BABYLON {
  13689. /**
  13690. * Particle emitter emitting particles from the inside of a box.
  13691. * It emits the particles randomly between 2 given directions.
  13692. */
  13693. export class MeshParticleEmitter implements IParticleEmitterType {
  13694. private _indices;
  13695. private _positions;
  13696. private _normals;
  13697. private _storedNormal;
  13698. private _mesh;
  13699. /**
  13700. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13701. */
  13702. direction1: Vector3;
  13703. /**
  13704. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13705. */
  13706. direction2: Vector3;
  13707. /**
  13708. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13709. */
  13710. useMeshNormalsForDirection: boolean;
  13711. /** Defines the mesh to use as source */
  13712. get mesh(): Nullable<AbstractMesh>;
  13713. set mesh(value: Nullable<AbstractMesh>);
  13714. /**
  13715. * Creates a new instance MeshParticleEmitter
  13716. * @param mesh defines the mesh to use as source
  13717. */
  13718. constructor(mesh?: Nullable<AbstractMesh>);
  13719. /**
  13720. * Called by the particle System when the direction is computed for the created particle.
  13721. * @param worldMatrix is the world matrix of the particle system
  13722. * @param directionToUpdate is the direction vector to update with the result
  13723. * @param particle is the particle we are computed the direction for
  13724. * @param isLocal defines if the direction should be set in local space
  13725. */
  13726. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13727. /**
  13728. * Called by the particle System when the position is computed for the created particle.
  13729. * @param worldMatrix is the world matrix of the particle system
  13730. * @param positionToUpdate is the position vector to update with the result
  13731. * @param particle is the particle we are computed the position for
  13732. * @param isLocal defines if the position should be set in local space
  13733. */
  13734. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13735. /**
  13736. * Clones the current emitter and returns a copy of it
  13737. * @returns the new emitter
  13738. */
  13739. clone(): MeshParticleEmitter;
  13740. /**
  13741. * Called by the GPUParticleSystem to setup the update shader
  13742. * @param effect defines the update shader
  13743. */
  13744. applyToShader(effect: Effect): void;
  13745. /**
  13746. * Returns a string to use to update the GPU particles update shader
  13747. * @returns a string containng the defines string
  13748. */
  13749. getEffectDefines(): string;
  13750. /**
  13751. * Returns the string "BoxParticleEmitter"
  13752. * @returns a string containing the class name
  13753. */
  13754. getClassName(): string;
  13755. /**
  13756. * Serializes the particle system to a JSON object.
  13757. * @returns the JSON object
  13758. */
  13759. serialize(): any;
  13760. /**
  13761. * Parse properties from a JSON object
  13762. * @param serializationObject defines the JSON object
  13763. * @param scene defines the hosting scene
  13764. */
  13765. parse(serializationObject: any, scene: Scene): void;
  13766. }
  13767. }
  13768. declare module BABYLON {
  13769. /**
  13770. * Interface representing a particle system in Babylon.js.
  13771. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13772. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13773. */
  13774. export interface IParticleSystem {
  13775. /**
  13776. * List of animations used by the particle system.
  13777. */
  13778. animations: Animation[];
  13779. /**
  13780. * The id of the Particle system.
  13781. */
  13782. id: string;
  13783. /**
  13784. * The name of the Particle system.
  13785. */
  13786. name: string;
  13787. /**
  13788. * The emitter represents the Mesh or position we are attaching the particle system to.
  13789. */
  13790. emitter: Nullable<AbstractMesh | Vector3>;
  13791. /**
  13792. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13793. */
  13794. isBillboardBased: boolean;
  13795. /**
  13796. * The rendering group used by the Particle system to chose when to render.
  13797. */
  13798. renderingGroupId: number;
  13799. /**
  13800. * The layer mask we are rendering the particles through.
  13801. */
  13802. layerMask: number;
  13803. /**
  13804. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13805. */
  13806. updateSpeed: number;
  13807. /**
  13808. * The amount of time the particle system is running (depends of the overall update speed).
  13809. */
  13810. targetStopDuration: number;
  13811. /**
  13812. * The texture used to render each particle. (this can be a spritesheet)
  13813. */
  13814. particleTexture: Nullable<Texture>;
  13815. /**
  13816. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13817. */
  13818. blendMode: number;
  13819. /**
  13820. * Minimum life time of emitting particles.
  13821. */
  13822. minLifeTime: number;
  13823. /**
  13824. * Maximum life time of emitting particles.
  13825. */
  13826. maxLifeTime: number;
  13827. /**
  13828. * Minimum Size of emitting particles.
  13829. */
  13830. minSize: number;
  13831. /**
  13832. * Maximum Size of emitting particles.
  13833. */
  13834. maxSize: number;
  13835. /**
  13836. * Minimum scale of emitting particles on X axis.
  13837. */
  13838. minScaleX: number;
  13839. /**
  13840. * Maximum scale of emitting particles on X axis.
  13841. */
  13842. maxScaleX: number;
  13843. /**
  13844. * Minimum scale of emitting particles on Y axis.
  13845. */
  13846. minScaleY: number;
  13847. /**
  13848. * Maximum scale of emitting particles on Y axis.
  13849. */
  13850. maxScaleY: number;
  13851. /**
  13852. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13853. */
  13854. color1: Color4;
  13855. /**
  13856. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13857. */
  13858. color2: Color4;
  13859. /**
  13860. * Color the particle will have at the end of its lifetime.
  13861. */
  13862. colorDead: Color4;
  13863. /**
  13864. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13865. */
  13866. emitRate: number;
  13867. /**
  13868. * You can use gravity if you want to give an orientation to your particles.
  13869. */
  13870. gravity: Vector3;
  13871. /**
  13872. * Minimum power of emitting particles.
  13873. */
  13874. minEmitPower: number;
  13875. /**
  13876. * Maximum power of emitting particles.
  13877. */
  13878. maxEmitPower: number;
  13879. /**
  13880. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13881. */
  13882. minAngularSpeed: number;
  13883. /**
  13884. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13885. */
  13886. maxAngularSpeed: number;
  13887. /**
  13888. * Gets or sets the minimal initial rotation in radians.
  13889. */
  13890. minInitialRotation: number;
  13891. /**
  13892. * Gets or sets the maximal initial rotation in radians.
  13893. */
  13894. maxInitialRotation: number;
  13895. /**
  13896. * The particle emitter type defines the emitter used by the particle system.
  13897. * It can be for example box, sphere, or cone...
  13898. */
  13899. particleEmitterType: Nullable<IParticleEmitterType>;
  13900. /**
  13901. * Defines the delay in milliseconds before starting the system (0 by default)
  13902. */
  13903. startDelay: number;
  13904. /**
  13905. * 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
  13906. */
  13907. preWarmCycles: number;
  13908. /**
  13909. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13910. */
  13911. preWarmStepOffset: number;
  13912. /**
  13913. * 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)
  13914. */
  13915. spriteCellChangeSpeed: number;
  13916. /**
  13917. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13918. */
  13919. startSpriteCellID: number;
  13920. /**
  13921. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13922. */
  13923. endSpriteCellID: number;
  13924. /**
  13925. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13926. */
  13927. spriteCellWidth: number;
  13928. /**
  13929. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13930. */
  13931. spriteCellHeight: number;
  13932. /**
  13933. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13934. */
  13935. spriteRandomStartCell: boolean;
  13936. /**
  13937. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13938. */
  13939. isAnimationSheetEnabled: boolean;
  13940. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13941. translationPivot: Vector2;
  13942. /**
  13943. * Gets or sets a texture used to add random noise to particle positions
  13944. */
  13945. noiseTexture: Nullable<BaseTexture>;
  13946. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13947. noiseStrength: Vector3;
  13948. /**
  13949. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13950. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13951. */
  13952. billboardMode: number;
  13953. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13954. limitVelocityDamping: number;
  13955. /**
  13956. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13957. */
  13958. beginAnimationOnStart: boolean;
  13959. /**
  13960. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13961. */
  13962. beginAnimationFrom: number;
  13963. /**
  13964. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13965. */
  13966. beginAnimationTo: number;
  13967. /**
  13968. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13969. */
  13970. beginAnimationLoop: boolean;
  13971. /**
  13972. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13973. */
  13974. disposeOnStop: boolean;
  13975. /**
  13976. * Specifies if the particles are updated in emitter local space or world space
  13977. */
  13978. isLocal: boolean;
  13979. /** Snippet ID if the particle system was created from the snippet server */
  13980. snippetId: string;
  13981. /**
  13982. * Gets the maximum number of particles active at the same time.
  13983. * @returns The max number of active particles.
  13984. */
  13985. getCapacity(): number;
  13986. /**
  13987. * Gets the number of particles active at the same time.
  13988. * @returns The number of active particles.
  13989. */
  13990. getActiveCount(): number;
  13991. /**
  13992. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13993. * @returns True if it has been started, otherwise false.
  13994. */
  13995. isStarted(): boolean;
  13996. /**
  13997. * Animates the particle system for this frame.
  13998. */
  13999. animate(): void;
  14000. /**
  14001. * Renders the particle system in its current state.
  14002. * @returns the current number of particles
  14003. */
  14004. render(): number;
  14005. /**
  14006. * Dispose the particle system and frees its associated resources.
  14007. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14008. */
  14009. dispose(disposeTexture?: boolean): void;
  14010. /**
  14011. * An event triggered when the system is disposed
  14012. */
  14013. onDisposeObservable: Observable<IParticleSystem>;
  14014. /**
  14015. * Clones the particle system.
  14016. * @param name The name of the cloned object
  14017. * @param newEmitter The new emitter to use
  14018. * @returns the cloned particle system
  14019. */
  14020. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14021. /**
  14022. * Serializes the particle system to a JSON object
  14023. * @param serializeTexture defines if the texture must be serialized as well
  14024. * @returns the JSON object
  14025. */
  14026. serialize(serializeTexture: boolean): any;
  14027. /**
  14028. * Rebuild the particle system
  14029. */
  14030. rebuild(): void;
  14031. /** Force the system to rebuild all gradients that need to be resync */
  14032. forceRefreshGradients(): void;
  14033. /**
  14034. * Starts the particle system and begins to emit
  14035. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14036. */
  14037. start(delay?: number): void;
  14038. /**
  14039. * Stops the particle system.
  14040. */
  14041. stop(): void;
  14042. /**
  14043. * Remove all active particles
  14044. */
  14045. reset(): void;
  14046. /**
  14047. * Gets a boolean indicating that the system is stopping
  14048. * @returns true if the system is currently stopping
  14049. */
  14050. isStopping(): boolean;
  14051. /**
  14052. * Is this system ready to be used/rendered
  14053. * @return true if the system is ready
  14054. */
  14055. isReady(): boolean;
  14056. /**
  14057. * Returns the string "ParticleSystem"
  14058. * @returns a string containing the class name
  14059. */
  14060. getClassName(): string;
  14061. /**
  14062. * Gets the custom effect used to render the particles
  14063. * @param blendMode Blend mode for which the effect should be retrieved
  14064. * @returns The effect
  14065. */
  14066. getCustomEffect(blendMode: number): Nullable<Effect>;
  14067. /**
  14068. * Sets the custom effect used to render the particles
  14069. * @param effect The effect to set
  14070. * @param blendMode Blend mode for which the effect should be set
  14071. */
  14072. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14073. /**
  14074. * Fill the defines array according to the current settings of the particle system
  14075. * @param defines Array to be updated
  14076. * @param blendMode blend mode to take into account when updating the array
  14077. */
  14078. fillDefines(defines: Array<string>, blendMode: number): void;
  14079. /**
  14080. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14081. * @param uniforms Uniforms array to fill
  14082. * @param attributes Attributes array to fill
  14083. * @param samplers Samplers array to fill
  14084. */
  14085. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14086. /**
  14087. * Observable that will be called just before the particles are drawn
  14088. */
  14089. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14090. /**
  14091. * Gets the name of the particle vertex shader
  14092. */
  14093. vertexShaderName: string;
  14094. /**
  14095. * Adds a new color gradient
  14096. * @param gradient defines the gradient to use (between 0 and 1)
  14097. * @param color1 defines the color to affect to the specified gradient
  14098. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14099. * @returns the current particle system
  14100. */
  14101. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14102. /**
  14103. * Remove a specific color gradient
  14104. * @param gradient defines the gradient to remove
  14105. * @returns the current particle system
  14106. */
  14107. removeColorGradient(gradient: number): IParticleSystem;
  14108. /**
  14109. * Adds a new size gradient
  14110. * @param gradient defines the gradient to use (between 0 and 1)
  14111. * @param factor defines the size factor to affect to the specified gradient
  14112. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14113. * @returns the current particle system
  14114. */
  14115. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14116. /**
  14117. * Remove a specific size gradient
  14118. * @param gradient defines the gradient to remove
  14119. * @returns the current particle system
  14120. */
  14121. removeSizeGradient(gradient: number): IParticleSystem;
  14122. /**
  14123. * Gets the current list of color gradients.
  14124. * You must use addColorGradient and removeColorGradient to udpate this list
  14125. * @returns the list of color gradients
  14126. */
  14127. getColorGradients(): Nullable<Array<ColorGradient>>;
  14128. /**
  14129. * Gets the current list of size gradients.
  14130. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14131. * @returns the list of size gradients
  14132. */
  14133. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14134. /**
  14135. * Gets the current list of angular speed gradients.
  14136. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14137. * @returns the list of angular speed gradients
  14138. */
  14139. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14140. /**
  14141. * Adds a new angular speed gradient
  14142. * @param gradient defines the gradient to use (between 0 and 1)
  14143. * @param factor defines the angular speed to affect to the specified gradient
  14144. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14145. * @returns the current particle system
  14146. */
  14147. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14148. /**
  14149. * Remove a specific angular speed gradient
  14150. * @param gradient defines the gradient to remove
  14151. * @returns the current particle system
  14152. */
  14153. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14154. /**
  14155. * Gets the current list of velocity gradients.
  14156. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14157. * @returns the list of velocity gradients
  14158. */
  14159. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14160. /**
  14161. * Adds a new velocity gradient
  14162. * @param gradient defines the gradient to use (between 0 and 1)
  14163. * @param factor defines the velocity to affect to the specified gradient
  14164. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14165. * @returns the current particle system
  14166. */
  14167. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14168. /**
  14169. * Remove a specific velocity gradient
  14170. * @param gradient defines the gradient to remove
  14171. * @returns the current particle system
  14172. */
  14173. removeVelocityGradient(gradient: number): IParticleSystem;
  14174. /**
  14175. * Gets the current list of limit velocity gradients.
  14176. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14177. * @returns the list of limit velocity gradients
  14178. */
  14179. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14180. /**
  14181. * Adds a new limit velocity gradient
  14182. * @param gradient defines the gradient to use (between 0 and 1)
  14183. * @param factor defines the limit velocity to affect to the specified gradient
  14184. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14185. * @returns the current particle system
  14186. */
  14187. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14188. /**
  14189. * Remove a specific limit velocity gradient
  14190. * @param gradient defines the gradient to remove
  14191. * @returns the current particle system
  14192. */
  14193. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14194. /**
  14195. * Adds a new drag gradient
  14196. * @param gradient defines the gradient to use (between 0 and 1)
  14197. * @param factor defines the drag to affect to the specified gradient
  14198. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14199. * @returns the current particle system
  14200. */
  14201. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14202. /**
  14203. * Remove a specific drag gradient
  14204. * @param gradient defines the gradient to remove
  14205. * @returns the current particle system
  14206. */
  14207. removeDragGradient(gradient: number): IParticleSystem;
  14208. /**
  14209. * Gets the current list of drag gradients.
  14210. * You must use addDragGradient and removeDragGradient to udpate this list
  14211. * @returns the list of drag gradients
  14212. */
  14213. getDragGradients(): Nullable<Array<FactorGradient>>;
  14214. /**
  14215. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14216. * @param gradient defines the gradient to use (between 0 and 1)
  14217. * @param factor defines the emit rate to affect to the specified gradient
  14218. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14219. * @returns the current particle system
  14220. */
  14221. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14222. /**
  14223. * Remove a specific emit rate gradient
  14224. * @param gradient defines the gradient to remove
  14225. * @returns the current particle system
  14226. */
  14227. removeEmitRateGradient(gradient: number): IParticleSystem;
  14228. /**
  14229. * Gets the current list of emit rate gradients.
  14230. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14231. * @returns the list of emit rate gradients
  14232. */
  14233. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14234. /**
  14235. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14236. * @param gradient defines the gradient to use (between 0 and 1)
  14237. * @param factor defines the start size to affect to the specified gradient
  14238. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14239. * @returns the current particle system
  14240. */
  14241. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14242. /**
  14243. * Remove a specific start size gradient
  14244. * @param gradient defines the gradient to remove
  14245. * @returns the current particle system
  14246. */
  14247. removeStartSizeGradient(gradient: number): IParticleSystem;
  14248. /**
  14249. * Gets the current list of start size gradients.
  14250. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14251. * @returns the list of start size gradients
  14252. */
  14253. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14254. /**
  14255. * Adds a new life time gradient
  14256. * @param gradient defines the gradient to use (between 0 and 1)
  14257. * @param factor defines the life time factor to affect to the specified gradient
  14258. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14259. * @returns the current particle system
  14260. */
  14261. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14262. /**
  14263. * Remove a specific life time gradient
  14264. * @param gradient defines the gradient to remove
  14265. * @returns the current particle system
  14266. */
  14267. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14268. /**
  14269. * Gets the current list of life time gradients.
  14270. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14271. * @returns the list of life time gradients
  14272. */
  14273. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14274. /**
  14275. * Gets the current list of color gradients.
  14276. * You must use addColorGradient and removeColorGradient to udpate this list
  14277. * @returns the list of color gradients
  14278. */
  14279. getColorGradients(): Nullable<Array<ColorGradient>>;
  14280. /**
  14281. * Adds a new ramp gradient used to remap particle colors
  14282. * @param gradient defines the gradient to use (between 0 and 1)
  14283. * @param color defines the color to affect to the specified gradient
  14284. * @returns the current particle system
  14285. */
  14286. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14287. /**
  14288. * Gets the current list of ramp gradients.
  14289. * You must use addRampGradient and removeRampGradient to udpate this list
  14290. * @returns the list of ramp gradients
  14291. */
  14292. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14293. /** Gets or sets a boolean indicating that ramp gradients must be used
  14294. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14295. */
  14296. useRampGradients: boolean;
  14297. /**
  14298. * Adds a new color remap gradient
  14299. * @param gradient defines the gradient to use (between 0 and 1)
  14300. * @param min defines the color remap minimal range
  14301. * @param max defines the color remap maximal range
  14302. * @returns the current particle system
  14303. */
  14304. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14305. /**
  14306. * Gets the current list of color remap gradients.
  14307. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14308. * @returns the list of color remap gradients
  14309. */
  14310. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14311. /**
  14312. * Adds a new alpha remap gradient
  14313. * @param gradient defines the gradient to use (between 0 and 1)
  14314. * @param min defines the alpha remap minimal range
  14315. * @param max defines the alpha remap maximal range
  14316. * @returns the current particle system
  14317. */
  14318. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14319. /**
  14320. * Gets the current list of alpha remap gradients.
  14321. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14322. * @returns the list of alpha remap gradients
  14323. */
  14324. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14325. /**
  14326. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14327. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14328. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14329. * @returns the emitter
  14330. */
  14331. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14332. /**
  14333. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14334. * @param radius The radius of the hemisphere to emit from
  14335. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14336. * @returns the emitter
  14337. */
  14338. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14339. /**
  14340. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14341. * @param radius The radius of the sphere to emit from
  14342. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14343. * @returns the emitter
  14344. */
  14345. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14346. /**
  14347. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14348. * @param radius The radius of the sphere to emit from
  14349. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14350. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14351. * @returns the emitter
  14352. */
  14353. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14354. /**
  14355. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14356. * @param radius The radius of the emission cylinder
  14357. * @param height The height of the emission cylinder
  14358. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14359. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14360. * @returns the emitter
  14361. */
  14362. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14363. /**
  14364. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14365. * @param radius The radius of the cylinder to emit from
  14366. * @param height The height of the emission cylinder
  14367. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14368. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14369. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14370. * @returns the emitter
  14371. */
  14372. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14373. /**
  14374. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14375. * @param radius The radius of the cone to emit from
  14376. * @param angle The base angle of the cone
  14377. * @returns the emitter
  14378. */
  14379. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14380. /**
  14381. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14382. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14383. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14384. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14385. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14386. * @returns the emitter
  14387. */
  14388. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14389. /**
  14390. * Get hosting scene
  14391. * @returns the scene
  14392. */
  14393. getScene(): Scene;
  14394. }
  14395. }
  14396. declare module BABYLON {
  14397. /**
  14398. * 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.
  14399. * @see https://doc.babylonjs.com/how_to/transformnode
  14400. */
  14401. export class TransformNode extends Node {
  14402. /**
  14403. * Object will not rotate to face the camera
  14404. */
  14405. static BILLBOARDMODE_NONE: number;
  14406. /**
  14407. * Object will rotate to face the camera but only on the x axis
  14408. */
  14409. static BILLBOARDMODE_X: number;
  14410. /**
  14411. * Object will rotate to face the camera but only on the y axis
  14412. */
  14413. static BILLBOARDMODE_Y: number;
  14414. /**
  14415. * Object will rotate to face the camera but only on the z axis
  14416. */
  14417. static BILLBOARDMODE_Z: number;
  14418. /**
  14419. * Object will rotate to face the camera
  14420. */
  14421. static BILLBOARDMODE_ALL: number;
  14422. /**
  14423. * Object will rotate to face the camera's position instead of orientation
  14424. */
  14425. static BILLBOARDMODE_USE_POSITION: number;
  14426. private static _TmpRotation;
  14427. private static _TmpScaling;
  14428. private static _TmpTranslation;
  14429. private _forward;
  14430. private _forwardInverted;
  14431. private _up;
  14432. private _right;
  14433. private _rightInverted;
  14434. private _position;
  14435. private _rotation;
  14436. private _rotationQuaternion;
  14437. protected _scaling: Vector3;
  14438. protected _isDirty: boolean;
  14439. private _transformToBoneReferal;
  14440. private _isAbsoluteSynced;
  14441. private _billboardMode;
  14442. /**
  14443. * Gets or sets the billboard mode. Default is 0.
  14444. *
  14445. * | Value | Type | Description |
  14446. * | --- | --- | --- |
  14447. * | 0 | BILLBOARDMODE_NONE | |
  14448. * | 1 | BILLBOARDMODE_X | |
  14449. * | 2 | BILLBOARDMODE_Y | |
  14450. * | 4 | BILLBOARDMODE_Z | |
  14451. * | 7 | BILLBOARDMODE_ALL | |
  14452. *
  14453. */
  14454. get billboardMode(): number;
  14455. set billboardMode(value: number);
  14456. private _preserveParentRotationForBillboard;
  14457. /**
  14458. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14459. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14460. */
  14461. get preserveParentRotationForBillboard(): boolean;
  14462. set preserveParentRotationForBillboard(value: boolean);
  14463. /**
  14464. * 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
  14465. */
  14466. scalingDeterminant: number;
  14467. private _infiniteDistance;
  14468. /**
  14469. * Gets or sets the distance of the object to max, often used by skybox
  14470. */
  14471. get infiniteDistance(): boolean;
  14472. set infiniteDistance(value: boolean);
  14473. /**
  14474. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14475. * By default the system will update normals to compensate
  14476. */
  14477. ignoreNonUniformScaling: boolean;
  14478. /**
  14479. * 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
  14480. */
  14481. reIntegrateRotationIntoRotationQuaternion: boolean;
  14482. /** @hidden */
  14483. _poseMatrix: Nullable<Matrix>;
  14484. /** @hidden */
  14485. _localMatrix: Matrix;
  14486. private _usePivotMatrix;
  14487. private _absolutePosition;
  14488. private _absoluteScaling;
  14489. private _absoluteRotationQuaternion;
  14490. private _pivotMatrix;
  14491. private _pivotMatrixInverse;
  14492. protected _postMultiplyPivotMatrix: boolean;
  14493. protected _isWorldMatrixFrozen: boolean;
  14494. /** @hidden */
  14495. _indexInSceneTransformNodesArray: number;
  14496. /**
  14497. * An event triggered after the world matrix is updated
  14498. */
  14499. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14500. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14501. /**
  14502. * Gets a string identifying the name of the class
  14503. * @returns "TransformNode" string
  14504. */
  14505. getClassName(): string;
  14506. /**
  14507. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14508. */
  14509. get position(): Vector3;
  14510. set position(newPosition: Vector3);
  14511. /**
  14512. * 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)).
  14513. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14514. */
  14515. get rotation(): Vector3;
  14516. set rotation(newRotation: Vector3);
  14517. /**
  14518. * 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)).
  14519. */
  14520. get scaling(): Vector3;
  14521. set scaling(newScaling: Vector3);
  14522. /**
  14523. * 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).
  14524. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14525. */
  14526. get rotationQuaternion(): Nullable<Quaternion>;
  14527. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14528. /**
  14529. * The forward direction of that transform in world space.
  14530. */
  14531. get forward(): Vector3;
  14532. /**
  14533. * The up direction of that transform in world space.
  14534. */
  14535. get up(): Vector3;
  14536. /**
  14537. * The right direction of that transform in world space.
  14538. */
  14539. get right(): Vector3;
  14540. /**
  14541. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14542. * @param matrix the matrix to copy the pose from
  14543. * @returns this TransformNode.
  14544. */
  14545. updatePoseMatrix(matrix: Matrix): TransformNode;
  14546. /**
  14547. * Returns the mesh Pose matrix.
  14548. * @returns the pose matrix
  14549. */
  14550. getPoseMatrix(): Matrix;
  14551. /** @hidden */
  14552. _isSynchronized(): boolean;
  14553. /** @hidden */
  14554. _initCache(): void;
  14555. /**
  14556. * Flag the transform node as dirty (Forcing it to update everything)
  14557. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14558. * @returns this transform node
  14559. */
  14560. markAsDirty(property: string): TransformNode;
  14561. /**
  14562. * Returns the current mesh absolute position.
  14563. * Returns a Vector3.
  14564. */
  14565. get absolutePosition(): Vector3;
  14566. /**
  14567. * Returns the current mesh absolute scaling.
  14568. * Returns a Vector3.
  14569. */
  14570. get absoluteScaling(): Vector3;
  14571. /**
  14572. * Returns the current mesh absolute rotation.
  14573. * Returns a Quaternion.
  14574. */
  14575. get absoluteRotationQuaternion(): Quaternion;
  14576. /**
  14577. * Sets a new matrix to apply before all other transformation
  14578. * @param matrix defines the transform matrix
  14579. * @returns the current TransformNode
  14580. */
  14581. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14582. /**
  14583. * Sets a new pivot matrix to the current node
  14584. * @param matrix defines the new pivot matrix to use
  14585. * @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
  14586. * @returns the current TransformNode
  14587. */
  14588. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14589. /**
  14590. * Returns the mesh pivot matrix.
  14591. * Default : Identity.
  14592. * @returns the matrix
  14593. */
  14594. getPivotMatrix(): Matrix;
  14595. /**
  14596. * Instantiate (when possible) or clone that node with its hierarchy
  14597. * @param newParent defines the new parent to use for the instance (or clone)
  14598. * @param options defines options to configure how copy is done
  14599. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14600. * @returns an instance (or a clone) of the current node with its hiearchy
  14601. */
  14602. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14603. doNotInstantiate: boolean;
  14604. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14605. /**
  14606. * Prevents the World matrix to be computed any longer
  14607. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14608. * @returns the TransformNode.
  14609. */
  14610. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14611. /**
  14612. * Allows back the World matrix computation.
  14613. * @returns the TransformNode.
  14614. */
  14615. unfreezeWorldMatrix(): this;
  14616. /**
  14617. * True if the World matrix has been frozen.
  14618. */
  14619. get isWorldMatrixFrozen(): boolean;
  14620. /**
  14621. * Retuns the mesh absolute position in the World.
  14622. * @returns a Vector3.
  14623. */
  14624. getAbsolutePosition(): Vector3;
  14625. /**
  14626. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14627. * @param absolutePosition the absolute position to set
  14628. * @returns the TransformNode.
  14629. */
  14630. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14631. /**
  14632. * Sets the mesh position in its local space.
  14633. * @param vector3 the position to set in localspace
  14634. * @returns the TransformNode.
  14635. */
  14636. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14637. /**
  14638. * Returns the mesh position in the local space from the current World matrix values.
  14639. * @returns a new Vector3.
  14640. */
  14641. getPositionExpressedInLocalSpace(): Vector3;
  14642. /**
  14643. * Translates the mesh along the passed Vector3 in its local space.
  14644. * @param vector3 the distance to translate in localspace
  14645. * @returns the TransformNode.
  14646. */
  14647. locallyTranslate(vector3: Vector3): TransformNode;
  14648. private static _lookAtVectorCache;
  14649. /**
  14650. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14651. * @param targetPoint the position (must be in same space as current mesh) to look at
  14652. * @param yawCor optional yaw (y-axis) correction in radians
  14653. * @param pitchCor optional pitch (x-axis) correction in radians
  14654. * @param rollCor optional roll (z-axis) correction in radians
  14655. * @param space the choosen space of the target
  14656. * @returns the TransformNode.
  14657. */
  14658. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14659. /**
  14660. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14661. * This Vector3 is expressed in the World space.
  14662. * @param localAxis axis to rotate
  14663. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14664. */
  14665. getDirection(localAxis: Vector3): Vector3;
  14666. /**
  14667. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14668. * localAxis is expressed in the mesh local space.
  14669. * result is computed in the Wordl space from the mesh World matrix.
  14670. * @param localAxis axis to rotate
  14671. * @param result the resulting transformnode
  14672. * @returns this TransformNode.
  14673. */
  14674. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14675. /**
  14676. * Sets this transform node rotation to the given local axis.
  14677. * @param localAxis the axis in local space
  14678. * @param yawCor optional yaw (y-axis) correction in radians
  14679. * @param pitchCor optional pitch (x-axis) correction in radians
  14680. * @param rollCor optional roll (z-axis) correction in radians
  14681. * @returns this TransformNode
  14682. */
  14683. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14684. /**
  14685. * Sets a new pivot point to the current node
  14686. * @param point defines the new pivot point to use
  14687. * @param space defines if the point is in world or local space (local by default)
  14688. * @returns the current TransformNode
  14689. */
  14690. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14691. /**
  14692. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14693. * @returns the pivot point
  14694. */
  14695. getPivotPoint(): Vector3;
  14696. /**
  14697. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14698. * @param result the vector3 to store the result
  14699. * @returns this TransformNode.
  14700. */
  14701. getPivotPointToRef(result: Vector3): TransformNode;
  14702. /**
  14703. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14704. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14705. */
  14706. getAbsolutePivotPoint(): Vector3;
  14707. /**
  14708. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14709. * @param result vector3 to store the result
  14710. * @returns this TransformNode.
  14711. */
  14712. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14713. /**
  14714. * Defines the passed node as the parent of the current node.
  14715. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14716. * @see https://doc.babylonjs.com/how_to/parenting
  14717. * @param node the node ot set as the parent
  14718. * @returns this TransformNode.
  14719. */
  14720. setParent(node: Nullable<Node>): TransformNode;
  14721. private _nonUniformScaling;
  14722. /**
  14723. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14724. */
  14725. get nonUniformScaling(): boolean;
  14726. /** @hidden */
  14727. _updateNonUniformScalingState(value: boolean): boolean;
  14728. /**
  14729. * Attach the current TransformNode to another TransformNode associated with a bone
  14730. * @param bone Bone affecting the TransformNode
  14731. * @param affectedTransformNode TransformNode associated with the bone
  14732. * @returns this object
  14733. */
  14734. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14735. /**
  14736. * Detach the transform node if its associated with a bone
  14737. * @returns this object
  14738. */
  14739. detachFromBone(): TransformNode;
  14740. private static _rotationAxisCache;
  14741. /**
  14742. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14743. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14744. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14745. * The passed axis is also normalized.
  14746. * @param axis the axis to rotate around
  14747. * @param amount the amount to rotate in radians
  14748. * @param space Space to rotate in (Default: local)
  14749. * @returns the TransformNode.
  14750. */
  14751. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14752. /**
  14753. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14754. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14755. * The passed axis is also normalized. .
  14756. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14757. * @param point the point to rotate around
  14758. * @param axis the axis to rotate around
  14759. * @param amount the amount to rotate in radians
  14760. * @returns the TransformNode
  14761. */
  14762. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14763. /**
  14764. * Translates the mesh along the axis vector for the passed distance in the given space.
  14765. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14766. * @param axis the axis to translate in
  14767. * @param distance the distance to translate
  14768. * @param space Space to rotate in (Default: local)
  14769. * @returns the TransformNode.
  14770. */
  14771. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14772. /**
  14773. * Adds a rotation step to the mesh current rotation.
  14774. * x, y, z are Euler angles expressed in radians.
  14775. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14776. * This means this rotation is made in the mesh local space only.
  14777. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14778. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14779. * ```javascript
  14780. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14781. * ```
  14782. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14783. * 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.
  14784. * @param x Rotation to add
  14785. * @param y Rotation to add
  14786. * @param z Rotation to add
  14787. * @returns the TransformNode.
  14788. */
  14789. addRotation(x: number, y: number, z: number): TransformNode;
  14790. /**
  14791. * @hidden
  14792. */
  14793. protected _getEffectiveParent(): Nullable<Node>;
  14794. /**
  14795. * Computes the world matrix of the node
  14796. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14797. * @returns the world matrix
  14798. */
  14799. computeWorldMatrix(force?: boolean): Matrix;
  14800. /**
  14801. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14802. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14803. */
  14804. resetLocalMatrix(independentOfChildren?: boolean): void;
  14805. protected _afterComputeWorldMatrix(): void;
  14806. /**
  14807. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14808. * @param func callback function to add
  14809. *
  14810. * @returns the TransformNode.
  14811. */
  14812. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14813. /**
  14814. * Removes a registered callback function.
  14815. * @param func callback function to remove
  14816. * @returns the TransformNode.
  14817. */
  14818. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14819. /**
  14820. * Gets the position of the current mesh in camera space
  14821. * @param camera defines the camera to use
  14822. * @returns a position
  14823. */
  14824. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14825. /**
  14826. * Returns the distance from the mesh to the active camera
  14827. * @param camera defines the camera to use
  14828. * @returns the distance
  14829. */
  14830. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14831. /**
  14832. * Clone the current transform node
  14833. * @param name Name of the new clone
  14834. * @param newParent New parent for the clone
  14835. * @param doNotCloneChildren Do not clone children hierarchy
  14836. * @returns the new transform node
  14837. */
  14838. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14839. /**
  14840. * Serializes the objects information.
  14841. * @param currentSerializationObject defines the object to serialize in
  14842. * @returns the serialized object
  14843. */
  14844. serialize(currentSerializationObject?: any): any;
  14845. /**
  14846. * Returns a new TransformNode object parsed from the source provided.
  14847. * @param parsedTransformNode is the source.
  14848. * @param scene the scne the object belongs to
  14849. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14850. * @returns a new TransformNode object parsed from the source provided.
  14851. */
  14852. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14853. /**
  14854. * Get all child-transformNodes of this node
  14855. * @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
  14856. * @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
  14857. * @returns an array of TransformNode
  14858. */
  14859. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14860. /**
  14861. * Releases resources associated with this transform node.
  14862. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14863. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14864. */
  14865. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14866. /**
  14867. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14868. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14869. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14870. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14871. * @returns the current mesh
  14872. */
  14873. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14874. private _syncAbsoluteScalingAndRotation;
  14875. }
  14876. }
  14877. declare module BABYLON {
  14878. /**
  14879. * Class used to override all child animations of a given target
  14880. */
  14881. export class AnimationPropertiesOverride {
  14882. /**
  14883. * Gets or sets a value indicating if animation blending must be used
  14884. */
  14885. enableBlending: boolean;
  14886. /**
  14887. * Gets or sets the blending speed to use when enableBlending is true
  14888. */
  14889. blendingSpeed: number;
  14890. /**
  14891. * Gets or sets the default loop mode to use
  14892. */
  14893. loopMode: number;
  14894. }
  14895. }
  14896. declare module BABYLON {
  14897. /**
  14898. * Class used to store bone information
  14899. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14900. */
  14901. export class Bone extends Node {
  14902. /**
  14903. * defines the bone name
  14904. */
  14905. name: string;
  14906. private static _tmpVecs;
  14907. private static _tmpQuat;
  14908. private static _tmpMats;
  14909. /**
  14910. * Gets the list of child bones
  14911. */
  14912. children: Bone[];
  14913. /** Gets the animations associated with this bone */
  14914. animations: Animation[];
  14915. /**
  14916. * Gets or sets bone length
  14917. */
  14918. length: number;
  14919. /**
  14920. * @hidden Internal only
  14921. * Set this value to map this bone to a different index in the transform matrices
  14922. * Set this value to -1 to exclude the bone from the transform matrices
  14923. */
  14924. _index: Nullable<number>;
  14925. private _skeleton;
  14926. private _localMatrix;
  14927. private _restPose;
  14928. private _baseMatrix;
  14929. private _absoluteTransform;
  14930. private _invertedAbsoluteTransform;
  14931. private _parent;
  14932. private _scalingDeterminant;
  14933. private _worldTransform;
  14934. private _localScaling;
  14935. private _localRotation;
  14936. private _localPosition;
  14937. private _needToDecompose;
  14938. private _needToCompose;
  14939. /** @hidden */
  14940. _linkedTransformNode: Nullable<TransformNode>;
  14941. /** @hidden */
  14942. _waitingTransformNodeId: Nullable<string>;
  14943. /** @hidden */
  14944. get _matrix(): Matrix;
  14945. /** @hidden */
  14946. set _matrix(value: Matrix);
  14947. /**
  14948. * Create a new bone
  14949. * @param name defines the bone name
  14950. * @param skeleton defines the parent skeleton
  14951. * @param parentBone defines the parent (can be null if the bone is the root)
  14952. * @param localMatrix defines the local matrix
  14953. * @param restPose defines the rest pose matrix
  14954. * @param baseMatrix defines the base matrix
  14955. * @param index defines index of the bone in the hiearchy
  14956. */
  14957. constructor(
  14958. /**
  14959. * defines the bone name
  14960. */
  14961. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14962. /**
  14963. * Gets the current object class name.
  14964. * @return the class name
  14965. */
  14966. getClassName(): string;
  14967. /**
  14968. * Gets the parent skeleton
  14969. * @returns a skeleton
  14970. */
  14971. getSkeleton(): Skeleton;
  14972. /**
  14973. * Gets parent bone
  14974. * @returns a bone or null if the bone is the root of the bone hierarchy
  14975. */
  14976. getParent(): Nullable<Bone>;
  14977. /**
  14978. * Returns an array containing the root bones
  14979. * @returns an array containing the root bones
  14980. */
  14981. getChildren(): Array<Bone>;
  14982. /**
  14983. * Gets the node index in matrix array generated for rendering
  14984. * @returns the node index
  14985. */
  14986. getIndex(): number;
  14987. /**
  14988. * Sets the parent bone
  14989. * @param parent defines the parent (can be null if the bone is the root)
  14990. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14991. */
  14992. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14993. /**
  14994. * Gets the local matrix
  14995. * @returns a matrix
  14996. */
  14997. getLocalMatrix(): Matrix;
  14998. /**
  14999. * Gets the base matrix (initial matrix which remains unchanged)
  15000. * @returns a matrix
  15001. */
  15002. getBaseMatrix(): Matrix;
  15003. /**
  15004. * Gets the rest pose matrix
  15005. * @returns a matrix
  15006. */
  15007. getRestPose(): Matrix;
  15008. /**
  15009. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15010. */
  15011. getWorldMatrix(): Matrix;
  15012. /**
  15013. * Sets the local matrix to rest pose matrix
  15014. */
  15015. returnToRest(): void;
  15016. /**
  15017. * Gets the inverse of the absolute transform matrix.
  15018. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15019. * @returns a matrix
  15020. */
  15021. getInvertedAbsoluteTransform(): Matrix;
  15022. /**
  15023. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15024. * @returns a matrix
  15025. */
  15026. getAbsoluteTransform(): Matrix;
  15027. /**
  15028. * Links with the given transform node.
  15029. * The local matrix of this bone is copied from the transform node every frame.
  15030. * @param transformNode defines the transform node to link to
  15031. */
  15032. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15033. /**
  15034. * Gets the node used to drive the bone's transformation
  15035. * @returns a transform node or null
  15036. */
  15037. getTransformNode(): Nullable<TransformNode>;
  15038. /** Gets or sets current position (in local space) */
  15039. get position(): Vector3;
  15040. set position(newPosition: Vector3);
  15041. /** Gets or sets current rotation (in local space) */
  15042. get rotation(): Vector3;
  15043. set rotation(newRotation: Vector3);
  15044. /** Gets or sets current rotation quaternion (in local space) */
  15045. get rotationQuaternion(): Quaternion;
  15046. set rotationQuaternion(newRotation: Quaternion);
  15047. /** Gets or sets current scaling (in local space) */
  15048. get scaling(): Vector3;
  15049. set scaling(newScaling: Vector3);
  15050. /**
  15051. * Gets the animation properties override
  15052. */
  15053. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15054. private _decompose;
  15055. private _compose;
  15056. /**
  15057. * Update the base and local matrices
  15058. * @param matrix defines the new base or local matrix
  15059. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15060. * @param updateLocalMatrix defines if the local matrix should be updated
  15061. */
  15062. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15063. /** @hidden */
  15064. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15065. /**
  15066. * Flag the bone as dirty (Forcing it to update everything)
  15067. */
  15068. markAsDirty(): void;
  15069. /** @hidden */
  15070. _markAsDirtyAndCompose(): void;
  15071. private _markAsDirtyAndDecompose;
  15072. /**
  15073. * Translate the bone in local or world space
  15074. * @param vec The amount to translate the bone
  15075. * @param space The space that the translation is in
  15076. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15077. */
  15078. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15079. /**
  15080. * Set the postion of the bone in local or world space
  15081. * @param position The position to set the bone
  15082. * @param space The space that the position is in
  15083. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15084. */
  15085. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15086. /**
  15087. * Set the absolute position of the bone (world space)
  15088. * @param position The position to set the bone
  15089. * @param mesh The mesh that this bone is attached to
  15090. */
  15091. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15092. /**
  15093. * Scale the bone on the x, y and z axes (in local space)
  15094. * @param x The amount to scale the bone on the x axis
  15095. * @param y The amount to scale the bone on the y axis
  15096. * @param z The amount to scale the bone on the z axis
  15097. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15098. */
  15099. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15100. /**
  15101. * Set the bone scaling in local space
  15102. * @param scale defines the scaling vector
  15103. */
  15104. setScale(scale: Vector3): void;
  15105. /**
  15106. * Gets the current scaling in local space
  15107. * @returns the current scaling vector
  15108. */
  15109. getScale(): Vector3;
  15110. /**
  15111. * Gets the current scaling in local space and stores it in a target vector
  15112. * @param result defines the target vector
  15113. */
  15114. getScaleToRef(result: Vector3): void;
  15115. /**
  15116. * Set the yaw, pitch, and roll of the bone in local or world space
  15117. * @param yaw The rotation of the bone on the y axis
  15118. * @param pitch The rotation of the bone on the x axis
  15119. * @param roll The rotation of the bone on the z axis
  15120. * @param space The space that the axes of rotation are in
  15121. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15122. */
  15123. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15124. /**
  15125. * Add a rotation to the bone on an axis in local or world space
  15126. * @param axis The axis to rotate the bone on
  15127. * @param amount The amount to rotate the bone
  15128. * @param space The space that the axis is in
  15129. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15130. */
  15131. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15132. /**
  15133. * Set the rotation of the bone to a particular axis angle in local or world space
  15134. * @param axis The axis to rotate the bone on
  15135. * @param angle The angle that the bone should be rotated to
  15136. * @param space The space that the axis is in
  15137. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15138. */
  15139. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15140. /**
  15141. * Set the euler rotation of the bone in local of world space
  15142. * @param rotation The euler rotation that the bone should be set to
  15143. * @param space The space that the rotation is in
  15144. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15145. */
  15146. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15147. /**
  15148. * Set the quaternion rotation of the bone in local of world space
  15149. * @param quat The quaternion rotation that the bone should be set to
  15150. * @param space The space that the rotation is in
  15151. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15152. */
  15153. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15154. /**
  15155. * Set the rotation matrix of the bone in local of world space
  15156. * @param rotMat The rotation matrix that the bone should be set to
  15157. * @param space The space that the rotation is in
  15158. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15159. */
  15160. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15161. private _rotateWithMatrix;
  15162. private _getNegativeRotationToRef;
  15163. /**
  15164. * Get the position of the bone in local or world space
  15165. * @param space The space that the returned position is in
  15166. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15167. * @returns The position of the bone
  15168. */
  15169. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15170. /**
  15171. * Copy the position of the bone to a vector3 in local or world space
  15172. * @param space The space that the returned position is in
  15173. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15174. * @param result The vector3 to copy the position to
  15175. */
  15176. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15177. /**
  15178. * Get the absolute position of the bone (world space)
  15179. * @param mesh The mesh that this bone is attached to
  15180. * @returns The absolute position of the bone
  15181. */
  15182. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15183. /**
  15184. * Copy the absolute position of the bone (world space) to the result param
  15185. * @param mesh The mesh that this bone is attached to
  15186. * @param result The vector3 to copy the absolute position to
  15187. */
  15188. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15189. /**
  15190. * Compute the absolute transforms of this bone and its children
  15191. */
  15192. computeAbsoluteTransforms(): void;
  15193. /**
  15194. * Get the world direction from an axis that is in the local space of the bone
  15195. * @param localAxis The local direction that is used to compute the world direction
  15196. * @param mesh The mesh that this bone is attached to
  15197. * @returns The world direction
  15198. */
  15199. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15200. /**
  15201. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15202. * @param localAxis The local direction that is used to compute the world direction
  15203. * @param mesh The mesh that this bone is attached to
  15204. * @param result The vector3 that the world direction will be copied to
  15205. */
  15206. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15207. /**
  15208. * Get the euler rotation of the bone in local or world space
  15209. * @param space The space that the rotation should be in
  15210. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15211. * @returns The euler rotation
  15212. */
  15213. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15214. /**
  15215. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15216. * @param space The space that the rotation should be in
  15217. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15218. * @param result The vector3 that the rotation should be copied to
  15219. */
  15220. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15221. /**
  15222. * Get the quaternion rotation of the bone in either local or world space
  15223. * @param space The space that the rotation should be in
  15224. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15225. * @returns The quaternion rotation
  15226. */
  15227. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15228. /**
  15229. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15230. * @param space The space that the rotation should be in
  15231. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15232. * @param result The quaternion that the rotation should be copied to
  15233. */
  15234. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15235. /**
  15236. * Get the rotation matrix of the bone in local or world space
  15237. * @param space The space that the rotation should be in
  15238. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15239. * @returns The rotation matrix
  15240. */
  15241. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15242. /**
  15243. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15244. * @param space The space that the rotation should be in
  15245. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15246. * @param result The quaternion that the rotation should be copied to
  15247. */
  15248. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15249. /**
  15250. * Get the world position of a point that is in the local space of the bone
  15251. * @param position The local position
  15252. * @param mesh The mesh that this bone is attached to
  15253. * @returns The world position
  15254. */
  15255. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15256. /**
  15257. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15258. * @param position The local position
  15259. * @param mesh The mesh that this bone is attached to
  15260. * @param result The vector3 that the world position should be copied to
  15261. */
  15262. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15263. /**
  15264. * Get the local position of a point that is in world space
  15265. * @param position The world position
  15266. * @param mesh The mesh that this bone is attached to
  15267. * @returns The local position
  15268. */
  15269. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15270. /**
  15271. * Get the local position of a point that is in world space and copy it to the result param
  15272. * @param position The world position
  15273. * @param mesh The mesh that this bone is attached to
  15274. * @param result The vector3 that the local position should be copied to
  15275. */
  15276. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15277. }
  15278. }
  15279. declare module BABYLON {
  15280. /**
  15281. * Defines a runtime animation
  15282. */
  15283. export class RuntimeAnimation {
  15284. private _events;
  15285. /**
  15286. * The current frame of the runtime animation
  15287. */
  15288. private _currentFrame;
  15289. /**
  15290. * The animation used by the runtime animation
  15291. */
  15292. private _animation;
  15293. /**
  15294. * The target of the runtime animation
  15295. */
  15296. private _target;
  15297. /**
  15298. * The initiating animatable
  15299. */
  15300. private _host;
  15301. /**
  15302. * The original value of the runtime animation
  15303. */
  15304. private _originalValue;
  15305. /**
  15306. * The original blend value of the runtime animation
  15307. */
  15308. private _originalBlendValue;
  15309. /**
  15310. * The offsets cache of the runtime animation
  15311. */
  15312. private _offsetsCache;
  15313. /**
  15314. * The high limits cache of the runtime animation
  15315. */
  15316. private _highLimitsCache;
  15317. /**
  15318. * Specifies if the runtime animation has been stopped
  15319. */
  15320. private _stopped;
  15321. /**
  15322. * The blending factor of the runtime animation
  15323. */
  15324. private _blendingFactor;
  15325. /**
  15326. * The BabylonJS scene
  15327. */
  15328. private _scene;
  15329. /**
  15330. * The current value of the runtime animation
  15331. */
  15332. private _currentValue;
  15333. /** @hidden */
  15334. _animationState: _IAnimationState;
  15335. /**
  15336. * The active target of the runtime animation
  15337. */
  15338. private _activeTargets;
  15339. private _currentActiveTarget;
  15340. private _directTarget;
  15341. /**
  15342. * The target path of the runtime animation
  15343. */
  15344. private _targetPath;
  15345. /**
  15346. * The weight of the runtime animation
  15347. */
  15348. private _weight;
  15349. /**
  15350. * The ratio offset of the runtime animation
  15351. */
  15352. private _ratioOffset;
  15353. /**
  15354. * The previous delay of the runtime animation
  15355. */
  15356. private _previousDelay;
  15357. /**
  15358. * The previous ratio of the runtime animation
  15359. */
  15360. private _previousRatio;
  15361. private _enableBlending;
  15362. private _keys;
  15363. private _minFrame;
  15364. private _maxFrame;
  15365. private _minValue;
  15366. private _maxValue;
  15367. private _targetIsArray;
  15368. /**
  15369. * Gets the current frame of the runtime animation
  15370. */
  15371. get currentFrame(): number;
  15372. /**
  15373. * Gets the weight of the runtime animation
  15374. */
  15375. get weight(): number;
  15376. /**
  15377. * Gets the current value of the runtime animation
  15378. */
  15379. get currentValue(): any;
  15380. /**
  15381. * Gets the target path of the runtime animation
  15382. */
  15383. get targetPath(): string;
  15384. /**
  15385. * Gets the actual target of the runtime animation
  15386. */
  15387. get target(): any;
  15388. /**
  15389. * Gets the additive state of the runtime animation
  15390. */
  15391. get isAdditive(): boolean;
  15392. /** @hidden */
  15393. _onLoop: () => void;
  15394. /**
  15395. * Create a new RuntimeAnimation object
  15396. * @param target defines the target of the animation
  15397. * @param animation defines the source animation object
  15398. * @param scene defines the hosting scene
  15399. * @param host defines the initiating Animatable
  15400. */
  15401. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15402. private _preparePath;
  15403. /**
  15404. * Gets the animation from the runtime animation
  15405. */
  15406. get animation(): Animation;
  15407. /**
  15408. * Resets the runtime animation to the beginning
  15409. * @param restoreOriginal defines whether to restore the target property to the original value
  15410. */
  15411. reset(restoreOriginal?: boolean): void;
  15412. /**
  15413. * Specifies if the runtime animation is stopped
  15414. * @returns Boolean specifying if the runtime animation is stopped
  15415. */
  15416. isStopped(): boolean;
  15417. /**
  15418. * Disposes of the runtime animation
  15419. */
  15420. dispose(): void;
  15421. /**
  15422. * Apply the interpolated value to the target
  15423. * @param currentValue defines the value computed by the animation
  15424. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15425. */
  15426. setValue(currentValue: any, weight: number): void;
  15427. private _getOriginalValues;
  15428. private _setValue;
  15429. /**
  15430. * Gets the loop pmode of the runtime animation
  15431. * @returns Loop Mode
  15432. */
  15433. private _getCorrectLoopMode;
  15434. /**
  15435. * Move the current animation to a given frame
  15436. * @param frame defines the frame to move to
  15437. */
  15438. goToFrame(frame: number): void;
  15439. /**
  15440. * @hidden Internal use only
  15441. */
  15442. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15443. /**
  15444. * Execute the current animation
  15445. * @param delay defines the delay to add to the current frame
  15446. * @param from defines the lower bound of the animation range
  15447. * @param to defines the upper bound of the animation range
  15448. * @param loop defines if the current animation must loop
  15449. * @param speedRatio defines the current speed ratio
  15450. * @param weight defines the weight of the animation (default is -1 so no weight)
  15451. * @param onLoop optional callback called when animation loops
  15452. * @returns a boolean indicating if the animation is running
  15453. */
  15454. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15455. }
  15456. }
  15457. declare module BABYLON {
  15458. /**
  15459. * Class used to store an actual running animation
  15460. */
  15461. export class Animatable {
  15462. /** defines the target object */
  15463. target: any;
  15464. /** defines the starting frame number (default is 0) */
  15465. fromFrame: number;
  15466. /** defines the ending frame number (default is 100) */
  15467. toFrame: number;
  15468. /** defines if the animation must loop (default is false) */
  15469. loopAnimation: boolean;
  15470. /** defines a callback to call when animation ends if it is not looping */
  15471. onAnimationEnd?: (() => void) | null | undefined;
  15472. /** defines a callback to call when animation loops */
  15473. onAnimationLoop?: (() => void) | null | undefined;
  15474. /** defines whether the animation should be evaluated additively */
  15475. isAdditive: boolean;
  15476. private _localDelayOffset;
  15477. private _pausedDelay;
  15478. private _runtimeAnimations;
  15479. private _paused;
  15480. private _scene;
  15481. private _speedRatio;
  15482. private _weight;
  15483. private _syncRoot;
  15484. /**
  15485. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15486. * This will only apply for non looping animation (default is true)
  15487. */
  15488. disposeOnEnd: boolean;
  15489. /**
  15490. * Gets a boolean indicating if the animation has started
  15491. */
  15492. animationStarted: boolean;
  15493. /**
  15494. * Observer raised when the animation ends
  15495. */
  15496. onAnimationEndObservable: Observable<Animatable>;
  15497. /**
  15498. * Observer raised when the animation loops
  15499. */
  15500. onAnimationLoopObservable: Observable<Animatable>;
  15501. /**
  15502. * Gets the root Animatable used to synchronize and normalize animations
  15503. */
  15504. get syncRoot(): Nullable<Animatable>;
  15505. /**
  15506. * Gets the current frame of the first RuntimeAnimation
  15507. * Used to synchronize Animatables
  15508. */
  15509. get masterFrame(): number;
  15510. /**
  15511. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15512. */
  15513. get weight(): number;
  15514. set weight(value: number);
  15515. /**
  15516. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15517. */
  15518. get speedRatio(): number;
  15519. set speedRatio(value: number);
  15520. /**
  15521. * Creates a new Animatable
  15522. * @param scene defines the hosting scene
  15523. * @param target defines the target object
  15524. * @param fromFrame defines the starting frame number (default is 0)
  15525. * @param toFrame defines the ending frame number (default is 100)
  15526. * @param loopAnimation defines if the animation must loop (default is false)
  15527. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15528. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15529. * @param animations defines a group of animation to add to the new Animatable
  15530. * @param onAnimationLoop defines a callback to call when animation loops
  15531. * @param isAdditive defines whether the animation should be evaluated additively
  15532. */
  15533. constructor(scene: Scene,
  15534. /** defines the target object */
  15535. target: any,
  15536. /** defines the starting frame number (default is 0) */
  15537. fromFrame?: number,
  15538. /** defines the ending frame number (default is 100) */
  15539. toFrame?: number,
  15540. /** defines if the animation must loop (default is false) */
  15541. loopAnimation?: boolean, speedRatio?: number,
  15542. /** defines a callback to call when animation ends if it is not looping */
  15543. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15544. /** defines a callback to call when animation loops */
  15545. onAnimationLoop?: (() => void) | null | undefined,
  15546. /** defines whether the animation should be evaluated additively */
  15547. isAdditive?: boolean);
  15548. /**
  15549. * Synchronize and normalize current Animatable with a source Animatable
  15550. * This is useful when using animation weights and when animations are not of the same length
  15551. * @param root defines the root Animatable to synchronize with
  15552. * @returns the current Animatable
  15553. */
  15554. syncWith(root: Animatable): Animatable;
  15555. /**
  15556. * Gets the list of runtime animations
  15557. * @returns an array of RuntimeAnimation
  15558. */
  15559. getAnimations(): RuntimeAnimation[];
  15560. /**
  15561. * Adds more animations to the current animatable
  15562. * @param target defines the target of the animations
  15563. * @param animations defines the new animations to add
  15564. */
  15565. appendAnimations(target: any, animations: Animation[]): void;
  15566. /**
  15567. * Gets the source animation for a specific property
  15568. * @param property defines the propertyu to look for
  15569. * @returns null or the source animation for the given property
  15570. */
  15571. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15572. /**
  15573. * Gets the runtime animation for a specific property
  15574. * @param property defines the propertyu to look for
  15575. * @returns null or the runtime animation for the given property
  15576. */
  15577. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15578. /**
  15579. * Resets the animatable to its original state
  15580. */
  15581. reset(): void;
  15582. /**
  15583. * Allows the animatable to blend with current running animations
  15584. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15585. * @param blendingSpeed defines the blending speed to use
  15586. */
  15587. enableBlending(blendingSpeed: number): void;
  15588. /**
  15589. * Disable animation blending
  15590. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15591. */
  15592. disableBlending(): void;
  15593. /**
  15594. * Jump directly to a given frame
  15595. * @param frame defines the frame to jump to
  15596. */
  15597. goToFrame(frame: number): void;
  15598. /**
  15599. * Pause the animation
  15600. */
  15601. pause(): void;
  15602. /**
  15603. * Restart the animation
  15604. */
  15605. restart(): void;
  15606. private _raiseOnAnimationEnd;
  15607. /**
  15608. * Stop and delete the current animation
  15609. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15610. * @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)
  15611. */
  15612. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15613. /**
  15614. * Wait asynchronously for the animation to end
  15615. * @returns a promise which will be fullfilled when the animation ends
  15616. */
  15617. waitAsync(): Promise<Animatable>;
  15618. /** @hidden */
  15619. _animate(delay: number): boolean;
  15620. }
  15621. interface Scene {
  15622. /** @hidden */
  15623. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15624. /** @hidden */
  15625. _processLateAnimationBindingsForMatrices(holder: {
  15626. totalWeight: number;
  15627. totalAdditiveWeight: number;
  15628. animations: RuntimeAnimation[];
  15629. additiveAnimations: RuntimeAnimation[];
  15630. originalValue: Matrix;
  15631. }): any;
  15632. /** @hidden */
  15633. _processLateAnimationBindingsForQuaternions(holder: {
  15634. totalWeight: number;
  15635. totalAdditiveWeight: number;
  15636. animations: RuntimeAnimation[];
  15637. additiveAnimations: RuntimeAnimation[];
  15638. originalValue: Quaternion;
  15639. }, refQuaternion: Quaternion): Quaternion;
  15640. /** @hidden */
  15641. _processLateAnimationBindings(): void;
  15642. /**
  15643. * Will start the animation sequence of a given target
  15644. * @param target defines the target
  15645. * @param from defines from which frame should animation start
  15646. * @param to defines until which frame should animation run.
  15647. * @param weight defines the weight to apply to the animation (1.0 by default)
  15648. * @param loop defines if the animation loops
  15649. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15650. * @param onAnimationEnd defines the function to be executed when the animation ends
  15651. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15652. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15653. * @param onAnimationLoop defines the callback to call when an animation loops
  15654. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15655. * @returns the animatable object created for this animation
  15656. */
  15657. 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;
  15658. /**
  15659. * Will start the animation sequence of a given target
  15660. * @param target defines the target
  15661. * @param from defines from which frame should animation start
  15662. * @param to defines until which frame should animation run.
  15663. * @param loop defines if the animation loops
  15664. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15665. * @param onAnimationEnd defines the function to be executed when the animation ends
  15666. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15667. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15668. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15669. * @param onAnimationLoop defines the callback to call when an animation loops
  15670. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15671. * @returns the animatable object created for this animation
  15672. */
  15673. 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;
  15674. /**
  15675. * Will start the animation sequence of a given target and its hierarchy
  15676. * @param target defines the target
  15677. * @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.
  15678. * @param from defines from which frame should animation start
  15679. * @param to defines until which frame should animation run.
  15680. * @param loop defines if the animation loops
  15681. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15682. * @param onAnimationEnd defines the function to be executed when the animation ends
  15683. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15684. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15685. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15686. * @param onAnimationLoop defines the callback to call when an animation loops
  15687. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15688. * @returns the list of created animatables
  15689. */
  15690. 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[];
  15691. /**
  15692. * Begin a new animation on a given node
  15693. * @param target defines the target where the animation will take place
  15694. * @param animations defines the list of animations to start
  15695. * @param from defines the initial value
  15696. * @param to defines the final value
  15697. * @param loop defines if you want animation to loop (off by default)
  15698. * @param speedRatio defines the speed ratio to apply to all animations
  15699. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15700. * @param onAnimationLoop defines the callback to call when an animation loops
  15701. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15702. * @returns the list of created animatables
  15703. */
  15704. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15705. /**
  15706. * Begin a new animation on a given node and its hierarchy
  15707. * @param target defines the root node where the animation will take place
  15708. * @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.
  15709. * @param animations defines the list of animations to start
  15710. * @param from defines the initial value
  15711. * @param to defines the final value
  15712. * @param loop defines if you want animation to loop (off by default)
  15713. * @param speedRatio defines the speed ratio to apply to all animations
  15714. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15715. * @param onAnimationLoop defines the callback to call when an animation loops
  15716. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15717. * @returns the list of animatables created for all nodes
  15718. */
  15719. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15720. /**
  15721. * Gets the animatable associated with a specific target
  15722. * @param target defines the target of the animatable
  15723. * @returns the required animatable if found
  15724. */
  15725. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15726. /**
  15727. * Gets all animatables associated with a given target
  15728. * @param target defines the target to look animatables for
  15729. * @returns an array of Animatables
  15730. */
  15731. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15732. /**
  15733. * Stops and removes all animations that have been applied to the scene
  15734. */
  15735. stopAllAnimations(): void;
  15736. /**
  15737. * Gets the current delta time used by animation engine
  15738. */
  15739. deltaTime: number;
  15740. }
  15741. interface Bone {
  15742. /**
  15743. * Copy an animation range from another bone
  15744. * @param source defines the source bone
  15745. * @param rangeName defines the range name to copy
  15746. * @param frameOffset defines the frame offset
  15747. * @param rescaleAsRequired defines if rescaling must be applied if required
  15748. * @param skelDimensionsRatio defines the scaling ratio
  15749. * @returns true if operation was successful
  15750. */
  15751. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15752. }
  15753. }
  15754. declare module BABYLON {
  15755. /**
  15756. * Class used to handle skinning animations
  15757. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15758. */
  15759. export class Skeleton implements IAnimatable {
  15760. /** defines the skeleton name */
  15761. name: string;
  15762. /** defines the skeleton Id */
  15763. id: string;
  15764. /**
  15765. * Defines the list of child bones
  15766. */
  15767. bones: Bone[];
  15768. /**
  15769. * Defines an estimate of the dimension of the skeleton at rest
  15770. */
  15771. dimensionsAtRest: Vector3;
  15772. /**
  15773. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15774. */
  15775. needInitialSkinMatrix: boolean;
  15776. /**
  15777. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15778. */
  15779. overrideMesh: Nullable<AbstractMesh>;
  15780. /**
  15781. * Gets the list of animations attached to this skeleton
  15782. */
  15783. animations: Array<Animation>;
  15784. private _scene;
  15785. private _isDirty;
  15786. private _transformMatrices;
  15787. private _transformMatrixTexture;
  15788. private _meshesWithPoseMatrix;
  15789. private _animatables;
  15790. private _identity;
  15791. private _synchronizedWithMesh;
  15792. private _ranges;
  15793. private _lastAbsoluteTransformsUpdateId;
  15794. private _canUseTextureForBones;
  15795. private _uniqueId;
  15796. /** @hidden */
  15797. _numBonesWithLinkedTransformNode: number;
  15798. /** @hidden */
  15799. _hasWaitingData: Nullable<boolean>;
  15800. /**
  15801. * Specifies if the skeleton should be serialized
  15802. */
  15803. doNotSerialize: boolean;
  15804. private _useTextureToStoreBoneMatrices;
  15805. /**
  15806. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15807. * Please note that this option is not available if the hardware does not support it
  15808. */
  15809. get useTextureToStoreBoneMatrices(): boolean;
  15810. set useTextureToStoreBoneMatrices(value: boolean);
  15811. private _animationPropertiesOverride;
  15812. /**
  15813. * Gets or sets the animation properties override
  15814. */
  15815. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15816. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15817. /**
  15818. * List of inspectable custom properties (used by the Inspector)
  15819. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15820. */
  15821. inspectableCustomProperties: IInspectable[];
  15822. /**
  15823. * An observable triggered before computing the skeleton's matrices
  15824. */
  15825. onBeforeComputeObservable: Observable<Skeleton>;
  15826. /**
  15827. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15828. */
  15829. get isUsingTextureForMatrices(): boolean;
  15830. /**
  15831. * Gets the unique ID of this skeleton
  15832. */
  15833. get uniqueId(): number;
  15834. /**
  15835. * Creates a new skeleton
  15836. * @param name defines the skeleton name
  15837. * @param id defines the skeleton Id
  15838. * @param scene defines the hosting scene
  15839. */
  15840. constructor(
  15841. /** defines the skeleton name */
  15842. name: string,
  15843. /** defines the skeleton Id */
  15844. id: string, scene: Scene);
  15845. /**
  15846. * Gets the current object class name.
  15847. * @return the class name
  15848. */
  15849. getClassName(): string;
  15850. /**
  15851. * Returns an array containing the root bones
  15852. * @returns an array containing the root bones
  15853. */
  15854. getChildren(): Array<Bone>;
  15855. /**
  15856. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15857. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15858. * @returns a Float32Array containing matrices data
  15859. */
  15860. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15861. /**
  15862. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15863. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15864. * @returns a raw texture containing the data
  15865. */
  15866. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15867. /**
  15868. * Gets the current hosting scene
  15869. * @returns a scene object
  15870. */
  15871. getScene(): Scene;
  15872. /**
  15873. * Gets a string representing the current skeleton data
  15874. * @param fullDetails defines a boolean indicating if we want a verbose version
  15875. * @returns a string representing the current skeleton data
  15876. */
  15877. toString(fullDetails?: boolean): string;
  15878. /**
  15879. * Get bone's index searching by name
  15880. * @param name defines bone's name to search for
  15881. * @return the indice of the bone. Returns -1 if not found
  15882. */
  15883. getBoneIndexByName(name: string): number;
  15884. /**
  15885. * Creater a new animation range
  15886. * @param name defines the name of the range
  15887. * @param from defines the start key
  15888. * @param to defines the end key
  15889. */
  15890. createAnimationRange(name: string, from: number, to: number): void;
  15891. /**
  15892. * Delete a specific animation range
  15893. * @param name defines the name of the range
  15894. * @param deleteFrames defines if frames must be removed as well
  15895. */
  15896. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15897. /**
  15898. * Gets a specific animation range
  15899. * @param name defines the name of the range to look for
  15900. * @returns the requested animation range or null if not found
  15901. */
  15902. getAnimationRange(name: string): Nullable<AnimationRange>;
  15903. /**
  15904. * Gets the list of all animation ranges defined on this skeleton
  15905. * @returns an array
  15906. */
  15907. getAnimationRanges(): Nullable<AnimationRange>[];
  15908. /**
  15909. * Copy animation range from a source skeleton.
  15910. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15911. * @param source defines the source skeleton
  15912. * @param name defines the name of the range to copy
  15913. * @param rescaleAsRequired defines if rescaling must be applied if required
  15914. * @returns true if operation was successful
  15915. */
  15916. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15917. /**
  15918. * Forces the skeleton to go to rest pose
  15919. */
  15920. returnToRest(): void;
  15921. private _getHighestAnimationFrame;
  15922. /**
  15923. * Begin a specific animation range
  15924. * @param name defines the name of the range to start
  15925. * @param loop defines if looping must be turned on (false by default)
  15926. * @param speedRatio defines the speed ratio to apply (1 by default)
  15927. * @param onAnimationEnd defines a callback which will be called when animation will end
  15928. * @returns a new animatable
  15929. */
  15930. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15931. /**
  15932. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  15933. * @param skeleton defines the Skeleton containing the animation range to convert
  15934. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  15935. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  15936. * @returns the original skeleton
  15937. */
  15938. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  15939. /** @hidden */
  15940. _markAsDirty(): void;
  15941. /** @hidden */
  15942. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15943. /** @hidden */
  15944. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15945. private _computeTransformMatrices;
  15946. /**
  15947. * Build all resources required to render a skeleton
  15948. */
  15949. prepare(): void;
  15950. /**
  15951. * Gets the list of animatables currently running for this skeleton
  15952. * @returns an array of animatables
  15953. */
  15954. getAnimatables(): IAnimatable[];
  15955. /**
  15956. * Clone the current skeleton
  15957. * @param name defines the name of the new skeleton
  15958. * @param id defines the id of the new skeleton
  15959. * @returns the new skeleton
  15960. */
  15961. clone(name: string, id?: string): Skeleton;
  15962. /**
  15963. * Enable animation blending for this skeleton
  15964. * @param blendingSpeed defines the blending speed to apply
  15965. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15966. */
  15967. enableBlending(blendingSpeed?: number): void;
  15968. /**
  15969. * Releases all resources associated with the current skeleton
  15970. */
  15971. dispose(): void;
  15972. /**
  15973. * Serialize the skeleton in a JSON object
  15974. * @returns a JSON object
  15975. */
  15976. serialize(): any;
  15977. /**
  15978. * Creates a new skeleton from serialized data
  15979. * @param parsedSkeleton defines the serialized data
  15980. * @param scene defines the hosting scene
  15981. * @returns a new skeleton
  15982. */
  15983. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15984. /**
  15985. * Compute all node absolute transforms
  15986. * @param forceUpdate defines if computation must be done even if cache is up to date
  15987. */
  15988. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15989. /**
  15990. * Gets the root pose matrix
  15991. * @returns a matrix
  15992. */
  15993. getPoseMatrix(): Nullable<Matrix>;
  15994. /**
  15995. * Sorts bones per internal index
  15996. */
  15997. sortBones(): void;
  15998. private _sortBones;
  15999. }
  16000. }
  16001. declare module BABYLON {
  16002. /**
  16003. * Creates an instance based on a source mesh.
  16004. */
  16005. export class InstancedMesh extends AbstractMesh {
  16006. private _sourceMesh;
  16007. private _currentLOD;
  16008. /** @hidden */
  16009. _indexInSourceMeshInstanceArray: number;
  16010. constructor(name: string, source: Mesh);
  16011. /**
  16012. * Returns the string "InstancedMesh".
  16013. */
  16014. getClassName(): string;
  16015. /** Gets the list of lights affecting that mesh */
  16016. get lightSources(): Light[];
  16017. _resyncLightSources(): void;
  16018. _resyncLightSource(light: Light): void;
  16019. _removeLightSource(light: Light, dispose: boolean): void;
  16020. /**
  16021. * If the source mesh receives shadows
  16022. */
  16023. get receiveShadows(): boolean;
  16024. /**
  16025. * The material of the source mesh
  16026. */
  16027. get material(): Nullable<Material>;
  16028. /**
  16029. * Visibility of the source mesh
  16030. */
  16031. get visibility(): number;
  16032. /**
  16033. * Skeleton of the source mesh
  16034. */
  16035. get skeleton(): Nullable<Skeleton>;
  16036. /**
  16037. * Rendering ground id of the source mesh
  16038. */
  16039. get renderingGroupId(): number;
  16040. set renderingGroupId(value: number);
  16041. /**
  16042. * Returns the total number of vertices (integer).
  16043. */
  16044. getTotalVertices(): number;
  16045. /**
  16046. * Returns a positive integer : the total number of indices in this mesh geometry.
  16047. * @returns the numner of indices or zero if the mesh has no geometry.
  16048. */
  16049. getTotalIndices(): number;
  16050. /**
  16051. * The source mesh of the instance
  16052. */
  16053. get sourceMesh(): Mesh;
  16054. /**
  16055. * Creates a new InstancedMesh object from the mesh model.
  16056. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16057. * @param name defines the name of the new instance
  16058. * @returns a new InstancedMesh
  16059. */
  16060. createInstance(name: string): InstancedMesh;
  16061. /**
  16062. * Is this node ready to be used/rendered
  16063. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16064. * @return {boolean} is it ready
  16065. */
  16066. isReady(completeCheck?: boolean): boolean;
  16067. /**
  16068. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16069. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16070. * @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.
  16071. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16072. */
  16073. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16074. /**
  16075. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16076. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16077. * The `data` are either a numeric array either a Float32Array.
  16078. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16079. * 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).
  16080. * Note that a new underlying VertexBuffer object is created each call.
  16081. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16082. *
  16083. * Possible `kind` values :
  16084. * - VertexBuffer.PositionKind
  16085. * - VertexBuffer.UVKind
  16086. * - VertexBuffer.UV2Kind
  16087. * - VertexBuffer.UV3Kind
  16088. * - VertexBuffer.UV4Kind
  16089. * - VertexBuffer.UV5Kind
  16090. * - VertexBuffer.UV6Kind
  16091. * - VertexBuffer.ColorKind
  16092. * - VertexBuffer.MatricesIndicesKind
  16093. * - VertexBuffer.MatricesIndicesExtraKind
  16094. * - VertexBuffer.MatricesWeightsKind
  16095. * - VertexBuffer.MatricesWeightsExtraKind
  16096. *
  16097. * Returns the Mesh.
  16098. */
  16099. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16100. /**
  16101. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16102. * If the mesh has no geometry, it is simply returned as it is.
  16103. * The `data` are either a numeric array either a Float32Array.
  16104. * No new underlying VertexBuffer object is created.
  16105. * 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.
  16106. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16107. *
  16108. * Possible `kind` values :
  16109. * - VertexBuffer.PositionKind
  16110. * - VertexBuffer.UVKind
  16111. * - VertexBuffer.UV2Kind
  16112. * - VertexBuffer.UV3Kind
  16113. * - VertexBuffer.UV4Kind
  16114. * - VertexBuffer.UV5Kind
  16115. * - VertexBuffer.UV6Kind
  16116. * - VertexBuffer.ColorKind
  16117. * - VertexBuffer.MatricesIndicesKind
  16118. * - VertexBuffer.MatricesIndicesExtraKind
  16119. * - VertexBuffer.MatricesWeightsKind
  16120. * - VertexBuffer.MatricesWeightsExtraKind
  16121. *
  16122. * Returns the Mesh.
  16123. */
  16124. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16125. /**
  16126. * Sets the mesh indices.
  16127. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16128. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16129. * This method creates a new index buffer each call.
  16130. * Returns the Mesh.
  16131. */
  16132. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16133. /**
  16134. * Boolean : True if the mesh owns the requested kind of data.
  16135. */
  16136. isVerticesDataPresent(kind: string): boolean;
  16137. /**
  16138. * Returns an array of indices (IndicesArray).
  16139. */
  16140. getIndices(): Nullable<IndicesArray>;
  16141. get _positions(): Nullable<Vector3[]>;
  16142. /**
  16143. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16144. * This means the mesh underlying bounding box and sphere are recomputed.
  16145. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16146. * @returns the current mesh
  16147. */
  16148. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16149. /** @hidden */
  16150. _preActivate(): InstancedMesh;
  16151. /** @hidden */
  16152. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16153. /** @hidden */
  16154. _postActivate(): void;
  16155. getWorldMatrix(): Matrix;
  16156. get isAnInstance(): boolean;
  16157. /**
  16158. * Returns the current associated LOD AbstractMesh.
  16159. */
  16160. getLOD(camera: Camera): AbstractMesh;
  16161. /** @hidden */
  16162. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16163. /** @hidden */
  16164. _syncSubMeshes(): InstancedMesh;
  16165. /** @hidden */
  16166. _generatePointsArray(): boolean;
  16167. /**
  16168. * Creates a new InstancedMesh from the current mesh.
  16169. * - name (string) : the cloned mesh name
  16170. * - newParent (optional Node) : the optional Node to parent the clone to.
  16171. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16172. *
  16173. * Returns the clone.
  16174. */
  16175. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16176. /**
  16177. * Disposes the InstancedMesh.
  16178. * Returns nothing.
  16179. */
  16180. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16181. }
  16182. interface Mesh {
  16183. /**
  16184. * Register a custom buffer that will be instanced
  16185. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16186. * @param kind defines the buffer kind
  16187. * @param stride defines the stride in floats
  16188. */
  16189. registerInstancedBuffer(kind: string, stride: number): void;
  16190. /**
  16191. * true to use the edge renderer for all instances of this mesh
  16192. */
  16193. edgesShareWithInstances: boolean;
  16194. /** @hidden */
  16195. _userInstancedBuffersStorage: {
  16196. data: {
  16197. [key: string]: Float32Array;
  16198. };
  16199. sizes: {
  16200. [key: string]: number;
  16201. };
  16202. vertexBuffers: {
  16203. [key: string]: Nullable<VertexBuffer>;
  16204. };
  16205. strides: {
  16206. [key: string]: number;
  16207. };
  16208. };
  16209. }
  16210. interface AbstractMesh {
  16211. /**
  16212. * Object used to store instanced buffers defined by user
  16213. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16214. */
  16215. instancedBuffers: {
  16216. [key: string]: any;
  16217. };
  16218. }
  16219. }
  16220. declare module BABYLON {
  16221. /**
  16222. * Defines the options associated with the creation of a shader material.
  16223. */
  16224. export interface IShaderMaterialOptions {
  16225. /**
  16226. * Does the material work in alpha blend mode
  16227. */
  16228. needAlphaBlending: boolean;
  16229. /**
  16230. * Does the material work in alpha test mode
  16231. */
  16232. needAlphaTesting: boolean;
  16233. /**
  16234. * The list of attribute names used in the shader
  16235. */
  16236. attributes: string[];
  16237. /**
  16238. * The list of unifrom names used in the shader
  16239. */
  16240. uniforms: string[];
  16241. /**
  16242. * The list of UBO names used in the shader
  16243. */
  16244. uniformBuffers: string[];
  16245. /**
  16246. * The list of sampler names used in the shader
  16247. */
  16248. samplers: string[];
  16249. /**
  16250. * The list of defines used in the shader
  16251. */
  16252. defines: string[];
  16253. }
  16254. /**
  16255. * 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.
  16256. *
  16257. * This returned material effects how the mesh will look based on the code in the shaders.
  16258. *
  16259. * @see http://doc.babylonjs.com/how_to/shader_material
  16260. */
  16261. export class ShaderMaterial extends Material {
  16262. private _shaderPath;
  16263. private _options;
  16264. private _textures;
  16265. private _textureArrays;
  16266. private _floats;
  16267. private _ints;
  16268. private _floatsArrays;
  16269. private _colors3;
  16270. private _colors3Arrays;
  16271. private _colors4;
  16272. private _colors4Arrays;
  16273. private _vectors2;
  16274. private _vectors3;
  16275. private _vectors4;
  16276. private _matrices;
  16277. private _matrixArrays;
  16278. private _matrices3x3;
  16279. private _matrices2x2;
  16280. private _vectors2Arrays;
  16281. private _vectors3Arrays;
  16282. private _vectors4Arrays;
  16283. private _cachedWorldViewMatrix;
  16284. private _cachedWorldViewProjectionMatrix;
  16285. private _renderId;
  16286. private _multiview;
  16287. private _cachedDefines;
  16288. /** Define the Url to load snippets */
  16289. static SnippetUrl: string;
  16290. /** Snippet ID if the material was created from the snippet server */
  16291. snippetId: string;
  16292. /**
  16293. * Instantiate a new shader material.
  16294. * 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.
  16295. * This returned material effects how the mesh will look based on the code in the shaders.
  16296. * @see http://doc.babylonjs.com/how_to/shader_material
  16297. * @param name Define the name of the material in the scene
  16298. * @param scene Define the scene the material belongs to
  16299. * @param shaderPath Defines the route to the shader code in one of three ways:
  16300. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16301. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16302. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16303. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16304. * @param options Define the options used to create the shader
  16305. */
  16306. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16307. /**
  16308. * Gets the shader path used to define the shader code
  16309. * It can be modified to trigger a new compilation
  16310. */
  16311. get shaderPath(): any;
  16312. /**
  16313. * Sets the shader path used to define the shader code
  16314. * It can be modified to trigger a new compilation
  16315. */
  16316. set shaderPath(shaderPath: any);
  16317. /**
  16318. * Gets the options used to compile the shader.
  16319. * They can be modified to trigger a new compilation
  16320. */
  16321. get options(): IShaderMaterialOptions;
  16322. /**
  16323. * Gets the current class name of the material e.g. "ShaderMaterial"
  16324. * Mainly use in serialization.
  16325. * @returns the class name
  16326. */
  16327. getClassName(): string;
  16328. /**
  16329. * Specifies if the material will require alpha blending
  16330. * @returns a boolean specifying if alpha blending is needed
  16331. */
  16332. needAlphaBlending(): boolean;
  16333. /**
  16334. * Specifies if this material should be rendered in alpha test mode
  16335. * @returns a boolean specifying if an alpha test is needed.
  16336. */
  16337. needAlphaTesting(): boolean;
  16338. private _checkUniform;
  16339. /**
  16340. * Set a texture in the shader.
  16341. * @param name Define the name of the uniform samplers as defined in the shader
  16342. * @param texture Define the texture to bind to this sampler
  16343. * @return the material itself allowing "fluent" like uniform updates
  16344. */
  16345. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16346. /**
  16347. * Set a texture array in the shader.
  16348. * @param name Define the name of the uniform sampler array as defined in the shader
  16349. * @param textures Define the list of textures to bind to this sampler
  16350. * @return the material itself allowing "fluent" like uniform updates
  16351. */
  16352. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16353. /**
  16354. * Set a float in the shader.
  16355. * @param name Define the name of the uniform as defined in the shader
  16356. * @param value Define the value to give to the uniform
  16357. * @return the material itself allowing "fluent" like uniform updates
  16358. */
  16359. setFloat(name: string, value: number): ShaderMaterial;
  16360. /**
  16361. * Set a int in the shader.
  16362. * @param name Define the name of the uniform as defined in the shader
  16363. * @param value Define the value to give to the uniform
  16364. * @return the material itself allowing "fluent" like uniform updates
  16365. */
  16366. setInt(name: string, value: number): ShaderMaterial;
  16367. /**
  16368. * Set an array of floats in the shader.
  16369. * @param name Define the name of the uniform as defined in the shader
  16370. * @param value Define the value to give to the uniform
  16371. * @return the material itself allowing "fluent" like uniform updates
  16372. */
  16373. setFloats(name: string, value: number[]): ShaderMaterial;
  16374. /**
  16375. * Set a vec3 in the shader from a Color3.
  16376. * @param name Define the name of the uniform as defined in the shader
  16377. * @param value Define the value to give to the uniform
  16378. * @return the material itself allowing "fluent" like uniform updates
  16379. */
  16380. setColor3(name: string, value: Color3): ShaderMaterial;
  16381. /**
  16382. * Set a vec3 array in the shader from a Color3 array.
  16383. * @param name Define the name of the uniform as defined in the shader
  16384. * @param value Define the value to give to the uniform
  16385. * @return the material itself allowing "fluent" like uniform updates
  16386. */
  16387. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16388. /**
  16389. * Set a vec4 in the shader from a Color4.
  16390. * @param name Define the name of the uniform as defined in the shader
  16391. * @param value Define the value to give to the uniform
  16392. * @return the material itself allowing "fluent" like uniform updates
  16393. */
  16394. setColor4(name: string, value: Color4): ShaderMaterial;
  16395. /**
  16396. * Set a vec4 array in the shader from a Color4 array.
  16397. * @param name Define the name of the uniform as defined in the shader
  16398. * @param value Define the value to give to the uniform
  16399. * @return the material itself allowing "fluent" like uniform updates
  16400. */
  16401. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16402. /**
  16403. * Set a vec2 in the shader from a Vector2.
  16404. * @param name Define the name of the uniform as defined in the shader
  16405. * @param value Define the value to give to the uniform
  16406. * @return the material itself allowing "fluent" like uniform updates
  16407. */
  16408. setVector2(name: string, value: Vector2): ShaderMaterial;
  16409. /**
  16410. * Set a vec3 in the shader from a Vector3.
  16411. * @param name Define the name of the uniform as defined in the shader
  16412. * @param value Define the value to give to the uniform
  16413. * @return the material itself allowing "fluent" like uniform updates
  16414. */
  16415. setVector3(name: string, value: Vector3): ShaderMaterial;
  16416. /**
  16417. * Set a vec4 in the shader from a Vector4.
  16418. * @param name Define the name of the uniform as defined in the shader
  16419. * @param value Define the value to give to the uniform
  16420. * @return the material itself allowing "fluent" like uniform updates
  16421. */
  16422. setVector4(name: string, value: Vector4): ShaderMaterial;
  16423. /**
  16424. * Set a mat4 in the shader from a Matrix.
  16425. * @param name Define the name of the uniform as defined in the shader
  16426. * @param value Define the value to give to the uniform
  16427. * @return the material itself allowing "fluent" like uniform updates
  16428. */
  16429. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16430. /**
  16431. * Set a float32Array in the shader from a matrix array.
  16432. * @param name Define the name of the uniform as defined in the shader
  16433. * @param value Define the value to give to the uniform
  16434. * @return the material itself allowing "fluent" like uniform updates
  16435. */
  16436. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16437. /**
  16438. * Set a mat3 in the shader from a Float32Array.
  16439. * @param name Define the name of the uniform as defined in the shader
  16440. * @param value Define the value to give to the uniform
  16441. * @return the material itself allowing "fluent" like uniform updates
  16442. */
  16443. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16444. /**
  16445. * Set a mat2 in the shader from a Float32Array.
  16446. * @param name Define the name of the uniform as defined in the shader
  16447. * @param value Define the value to give to the uniform
  16448. * @return the material itself allowing "fluent" like uniform updates
  16449. */
  16450. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16451. /**
  16452. * Set a vec2 array in the shader from a number array.
  16453. * @param name Define the name of the uniform as defined in the shader
  16454. * @param value Define the value to give to the uniform
  16455. * @return the material itself allowing "fluent" like uniform updates
  16456. */
  16457. setArray2(name: string, value: number[]): ShaderMaterial;
  16458. /**
  16459. * Set a vec3 array in the shader from a number array.
  16460. * @param name Define the name of the uniform as defined in the shader
  16461. * @param value Define the value to give to the uniform
  16462. * @return the material itself allowing "fluent" like uniform updates
  16463. */
  16464. setArray3(name: string, value: number[]): ShaderMaterial;
  16465. /**
  16466. * Set a vec4 array in the shader from a number array.
  16467. * @param name Define the name of the uniform as defined in the shader
  16468. * @param value Define the value to give to the uniform
  16469. * @return the material itself allowing "fluent" like uniform updates
  16470. */
  16471. setArray4(name: string, value: number[]): ShaderMaterial;
  16472. private _checkCache;
  16473. /**
  16474. * Specifies that the submesh is ready to be used
  16475. * @param mesh defines the mesh to check
  16476. * @param subMesh defines which submesh to check
  16477. * @param useInstances specifies that instances should be used
  16478. * @returns a boolean indicating that the submesh is ready or not
  16479. */
  16480. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16481. /**
  16482. * Checks if the material is ready to render the requested mesh
  16483. * @param mesh Define the mesh to render
  16484. * @param useInstances Define whether or not the material is used with instances
  16485. * @returns true if ready, otherwise false
  16486. */
  16487. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16488. /**
  16489. * Binds the world matrix to the material
  16490. * @param world defines the world transformation matrix
  16491. * @param effectOverride - If provided, use this effect instead of internal effect
  16492. */
  16493. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16494. /**
  16495. * Binds the submesh to this material by preparing the effect and shader to draw
  16496. * @param world defines the world transformation matrix
  16497. * @param mesh defines the mesh containing the submesh
  16498. * @param subMesh defines the submesh to bind the material to
  16499. */
  16500. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16501. /**
  16502. * Binds the material to the mesh
  16503. * @param world defines the world transformation matrix
  16504. * @param mesh defines the mesh to bind the material to
  16505. * @param effectOverride - If provided, use this effect instead of internal effect
  16506. */
  16507. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16508. protected _afterBind(mesh?: Mesh): void;
  16509. /**
  16510. * Gets the active textures from the material
  16511. * @returns an array of textures
  16512. */
  16513. getActiveTextures(): BaseTexture[];
  16514. /**
  16515. * Specifies if the material uses a texture
  16516. * @param texture defines the texture to check against the material
  16517. * @returns a boolean specifying if the material uses the texture
  16518. */
  16519. hasTexture(texture: BaseTexture): boolean;
  16520. /**
  16521. * Makes a duplicate of the material, and gives it a new name
  16522. * @param name defines the new name for the duplicated material
  16523. * @returns the cloned material
  16524. */
  16525. clone(name: string): ShaderMaterial;
  16526. /**
  16527. * Disposes the material
  16528. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16529. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16530. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16531. */
  16532. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16533. /**
  16534. * Serializes this material in a JSON representation
  16535. * @returns the serialized material object
  16536. */
  16537. serialize(): any;
  16538. /**
  16539. * Creates a shader material from parsed shader material data
  16540. * @param source defines the JSON represnetation of the material
  16541. * @param scene defines the hosting scene
  16542. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16543. * @returns a new material
  16544. */
  16545. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16546. /**
  16547. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16548. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16549. * @param url defines the url to load from
  16550. * @param scene defines the hosting scene
  16551. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16552. * @returns a promise that will resolve to the new ShaderMaterial
  16553. */
  16554. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16555. /**
  16556. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16557. * @param snippetId defines the snippet to load
  16558. * @param scene defines the hosting scene
  16559. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16560. * @returns a promise that will resolve to the new ShaderMaterial
  16561. */
  16562. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16563. }
  16564. }
  16565. declare module BABYLON {
  16566. /** @hidden */
  16567. export var colorPixelShader: {
  16568. name: string;
  16569. shader: string;
  16570. };
  16571. }
  16572. declare module BABYLON {
  16573. /** @hidden */
  16574. export var colorVertexShader: {
  16575. name: string;
  16576. shader: string;
  16577. };
  16578. }
  16579. declare module BABYLON {
  16580. /**
  16581. * Line mesh
  16582. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16583. */
  16584. export class LinesMesh extends Mesh {
  16585. /**
  16586. * If vertex color should be applied to the mesh
  16587. */
  16588. readonly useVertexColor?: boolean | undefined;
  16589. /**
  16590. * If vertex alpha should be applied to the mesh
  16591. */
  16592. readonly useVertexAlpha?: boolean | undefined;
  16593. /**
  16594. * Color of the line (Default: White)
  16595. */
  16596. color: Color3;
  16597. /**
  16598. * Alpha of the line (Default: 1)
  16599. */
  16600. alpha: number;
  16601. /**
  16602. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16603. * This margin is expressed in world space coordinates, so its value may vary.
  16604. * Default value is 0.1
  16605. */
  16606. intersectionThreshold: number;
  16607. private _colorShader;
  16608. private color4;
  16609. /**
  16610. * Creates a new LinesMesh
  16611. * @param name defines the name
  16612. * @param scene defines the hosting scene
  16613. * @param parent defines the parent mesh if any
  16614. * @param source defines the optional source LinesMesh used to clone data from
  16615. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16616. * When false, achieved by calling a clone(), also passing False.
  16617. * This will make creation of children, recursive.
  16618. * @param useVertexColor defines if this LinesMesh supports vertex color
  16619. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16620. */
  16621. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16622. /**
  16623. * If vertex color should be applied to the mesh
  16624. */
  16625. useVertexColor?: boolean | undefined,
  16626. /**
  16627. * If vertex alpha should be applied to the mesh
  16628. */
  16629. useVertexAlpha?: boolean | undefined);
  16630. private _addClipPlaneDefine;
  16631. private _removeClipPlaneDefine;
  16632. isReady(): boolean;
  16633. /**
  16634. * Returns the string "LineMesh"
  16635. */
  16636. getClassName(): string;
  16637. /**
  16638. * @hidden
  16639. */
  16640. get material(): Material;
  16641. /**
  16642. * @hidden
  16643. */
  16644. set material(value: Material);
  16645. /**
  16646. * @hidden
  16647. */
  16648. get checkCollisions(): boolean;
  16649. /** @hidden */
  16650. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16651. /** @hidden */
  16652. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16653. /**
  16654. * Disposes of the line mesh
  16655. * @param doNotRecurse If children should be disposed
  16656. */
  16657. dispose(doNotRecurse?: boolean): void;
  16658. /**
  16659. * Returns a new LineMesh object cloned from the current one.
  16660. */
  16661. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16662. /**
  16663. * Creates a new InstancedLinesMesh object from the mesh model.
  16664. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16665. * @param name defines the name of the new instance
  16666. * @returns a new InstancedLinesMesh
  16667. */
  16668. createInstance(name: string): InstancedLinesMesh;
  16669. }
  16670. /**
  16671. * Creates an instance based on a source LinesMesh
  16672. */
  16673. export class InstancedLinesMesh extends InstancedMesh {
  16674. /**
  16675. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16676. * This margin is expressed in world space coordinates, so its value may vary.
  16677. * Initilized with the intersectionThreshold value of the source LinesMesh
  16678. */
  16679. intersectionThreshold: number;
  16680. constructor(name: string, source: LinesMesh);
  16681. /**
  16682. * Returns the string "InstancedLinesMesh".
  16683. */
  16684. getClassName(): string;
  16685. }
  16686. }
  16687. declare module BABYLON {
  16688. /** @hidden */
  16689. export var linePixelShader: {
  16690. name: string;
  16691. shader: string;
  16692. };
  16693. }
  16694. declare module BABYLON {
  16695. /** @hidden */
  16696. export var lineVertexShader: {
  16697. name: string;
  16698. shader: string;
  16699. };
  16700. }
  16701. declare module BABYLON {
  16702. interface Scene {
  16703. /** @hidden */
  16704. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  16705. }
  16706. interface AbstractMesh {
  16707. /**
  16708. * Gets the edgesRenderer associated with the mesh
  16709. */
  16710. edgesRenderer: Nullable<EdgesRenderer>;
  16711. }
  16712. interface LinesMesh {
  16713. /**
  16714. * Enables the edge rendering mode on the mesh.
  16715. * This mode makes the mesh edges visible
  16716. * @param epsilon defines the maximal distance between two angles to detect a face
  16717. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16718. * @returns the currentAbstractMesh
  16719. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16720. */
  16721. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16722. }
  16723. interface InstancedLinesMesh {
  16724. /**
  16725. * Enables the edge rendering mode on the mesh.
  16726. * This mode makes the mesh edges visible
  16727. * @param epsilon defines the maximal distance between two angles to detect a face
  16728. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16729. * @returns the current InstancedLinesMesh
  16730. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16731. */
  16732. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16733. }
  16734. /**
  16735. * Defines the minimum contract an Edges renderer should follow.
  16736. */
  16737. export interface IEdgesRenderer extends IDisposable {
  16738. /**
  16739. * Gets or sets a boolean indicating if the edgesRenderer is active
  16740. */
  16741. isEnabled: boolean;
  16742. /**
  16743. * Renders the edges of the attached mesh,
  16744. */
  16745. render(): void;
  16746. /**
  16747. * Checks wether or not the edges renderer is ready to render.
  16748. * @return true if ready, otherwise false.
  16749. */
  16750. isReady(): boolean;
  16751. /**
  16752. * List of instances to render in case the source mesh has instances
  16753. */
  16754. customInstances: SmartArray<Matrix>;
  16755. }
  16756. /**
  16757. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16758. */
  16759. export class EdgesRenderer implements IEdgesRenderer {
  16760. /**
  16761. * Define the size of the edges with an orthographic camera
  16762. */
  16763. edgesWidthScalerForOrthographic: number;
  16764. /**
  16765. * Define the size of the edges with a perspective camera
  16766. */
  16767. edgesWidthScalerForPerspective: number;
  16768. protected _source: AbstractMesh;
  16769. protected _linesPositions: number[];
  16770. protected _linesNormals: number[];
  16771. protected _linesIndices: number[];
  16772. protected _epsilon: number;
  16773. protected _indicesCount: number;
  16774. protected _lineShader: ShaderMaterial;
  16775. protected _ib: DataBuffer;
  16776. protected _buffers: {
  16777. [key: string]: Nullable<VertexBuffer>;
  16778. };
  16779. protected _buffersForInstances: {
  16780. [key: string]: Nullable<VertexBuffer>;
  16781. };
  16782. protected _checkVerticesInsteadOfIndices: boolean;
  16783. private _meshRebuildObserver;
  16784. private _meshDisposeObserver;
  16785. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16786. isEnabled: boolean;
  16787. /**
  16788. * List of instances to render in case the source mesh has instances
  16789. */
  16790. customInstances: SmartArray<Matrix>;
  16791. private static GetShader;
  16792. /**
  16793. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16794. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16795. * @param source Mesh used to create edges
  16796. * @param epsilon sum of angles in adjacency to check for edge
  16797. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16798. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16799. */
  16800. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16801. protected _prepareRessources(): void;
  16802. /** @hidden */
  16803. _rebuild(): void;
  16804. /**
  16805. * Releases the required resources for the edges renderer
  16806. */
  16807. dispose(): void;
  16808. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16809. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16810. /**
  16811. * Checks if the pair of p0 and p1 is en edge
  16812. * @param faceIndex
  16813. * @param edge
  16814. * @param faceNormals
  16815. * @param p0
  16816. * @param p1
  16817. * @private
  16818. */
  16819. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16820. /**
  16821. * push line into the position, normal and index buffer
  16822. * @protected
  16823. */
  16824. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16825. /**
  16826. * Generates lines edges from adjacencjes
  16827. * @private
  16828. */
  16829. _generateEdgesLines(): void;
  16830. /**
  16831. * Checks wether or not the edges renderer is ready to render.
  16832. * @return true if ready, otherwise false.
  16833. */
  16834. isReady(): boolean;
  16835. /**
  16836. * Renders the edges of the attached mesh,
  16837. */
  16838. render(): void;
  16839. }
  16840. /**
  16841. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16842. */
  16843. export class LineEdgesRenderer extends EdgesRenderer {
  16844. /**
  16845. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16846. * @param source LineMesh used to generate edges
  16847. * @param epsilon not important (specified angle for edge detection)
  16848. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16849. */
  16850. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16851. /**
  16852. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16853. */
  16854. _generateEdgesLines(): void;
  16855. }
  16856. }
  16857. declare module BABYLON {
  16858. /**
  16859. * This represents the object necessary to create a rendering group.
  16860. * This is exclusively used and created by the rendering manager.
  16861. * To modify the behavior, you use the available helpers in your scene or meshes.
  16862. * @hidden
  16863. */
  16864. export class RenderingGroup {
  16865. index: number;
  16866. private static _zeroVector;
  16867. private _scene;
  16868. private _opaqueSubMeshes;
  16869. private _transparentSubMeshes;
  16870. private _alphaTestSubMeshes;
  16871. private _depthOnlySubMeshes;
  16872. private _particleSystems;
  16873. private _spriteManagers;
  16874. private _opaqueSortCompareFn;
  16875. private _alphaTestSortCompareFn;
  16876. private _transparentSortCompareFn;
  16877. private _renderOpaque;
  16878. private _renderAlphaTest;
  16879. private _renderTransparent;
  16880. /** @hidden */
  16881. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  16882. onBeforeTransparentRendering: () => void;
  16883. /**
  16884. * Set the opaque sort comparison function.
  16885. * If null the sub meshes will be render in the order they were created
  16886. */
  16887. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16888. /**
  16889. * Set the alpha test sort comparison function.
  16890. * If null the sub meshes will be render in the order they were created
  16891. */
  16892. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16893. /**
  16894. * Set the transparent sort comparison function.
  16895. * If null the sub meshes will be render in the order they were created
  16896. */
  16897. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16898. /**
  16899. * Creates a new rendering group.
  16900. * @param index The rendering group index
  16901. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16902. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16903. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16904. */
  16905. 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>);
  16906. /**
  16907. * Render all the sub meshes contained in the group.
  16908. * @param customRenderFunction Used to override the default render behaviour of the group.
  16909. * @returns true if rendered some submeshes.
  16910. */
  16911. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16912. /**
  16913. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16914. * @param subMeshes The submeshes to render
  16915. */
  16916. private renderOpaqueSorted;
  16917. /**
  16918. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16919. * @param subMeshes The submeshes to render
  16920. */
  16921. private renderAlphaTestSorted;
  16922. /**
  16923. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16924. * @param subMeshes The submeshes to render
  16925. */
  16926. private renderTransparentSorted;
  16927. /**
  16928. * Renders the submeshes in a specified order.
  16929. * @param subMeshes The submeshes to sort before render
  16930. * @param sortCompareFn The comparison function use to sort
  16931. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16932. * @param transparent Specifies to activate blending if true
  16933. */
  16934. private static renderSorted;
  16935. /**
  16936. * Renders the submeshes in the order they were dispatched (no sort applied).
  16937. * @param subMeshes The submeshes to render
  16938. */
  16939. private static renderUnsorted;
  16940. /**
  16941. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16942. * are rendered back to front if in the same alpha index.
  16943. *
  16944. * @param a The first submesh
  16945. * @param b The second submesh
  16946. * @returns The result of the comparison
  16947. */
  16948. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16949. /**
  16950. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16951. * are rendered back to front.
  16952. *
  16953. * @param a The first submesh
  16954. * @param b The second submesh
  16955. * @returns The result of the comparison
  16956. */
  16957. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16958. /**
  16959. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16960. * are rendered front to back (prevent overdraw).
  16961. *
  16962. * @param a The first submesh
  16963. * @param b The second submesh
  16964. * @returns The result of the comparison
  16965. */
  16966. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16967. /**
  16968. * Resets the different lists of submeshes to prepare a new frame.
  16969. */
  16970. prepare(): void;
  16971. dispose(): void;
  16972. /**
  16973. * Inserts the submesh in its correct queue depending on its material.
  16974. * @param subMesh The submesh to dispatch
  16975. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16976. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16977. */
  16978. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16979. dispatchSprites(spriteManager: ISpriteManager): void;
  16980. dispatchParticles(particleSystem: IParticleSystem): void;
  16981. private _renderParticles;
  16982. private _renderSprites;
  16983. }
  16984. }
  16985. declare module BABYLON {
  16986. /**
  16987. * Interface describing the different options available in the rendering manager
  16988. * regarding Auto Clear between groups.
  16989. */
  16990. export interface IRenderingManagerAutoClearSetup {
  16991. /**
  16992. * Defines whether or not autoclear is enable.
  16993. */
  16994. autoClear: boolean;
  16995. /**
  16996. * Defines whether or not to autoclear the depth buffer.
  16997. */
  16998. depth: boolean;
  16999. /**
  17000. * Defines whether or not to autoclear the stencil buffer.
  17001. */
  17002. stencil: boolean;
  17003. }
  17004. /**
  17005. * This class is used by the onRenderingGroupObservable
  17006. */
  17007. export class RenderingGroupInfo {
  17008. /**
  17009. * The Scene that being rendered
  17010. */
  17011. scene: Scene;
  17012. /**
  17013. * The camera currently used for the rendering pass
  17014. */
  17015. camera: Nullable<Camera>;
  17016. /**
  17017. * The ID of the renderingGroup being processed
  17018. */
  17019. renderingGroupId: number;
  17020. }
  17021. /**
  17022. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17023. * It is enable to manage the different groups as well as the different necessary sort functions.
  17024. * This should not be used directly aside of the few static configurations
  17025. */
  17026. export class RenderingManager {
  17027. /**
  17028. * The max id used for rendering groups (not included)
  17029. */
  17030. static MAX_RENDERINGGROUPS: number;
  17031. /**
  17032. * The min id used for rendering groups (included)
  17033. */
  17034. static MIN_RENDERINGGROUPS: number;
  17035. /**
  17036. * Used to globally prevent autoclearing scenes.
  17037. */
  17038. static AUTOCLEAR: boolean;
  17039. /**
  17040. * @hidden
  17041. */
  17042. _useSceneAutoClearSetup: boolean;
  17043. private _scene;
  17044. private _renderingGroups;
  17045. private _depthStencilBufferAlreadyCleaned;
  17046. private _autoClearDepthStencil;
  17047. private _customOpaqueSortCompareFn;
  17048. private _customAlphaTestSortCompareFn;
  17049. private _customTransparentSortCompareFn;
  17050. private _renderingGroupInfo;
  17051. /**
  17052. * Instantiates a new rendering group for a particular scene
  17053. * @param scene Defines the scene the groups belongs to
  17054. */
  17055. constructor(scene: Scene);
  17056. private _clearDepthStencilBuffer;
  17057. /**
  17058. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17059. * @hidden
  17060. */
  17061. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17062. /**
  17063. * Resets the different information of the group to prepare a new frame
  17064. * @hidden
  17065. */
  17066. reset(): void;
  17067. /**
  17068. * Dispose and release the group and its associated resources.
  17069. * @hidden
  17070. */
  17071. dispose(): void;
  17072. /**
  17073. * Clear the info related to rendering groups preventing retention points during dispose.
  17074. */
  17075. freeRenderingGroups(): void;
  17076. private _prepareRenderingGroup;
  17077. /**
  17078. * Add a sprite manager to the rendering manager in order to render it this frame.
  17079. * @param spriteManager Define the sprite manager to render
  17080. */
  17081. dispatchSprites(spriteManager: ISpriteManager): void;
  17082. /**
  17083. * Add a particle system to the rendering manager in order to render it this frame.
  17084. * @param particleSystem Define the particle system to render
  17085. */
  17086. dispatchParticles(particleSystem: IParticleSystem): void;
  17087. /**
  17088. * Add a submesh to the manager in order to render it this frame
  17089. * @param subMesh The submesh to dispatch
  17090. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17091. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17092. */
  17093. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17094. /**
  17095. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17096. * This allowed control for front to back rendering or reversly depending of the special needs.
  17097. *
  17098. * @param renderingGroupId The rendering group id corresponding to its index
  17099. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17100. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17101. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17102. */
  17103. 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;
  17104. /**
  17105. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17106. *
  17107. * @param renderingGroupId The rendering group id corresponding to its index
  17108. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17109. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17110. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17111. */
  17112. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17113. /**
  17114. * Gets the current auto clear configuration for one rendering group of the rendering
  17115. * manager.
  17116. * @param index the rendering group index to get the information for
  17117. * @returns The auto clear setup for the requested rendering group
  17118. */
  17119. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17120. }
  17121. }
  17122. declare module BABYLON {
  17123. /**
  17124. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17125. */
  17126. export interface ICustomShaderOptions {
  17127. /**
  17128. * Gets or sets the custom shader name to use
  17129. */
  17130. shaderName: string;
  17131. /**
  17132. * The list of attribute names used in the shader
  17133. */
  17134. attributes?: string[];
  17135. /**
  17136. * The list of unifrom names used in the shader
  17137. */
  17138. uniforms?: string[];
  17139. /**
  17140. * The list of sampler names used in the shader
  17141. */
  17142. samplers?: string[];
  17143. /**
  17144. * The list of defines used in the shader
  17145. */
  17146. defines?: string[];
  17147. }
  17148. /**
  17149. * Interface to implement to create a shadow generator compatible with BJS.
  17150. */
  17151. export interface IShadowGenerator {
  17152. /**
  17153. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17154. * @returns The render target texture if present otherwise, null
  17155. */
  17156. getShadowMap(): Nullable<RenderTargetTexture>;
  17157. /**
  17158. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17159. * @param subMesh The submesh we want to render in the shadow map
  17160. * @param useInstances Defines wether will draw in the map using instances
  17161. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17162. * @returns true if ready otherwise, false
  17163. */
  17164. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17165. /**
  17166. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17167. * @param defines Defines of the material we want to update
  17168. * @param lightIndex Index of the light in the enabled light list of the material
  17169. */
  17170. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17171. /**
  17172. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17173. * defined in the generator but impacting the effect).
  17174. * It implies the unifroms available on the materials are the standard BJS ones.
  17175. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17176. * @param effect The effect we are binfing the information for
  17177. */
  17178. bindShadowLight(lightIndex: string, effect: Effect): void;
  17179. /**
  17180. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17181. * (eq to shadow prjection matrix * light transform matrix)
  17182. * @returns The transform matrix used to create the shadow map
  17183. */
  17184. getTransformMatrix(): Matrix;
  17185. /**
  17186. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17187. * Cube and 2D textures for instance.
  17188. */
  17189. recreateShadowMap(): void;
  17190. /**
  17191. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17192. * @param onCompiled Callback triggered at the and of the effects compilation
  17193. * @param options Sets of optional options forcing the compilation with different modes
  17194. */
  17195. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17196. useInstances: boolean;
  17197. }>): void;
  17198. /**
  17199. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17200. * @param options Sets of optional options forcing the compilation with different modes
  17201. * @returns A promise that resolves when the compilation completes
  17202. */
  17203. forceCompilationAsync(options?: Partial<{
  17204. useInstances: boolean;
  17205. }>): Promise<void>;
  17206. /**
  17207. * Serializes the shadow generator setup to a json object.
  17208. * @returns The serialized JSON object
  17209. */
  17210. serialize(): any;
  17211. /**
  17212. * Disposes the Shadow map and related Textures and effects.
  17213. */
  17214. dispose(): void;
  17215. }
  17216. /**
  17217. * Default implementation IShadowGenerator.
  17218. * This is the main object responsible of generating shadows in the framework.
  17219. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17220. */
  17221. export class ShadowGenerator implements IShadowGenerator {
  17222. /**
  17223. * Name of the shadow generator class
  17224. */
  17225. static CLASSNAME: string;
  17226. /**
  17227. * Shadow generator mode None: no filtering applied.
  17228. */
  17229. static readonly FILTER_NONE: number;
  17230. /**
  17231. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17232. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17233. */
  17234. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17235. /**
  17236. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17237. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17238. */
  17239. static readonly FILTER_POISSONSAMPLING: number;
  17240. /**
  17241. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17242. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17243. */
  17244. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17245. /**
  17246. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17247. * edge artifacts on steep falloff.
  17248. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17249. */
  17250. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17251. /**
  17252. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17253. * edge artifacts on steep falloff.
  17254. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17255. */
  17256. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17257. /**
  17258. * Shadow generator mode PCF: Percentage Closer Filtering
  17259. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17260. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17261. */
  17262. static readonly FILTER_PCF: number;
  17263. /**
  17264. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17265. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17266. * Contact Hardening
  17267. */
  17268. static readonly FILTER_PCSS: number;
  17269. /**
  17270. * Reserved for PCF and PCSS
  17271. * Highest Quality.
  17272. *
  17273. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17274. *
  17275. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17276. */
  17277. static readonly QUALITY_HIGH: number;
  17278. /**
  17279. * Reserved for PCF and PCSS
  17280. * Good tradeoff for quality/perf cross devices
  17281. *
  17282. * Execute PCF on a 3*3 kernel.
  17283. *
  17284. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17285. */
  17286. static readonly QUALITY_MEDIUM: number;
  17287. /**
  17288. * Reserved for PCF and PCSS
  17289. * The lowest quality but the fastest.
  17290. *
  17291. * Execute PCF on a 1*1 kernel.
  17292. *
  17293. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17294. */
  17295. static readonly QUALITY_LOW: number;
  17296. /** Gets or sets the custom shader name to use */
  17297. customShaderOptions: ICustomShaderOptions;
  17298. /**
  17299. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17300. */
  17301. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17302. /**
  17303. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17304. */
  17305. onAfterShadowMapRenderObservable: Observable<Effect>;
  17306. /**
  17307. * Observable triggered before a mesh is rendered in the shadow map.
  17308. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17309. */
  17310. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17311. /**
  17312. * Observable triggered after a mesh is rendered in the shadow map.
  17313. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17314. */
  17315. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17316. protected _bias: number;
  17317. /**
  17318. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17319. */
  17320. get bias(): number;
  17321. /**
  17322. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17323. */
  17324. set bias(bias: number);
  17325. protected _normalBias: number;
  17326. /**
  17327. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17328. */
  17329. get normalBias(): number;
  17330. /**
  17331. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17332. */
  17333. set normalBias(normalBias: number);
  17334. protected _blurBoxOffset: number;
  17335. /**
  17336. * Gets the blur box offset: offset applied during the blur pass.
  17337. * Only useful if useKernelBlur = false
  17338. */
  17339. get blurBoxOffset(): number;
  17340. /**
  17341. * Sets the blur box offset: offset applied during the blur pass.
  17342. * Only useful if useKernelBlur = false
  17343. */
  17344. set blurBoxOffset(value: number);
  17345. protected _blurScale: number;
  17346. /**
  17347. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17348. * 2 means half of the size.
  17349. */
  17350. get blurScale(): number;
  17351. /**
  17352. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17353. * 2 means half of the size.
  17354. */
  17355. set blurScale(value: number);
  17356. protected _blurKernel: number;
  17357. /**
  17358. * Gets the blur kernel: kernel size of the blur pass.
  17359. * Only useful if useKernelBlur = true
  17360. */
  17361. get blurKernel(): number;
  17362. /**
  17363. * Sets the blur kernel: kernel size of the blur pass.
  17364. * Only useful if useKernelBlur = true
  17365. */
  17366. set blurKernel(value: number);
  17367. protected _useKernelBlur: boolean;
  17368. /**
  17369. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17370. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17371. */
  17372. get useKernelBlur(): boolean;
  17373. /**
  17374. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17375. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17376. */
  17377. set useKernelBlur(value: boolean);
  17378. protected _depthScale: number;
  17379. /**
  17380. * Gets the depth scale used in ESM mode.
  17381. */
  17382. get depthScale(): number;
  17383. /**
  17384. * Sets the depth scale used in ESM mode.
  17385. * This can override the scale stored on the light.
  17386. */
  17387. set depthScale(value: number);
  17388. protected _validateFilter(filter: number): number;
  17389. protected _filter: number;
  17390. /**
  17391. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17392. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17393. */
  17394. get filter(): number;
  17395. /**
  17396. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17397. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17398. */
  17399. set filter(value: number);
  17400. /**
  17401. * Gets if the current filter is set to Poisson Sampling.
  17402. */
  17403. get usePoissonSampling(): boolean;
  17404. /**
  17405. * Sets the current filter to Poisson Sampling.
  17406. */
  17407. set usePoissonSampling(value: boolean);
  17408. /**
  17409. * Gets if the current filter is set to ESM.
  17410. */
  17411. get useExponentialShadowMap(): boolean;
  17412. /**
  17413. * Sets the current filter is to ESM.
  17414. */
  17415. set useExponentialShadowMap(value: boolean);
  17416. /**
  17417. * Gets if the current filter is set to filtered ESM.
  17418. */
  17419. get useBlurExponentialShadowMap(): boolean;
  17420. /**
  17421. * Gets if the current filter is set to filtered ESM.
  17422. */
  17423. set useBlurExponentialShadowMap(value: boolean);
  17424. /**
  17425. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17426. * exponential to prevent steep falloff artifacts).
  17427. */
  17428. get useCloseExponentialShadowMap(): boolean;
  17429. /**
  17430. * Sets the current filter to "close ESM" (using the inverse of the
  17431. * exponential to prevent steep falloff artifacts).
  17432. */
  17433. set useCloseExponentialShadowMap(value: boolean);
  17434. /**
  17435. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17436. * exponential to prevent steep falloff artifacts).
  17437. */
  17438. get useBlurCloseExponentialShadowMap(): boolean;
  17439. /**
  17440. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17441. * exponential to prevent steep falloff artifacts).
  17442. */
  17443. set useBlurCloseExponentialShadowMap(value: boolean);
  17444. /**
  17445. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17446. */
  17447. get usePercentageCloserFiltering(): boolean;
  17448. /**
  17449. * Sets the current filter to "PCF" (percentage closer filtering).
  17450. */
  17451. set usePercentageCloserFiltering(value: boolean);
  17452. protected _filteringQuality: number;
  17453. /**
  17454. * Gets the PCF or PCSS Quality.
  17455. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17456. */
  17457. get filteringQuality(): number;
  17458. /**
  17459. * Sets the PCF or PCSS Quality.
  17460. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17461. */
  17462. set filteringQuality(filteringQuality: number);
  17463. /**
  17464. * Gets if the current filter is set to "PCSS" (contact hardening).
  17465. */
  17466. get useContactHardeningShadow(): boolean;
  17467. /**
  17468. * Sets the current filter to "PCSS" (contact hardening).
  17469. */
  17470. set useContactHardeningShadow(value: boolean);
  17471. protected _contactHardeningLightSizeUVRatio: number;
  17472. /**
  17473. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17474. * Using a ratio helps keeping shape stability independently of the map size.
  17475. *
  17476. * It does not account for the light projection as it was having too much
  17477. * instability during the light setup or during light position changes.
  17478. *
  17479. * Only valid if useContactHardeningShadow is true.
  17480. */
  17481. get contactHardeningLightSizeUVRatio(): number;
  17482. /**
  17483. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17484. * Using a ratio helps keeping shape stability independently of the map size.
  17485. *
  17486. * It does not account for the light projection as it was having too much
  17487. * instability during the light setup or during light position changes.
  17488. *
  17489. * Only valid if useContactHardeningShadow is true.
  17490. */
  17491. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17492. protected _darkness: number;
  17493. /** Gets or sets the actual darkness of a shadow */
  17494. get darkness(): number;
  17495. set darkness(value: number);
  17496. /**
  17497. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17498. * 0 means strongest and 1 would means no shadow.
  17499. * @returns the darkness.
  17500. */
  17501. getDarkness(): number;
  17502. /**
  17503. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17504. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17505. * @returns the shadow generator allowing fluent coding.
  17506. */
  17507. setDarkness(darkness: number): ShadowGenerator;
  17508. protected _transparencyShadow: boolean;
  17509. /** Gets or sets the ability to have transparent shadow */
  17510. get transparencyShadow(): boolean;
  17511. set transparencyShadow(value: boolean);
  17512. /**
  17513. * Sets the ability to have transparent shadow (boolean).
  17514. * @param transparent True if transparent else False
  17515. * @returns the shadow generator allowing fluent coding
  17516. */
  17517. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17518. /**
  17519. * Enables or disables shadows with varying strength based on the transparency
  17520. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17521. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17522. * mesh.visibility * alphaTexture.a
  17523. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17524. */
  17525. enableSoftTransparentShadow: boolean;
  17526. protected _shadowMap: Nullable<RenderTargetTexture>;
  17527. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17528. /**
  17529. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17530. * @returns The render target texture if present otherwise, null
  17531. */
  17532. getShadowMap(): Nullable<RenderTargetTexture>;
  17533. /**
  17534. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17535. * @returns The render target texture if the shadow map is present otherwise, null
  17536. */
  17537. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17538. /**
  17539. * Gets the class name of that object
  17540. * @returns "ShadowGenerator"
  17541. */
  17542. getClassName(): string;
  17543. /**
  17544. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17545. * @param mesh Mesh to add
  17546. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17547. * @returns the Shadow Generator itself
  17548. */
  17549. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17550. /**
  17551. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17552. * @param mesh Mesh to remove
  17553. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17554. * @returns the Shadow Generator itself
  17555. */
  17556. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17557. /**
  17558. * Controls the extent to which the shadows fade out at the edge of the frustum
  17559. */
  17560. frustumEdgeFalloff: number;
  17561. protected _light: IShadowLight;
  17562. /**
  17563. * Returns the associated light object.
  17564. * @returns the light generating the shadow
  17565. */
  17566. getLight(): IShadowLight;
  17567. /**
  17568. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17569. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17570. * It might on the other hand introduce peter panning.
  17571. */
  17572. forceBackFacesOnly: boolean;
  17573. protected _scene: Scene;
  17574. protected _lightDirection: Vector3;
  17575. protected _effect: Effect;
  17576. protected _viewMatrix: Matrix;
  17577. protected _projectionMatrix: Matrix;
  17578. protected _transformMatrix: Matrix;
  17579. protected _cachedPosition: Vector3;
  17580. protected _cachedDirection: Vector3;
  17581. protected _cachedDefines: string;
  17582. protected _currentRenderID: number;
  17583. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17584. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17585. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17586. protected _blurPostProcesses: PostProcess[];
  17587. protected _mapSize: number;
  17588. protected _currentFaceIndex: number;
  17589. protected _currentFaceIndexCache: number;
  17590. protected _textureType: number;
  17591. protected _defaultTextureMatrix: Matrix;
  17592. protected _storedUniqueId: Nullable<number>;
  17593. /** @hidden */
  17594. static _SceneComponentInitialization: (scene: Scene) => void;
  17595. /**
  17596. * Creates a ShadowGenerator object.
  17597. * A ShadowGenerator is the required tool to use the shadows.
  17598. * Each light casting shadows needs to use its own ShadowGenerator.
  17599. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17600. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17601. * @param light The light object generating the shadows.
  17602. * @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.
  17603. */
  17604. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17605. protected _initializeGenerator(): void;
  17606. protected _createTargetRenderTexture(): void;
  17607. protected _initializeShadowMap(): void;
  17608. protected _initializeBlurRTTAndPostProcesses(): void;
  17609. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17610. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17611. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17612. protected _applyFilterValues(): void;
  17613. /**
  17614. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17615. * @param onCompiled Callback triggered at the and of the effects compilation
  17616. * @param options Sets of optional options forcing the compilation with different modes
  17617. */
  17618. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17619. useInstances: boolean;
  17620. }>): void;
  17621. /**
  17622. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17623. * @param options Sets of optional options forcing the compilation with different modes
  17624. * @returns A promise that resolves when the compilation completes
  17625. */
  17626. forceCompilationAsync(options?: Partial<{
  17627. useInstances: boolean;
  17628. }>): Promise<void>;
  17629. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17630. private _prepareShadowDefines;
  17631. /**
  17632. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17633. * @param subMesh The submesh we want to render in the shadow map
  17634. * @param useInstances Defines wether will draw in the map using instances
  17635. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17636. * @returns true if ready otherwise, false
  17637. */
  17638. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17639. /**
  17640. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17641. * @param defines Defines of the material we want to update
  17642. * @param lightIndex Index of the light in the enabled light list of the material
  17643. */
  17644. prepareDefines(defines: any, lightIndex: number): void;
  17645. /**
  17646. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17647. * defined in the generator but impacting the effect).
  17648. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17649. * @param effect The effect we are binfing the information for
  17650. */
  17651. bindShadowLight(lightIndex: string, effect: Effect): void;
  17652. /**
  17653. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17654. * (eq to shadow prjection matrix * light transform matrix)
  17655. * @returns The transform matrix used to create the shadow map
  17656. */
  17657. getTransformMatrix(): Matrix;
  17658. /**
  17659. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17660. * Cube and 2D textures for instance.
  17661. */
  17662. recreateShadowMap(): void;
  17663. protected _disposeBlurPostProcesses(): void;
  17664. protected _disposeRTTandPostProcesses(): void;
  17665. /**
  17666. * Disposes the ShadowGenerator.
  17667. * Returns nothing.
  17668. */
  17669. dispose(): void;
  17670. /**
  17671. * Serializes the shadow generator setup to a json object.
  17672. * @returns The serialized JSON object
  17673. */
  17674. serialize(): any;
  17675. /**
  17676. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17677. * @param parsedShadowGenerator The JSON object to parse
  17678. * @param scene The scene to create the shadow map for
  17679. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17680. * @returns The parsed shadow generator
  17681. */
  17682. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17683. }
  17684. }
  17685. declare module BABYLON {
  17686. /**
  17687. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17688. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17689. * 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.
  17690. */
  17691. export abstract class Light extends Node {
  17692. /**
  17693. * Falloff Default: light is falling off following the material specification:
  17694. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17695. */
  17696. static readonly FALLOFF_DEFAULT: number;
  17697. /**
  17698. * Falloff Physical: light is falling off following the inverse squared distance law.
  17699. */
  17700. static readonly FALLOFF_PHYSICAL: number;
  17701. /**
  17702. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17703. * to enhance interoperability with other engines.
  17704. */
  17705. static readonly FALLOFF_GLTF: number;
  17706. /**
  17707. * Falloff Standard: light is falling off like in the standard material
  17708. * to enhance interoperability with other materials.
  17709. */
  17710. static readonly FALLOFF_STANDARD: number;
  17711. /**
  17712. * If every light affecting the material is in this lightmapMode,
  17713. * material.lightmapTexture adds or multiplies
  17714. * (depends on material.useLightmapAsShadowmap)
  17715. * after every other light calculations.
  17716. */
  17717. static readonly LIGHTMAP_DEFAULT: number;
  17718. /**
  17719. * material.lightmapTexture as only diffuse lighting from this light
  17720. * adds only specular lighting from this light
  17721. * adds dynamic shadows
  17722. */
  17723. static readonly LIGHTMAP_SPECULAR: number;
  17724. /**
  17725. * material.lightmapTexture as only lighting
  17726. * no light calculation from this light
  17727. * only adds dynamic shadows from this light
  17728. */
  17729. static readonly LIGHTMAP_SHADOWSONLY: number;
  17730. /**
  17731. * Each light type uses the default quantity according to its type:
  17732. * point/spot lights use luminous intensity
  17733. * directional lights use illuminance
  17734. */
  17735. static readonly INTENSITYMODE_AUTOMATIC: number;
  17736. /**
  17737. * lumen (lm)
  17738. */
  17739. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17740. /**
  17741. * candela (lm/sr)
  17742. */
  17743. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17744. /**
  17745. * lux (lm/m^2)
  17746. */
  17747. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17748. /**
  17749. * nit (cd/m^2)
  17750. */
  17751. static readonly INTENSITYMODE_LUMINANCE: number;
  17752. /**
  17753. * Light type const id of the point light.
  17754. */
  17755. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17756. /**
  17757. * Light type const id of the directional light.
  17758. */
  17759. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17760. /**
  17761. * Light type const id of the spot light.
  17762. */
  17763. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17764. /**
  17765. * Light type const id of the hemispheric light.
  17766. */
  17767. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17768. /**
  17769. * Diffuse gives the basic color to an object.
  17770. */
  17771. diffuse: Color3;
  17772. /**
  17773. * Specular produces a highlight color on an object.
  17774. * Note: This is note affecting PBR materials.
  17775. */
  17776. specular: Color3;
  17777. /**
  17778. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17779. * falling off base on range or angle.
  17780. * This can be set to any values in Light.FALLOFF_x.
  17781. *
  17782. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17783. * other types of materials.
  17784. */
  17785. falloffType: number;
  17786. /**
  17787. * Strength of the light.
  17788. * Note: By default it is define in the framework own unit.
  17789. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17790. */
  17791. intensity: number;
  17792. private _range;
  17793. protected _inverseSquaredRange: number;
  17794. /**
  17795. * Defines how far from the source the light is impacting in scene units.
  17796. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17797. */
  17798. get range(): number;
  17799. /**
  17800. * Defines how far from the source the light is impacting in scene units.
  17801. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17802. */
  17803. set range(value: number);
  17804. /**
  17805. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17806. * of light.
  17807. */
  17808. private _photometricScale;
  17809. private _intensityMode;
  17810. /**
  17811. * Gets the photometric scale used to interpret the intensity.
  17812. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17813. */
  17814. get intensityMode(): number;
  17815. /**
  17816. * Sets the photometric scale used to interpret the intensity.
  17817. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17818. */
  17819. set intensityMode(value: number);
  17820. private _radius;
  17821. /**
  17822. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17823. */
  17824. get radius(): number;
  17825. /**
  17826. * sets the light radius used by PBR Materials to simulate soft area lights.
  17827. */
  17828. set radius(value: number);
  17829. private _renderPriority;
  17830. /**
  17831. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17832. * exceeding the number allowed of the materials.
  17833. */
  17834. renderPriority: number;
  17835. private _shadowEnabled;
  17836. /**
  17837. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17838. * the current shadow generator.
  17839. */
  17840. get shadowEnabled(): boolean;
  17841. /**
  17842. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17843. * the current shadow generator.
  17844. */
  17845. set shadowEnabled(value: boolean);
  17846. private _includedOnlyMeshes;
  17847. /**
  17848. * Gets the only meshes impacted by this light.
  17849. */
  17850. get includedOnlyMeshes(): AbstractMesh[];
  17851. /**
  17852. * Sets the only meshes impacted by this light.
  17853. */
  17854. set includedOnlyMeshes(value: AbstractMesh[]);
  17855. private _excludedMeshes;
  17856. /**
  17857. * Gets the meshes not impacted by this light.
  17858. */
  17859. get excludedMeshes(): AbstractMesh[];
  17860. /**
  17861. * Sets the meshes not impacted by this light.
  17862. */
  17863. set excludedMeshes(value: AbstractMesh[]);
  17864. private _excludeWithLayerMask;
  17865. /**
  17866. * Gets the layer id use to find what meshes are not impacted by the light.
  17867. * Inactive if 0
  17868. */
  17869. get excludeWithLayerMask(): number;
  17870. /**
  17871. * Sets the layer id use to find what meshes are not impacted by the light.
  17872. * Inactive if 0
  17873. */
  17874. set excludeWithLayerMask(value: number);
  17875. private _includeOnlyWithLayerMask;
  17876. /**
  17877. * Gets the layer id use to find what meshes are impacted by the light.
  17878. * Inactive if 0
  17879. */
  17880. get includeOnlyWithLayerMask(): number;
  17881. /**
  17882. * Sets the layer id use to find what meshes are impacted by the light.
  17883. * Inactive if 0
  17884. */
  17885. set includeOnlyWithLayerMask(value: number);
  17886. private _lightmapMode;
  17887. /**
  17888. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17889. */
  17890. get lightmapMode(): number;
  17891. /**
  17892. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17893. */
  17894. set lightmapMode(value: number);
  17895. /**
  17896. * Shadow generator associted to the light.
  17897. * @hidden Internal use only.
  17898. */
  17899. _shadowGenerator: Nullable<IShadowGenerator>;
  17900. /**
  17901. * @hidden Internal use only.
  17902. */
  17903. _excludedMeshesIds: string[];
  17904. /**
  17905. * @hidden Internal use only.
  17906. */
  17907. _includedOnlyMeshesIds: string[];
  17908. /**
  17909. * The current light unifom buffer.
  17910. * @hidden Internal use only.
  17911. */
  17912. _uniformBuffer: UniformBuffer;
  17913. /** @hidden */
  17914. _renderId: number;
  17915. /**
  17916. * Creates a Light object in the scene.
  17917. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17918. * @param name The firendly name of the light
  17919. * @param scene The scene the light belongs too
  17920. */
  17921. constructor(name: string, scene: Scene);
  17922. protected abstract _buildUniformLayout(): void;
  17923. /**
  17924. * Sets the passed Effect "effect" with the Light information.
  17925. * @param effect The effect to update
  17926. * @param lightIndex The index of the light in the effect to update
  17927. * @returns The light
  17928. */
  17929. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17930. /**
  17931. * Sets the passed Effect "effect" with the Light textures.
  17932. * @param effect The effect to update
  17933. * @param lightIndex The index of the light in the effect to update
  17934. * @returns The light
  17935. */
  17936. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17937. /**
  17938. * Binds the lights information from the scene to the effect for the given mesh.
  17939. * @param lightIndex Light index
  17940. * @param scene The scene where the light belongs to
  17941. * @param effect The effect we are binding the data to
  17942. * @param useSpecular Defines if specular is supported
  17943. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17944. */
  17945. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17946. /**
  17947. * Sets the passed Effect "effect" with the Light information.
  17948. * @param effect The effect to update
  17949. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17950. * @returns The light
  17951. */
  17952. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17953. /**
  17954. * Returns the string "Light".
  17955. * @returns the class name
  17956. */
  17957. getClassName(): string;
  17958. /** @hidden */
  17959. readonly _isLight: boolean;
  17960. /**
  17961. * Converts the light information to a readable string for debug purpose.
  17962. * @param fullDetails Supports for multiple levels of logging within scene loading
  17963. * @returns the human readable light info
  17964. */
  17965. toString(fullDetails?: boolean): string;
  17966. /** @hidden */
  17967. protected _syncParentEnabledState(): void;
  17968. /**
  17969. * Set the enabled state of this node.
  17970. * @param value - the new enabled state
  17971. */
  17972. setEnabled(value: boolean): void;
  17973. /**
  17974. * Returns the Light associated shadow generator if any.
  17975. * @return the associated shadow generator.
  17976. */
  17977. getShadowGenerator(): Nullable<IShadowGenerator>;
  17978. /**
  17979. * Returns a Vector3, the absolute light position in the World.
  17980. * @returns the world space position of the light
  17981. */
  17982. getAbsolutePosition(): Vector3;
  17983. /**
  17984. * Specifies if the light will affect the passed mesh.
  17985. * @param mesh The mesh to test against the light
  17986. * @return true the mesh is affected otherwise, false.
  17987. */
  17988. canAffectMesh(mesh: AbstractMesh): boolean;
  17989. /**
  17990. * Sort function to order lights for rendering.
  17991. * @param a First Light object to compare to second.
  17992. * @param b Second Light object to compare first.
  17993. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17994. */
  17995. static CompareLightsPriority(a: Light, b: Light): number;
  17996. /**
  17997. * Releases resources associated with this node.
  17998. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17999. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18000. */
  18001. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18002. /**
  18003. * Returns the light type ID (integer).
  18004. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18005. */
  18006. getTypeID(): number;
  18007. /**
  18008. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18009. * @returns the scaled intensity in intensity mode unit
  18010. */
  18011. getScaledIntensity(): number;
  18012. /**
  18013. * Returns a new Light object, named "name", from the current one.
  18014. * @param name The name of the cloned light
  18015. * @param newParent The parent of this light, if it has one
  18016. * @returns the new created light
  18017. */
  18018. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18019. /**
  18020. * Serializes the current light into a Serialization object.
  18021. * @returns the serialized object.
  18022. */
  18023. serialize(): any;
  18024. /**
  18025. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18026. * This new light is named "name" and added to the passed scene.
  18027. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18028. * @param name The friendly name of the light
  18029. * @param scene The scene the new light will belong to
  18030. * @returns the constructor function
  18031. */
  18032. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18033. /**
  18034. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18035. * @param parsedLight The JSON representation of the light
  18036. * @param scene The scene to create the parsed light in
  18037. * @returns the created light after parsing
  18038. */
  18039. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18040. private _hookArrayForExcluded;
  18041. private _hookArrayForIncludedOnly;
  18042. private _resyncMeshes;
  18043. /**
  18044. * Forces the meshes to update their light related information in their rendering used effects
  18045. * @hidden Internal Use Only
  18046. */
  18047. _markMeshesAsLightDirty(): void;
  18048. /**
  18049. * Recomputes the cached photometric scale if needed.
  18050. */
  18051. private _computePhotometricScale;
  18052. /**
  18053. * Returns the Photometric Scale according to the light type and intensity mode.
  18054. */
  18055. private _getPhotometricScale;
  18056. /**
  18057. * Reorder the light in the scene according to their defined priority.
  18058. * @hidden Internal Use Only
  18059. */
  18060. _reorderLightsInScene(): void;
  18061. /**
  18062. * Prepares the list of defines specific to the light type.
  18063. * @param defines the list of defines
  18064. * @param lightIndex defines the index of the light for the effect
  18065. */
  18066. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18067. }
  18068. }
  18069. declare module BABYLON {
  18070. /**
  18071. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18072. * This is the base of the follow, arc rotate cameras and Free camera
  18073. * @see http://doc.babylonjs.com/features/cameras
  18074. */
  18075. export class TargetCamera extends Camera {
  18076. private static _RigCamTransformMatrix;
  18077. private static _TargetTransformMatrix;
  18078. private static _TargetFocalPoint;
  18079. private _tmpUpVector;
  18080. private _tmpTargetVector;
  18081. /**
  18082. * Define the current direction the camera is moving to
  18083. */
  18084. cameraDirection: Vector3;
  18085. /**
  18086. * Define the current rotation the camera is rotating to
  18087. */
  18088. cameraRotation: Vector2;
  18089. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18090. ignoreParentScaling: boolean;
  18091. /**
  18092. * When set, the up vector of the camera will be updated by the rotation of the camera
  18093. */
  18094. updateUpVectorFromRotation: boolean;
  18095. private _tmpQuaternion;
  18096. /**
  18097. * Define the current rotation of the camera
  18098. */
  18099. rotation: Vector3;
  18100. /**
  18101. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18102. */
  18103. rotationQuaternion: Quaternion;
  18104. /**
  18105. * Define the current speed of the camera
  18106. */
  18107. speed: number;
  18108. /**
  18109. * Add constraint to the camera to prevent it to move freely in all directions and
  18110. * around all axis.
  18111. */
  18112. noRotationConstraint: boolean;
  18113. /**
  18114. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18115. * panning
  18116. */
  18117. invertRotation: boolean;
  18118. /**
  18119. * Speed multiplier for inverse camera panning
  18120. */
  18121. inverseRotationSpeed: number;
  18122. /**
  18123. * Define the current target of the camera as an object or a position.
  18124. */
  18125. lockedTarget: any;
  18126. /** @hidden */
  18127. _currentTarget: Vector3;
  18128. /** @hidden */
  18129. _initialFocalDistance: number;
  18130. /** @hidden */
  18131. _viewMatrix: Matrix;
  18132. /** @hidden */
  18133. _camMatrix: Matrix;
  18134. /** @hidden */
  18135. _cameraTransformMatrix: Matrix;
  18136. /** @hidden */
  18137. _cameraRotationMatrix: Matrix;
  18138. /** @hidden */
  18139. _referencePoint: Vector3;
  18140. /** @hidden */
  18141. _transformedReferencePoint: Vector3;
  18142. /** @hidden */
  18143. _reset: () => void;
  18144. private _defaultUp;
  18145. /**
  18146. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18147. * This is the base of the follow, arc rotate cameras and Free camera
  18148. * @see http://doc.babylonjs.com/features/cameras
  18149. * @param name Defines the name of the camera in the scene
  18150. * @param position Defines the start position of the camera in the scene
  18151. * @param scene Defines the scene the camera belongs to
  18152. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18153. */
  18154. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18155. /**
  18156. * Gets the position in front of the camera at a given distance.
  18157. * @param distance The distance from the camera we want the position to be
  18158. * @returns the position
  18159. */
  18160. getFrontPosition(distance: number): Vector3;
  18161. /** @hidden */
  18162. _getLockedTargetPosition(): Nullable<Vector3>;
  18163. private _storedPosition;
  18164. private _storedRotation;
  18165. private _storedRotationQuaternion;
  18166. /**
  18167. * Store current camera state of the camera (fov, position, rotation, etc..)
  18168. * @returns the camera
  18169. */
  18170. storeState(): Camera;
  18171. /**
  18172. * Restored camera state. You must call storeState() first
  18173. * @returns whether it was successful or not
  18174. * @hidden
  18175. */
  18176. _restoreStateValues(): boolean;
  18177. /** @hidden */
  18178. _initCache(): void;
  18179. /** @hidden */
  18180. _updateCache(ignoreParentClass?: boolean): void;
  18181. /** @hidden */
  18182. _isSynchronizedViewMatrix(): boolean;
  18183. /** @hidden */
  18184. _computeLocalCameraSpeed(): number;
  18185. /**
  18186. * Defines the target the camera should look at.
  18187. * @param target Defines the new target as a Vector or a mesh
  18188. */
  18189. setTarget(target: Vector3): void;
  18190. /**
  18191. * Return the current target position of the camera. This value is expressed in local space.
  18192. * @returns the target position
  18193. */
  18194. getTarget(): Vector3;
  18195. /** @hidden */
  18196. _decideIfNeedsToMove(): boolean;
  18197. /** @hidden */
  18198. _updatePosition(): void;
  18199. /** @hidden */
  18200. _checkInputs(): void;
  18201. protected _updateCameraRotationMatrix(): void;
  18202. /**
  18203. * 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)
  18204. * @returns the current camera
  18205. */
  18206. private _rotateUpVectorWithCameraRotationMatrix;
  18207. private _cachedRotationZ;
  18208. private _cachedQuaternionRotationZ;
  18209. /** @hidden */
  18210. _getViewMatrix(): Matrix;
  18211. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18212. /**
  18213. * @hidden
  18214. */
  18215. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18216. /**
  18217. * @hidden
  18218. */
  18219. _updateRigCameras(): void;
  18220. private _getRigCamPositionAndTarget;
  18221. /**
  18222. * Gets the current object class name.
  18223. * @return the class name
  18224. */
  18225. getClassName(): string;
  18226. }
  18227. }
  18228. declare module BABYLON {
  18229. /**
  18230. * Gather the list of keyboard event types as constants.
  18231. */
  18232. export class KeyboardEventTypes {
  18233. /**
  18234. * The keydown event is fired when a key becomes active (pressed).
  18235. */
  18236. static readonly KEYDOWN: number;
  18237. /**
  18238. * The keyup event is fired when a key has been released.
  18239. */
  18240. static readonly KEYUP: number;
  18241. }
  18242. /**
  18243. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18244. */
  18245. export class KeyboardInfo {
  18246. /**
  18247. * Defines the type of event (KeyboardEventTypes)
  18248. */
  18249. type: number;
  18250. /**
  18251. * Defines the related dom event
  18252. */
  18253. event: KeyboardEvent;
  18254. /**
  18255. * Instantiates a new keyboard info.
  18256. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18257. * @param type Defines the type of event (KeyboardEventTypes)
  18258. * @param event Defines the related dom event
  18259. */
  18260. constructor(
  18261. /**
  18262. * Defines the type of event (KeyboardEventTypes)
  18263. */
  18264. type: number,
  18265. /**
  18266. * Defines the related dom event
  18267. */
  18268. event: KeyboardEvent);
  18269. }
  18270. /**
  18271. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18272. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18273. */
  18274. export class KeyboardInfoPre extends KeyboardInfo {
  18275. /**
  18276. * Defines the type of event (KeyboardEventTypes)
  18277. */
  18278. type: number;
  18279. /**
  18280. * Defines the related dom event
  18281. */
  18282. event: KeyboardEvent;
  18283. /**
  18284. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18285. */
  18286. skipOnPointerObservable: boolean;
  18287. /**
  18288. * Instantiates a new keyboard pre info.
  18289. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18290. * @param type Defines the type of event (KeyboardEventTypes)
  18291. * @param event Defines the related dom event
  18292. */
  18293. constructor(
  18294. /**
  18295. * Defines the type of event (KeyboardEventTypes)
  18296. */
  18297. type: number,
  18298. /**
  18299. * Defines the related dom event
  18300. */
  18301. event: KeyboardEvent);
  18302. }
  18303. }
  18304. declare module BABYLON {
  18305. /**
  18306. * Manage the keyboard inputs to control the movement of a free camera.
  18307. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18308. */
  18309. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18310. /**
  18311. * Defines the camera the input is attached to.
  18312. */
  18313. camera: FreeCamera;
  18314. /**
  18315. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18316. */
  18317. keysUp: number[];
  18318. /**
  18319. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18320. */
  18321. keysUpward: number[];
  18322. /**
  18323. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18324. */
  18325. keysDown: number[];
  18326. /**
  18327. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18328. */
  18329. keysDownward: number[];
  18330. /**
  18331. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18332. */
  18333. keysLeft: number[];
  18334. /**
  18335. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18336. */
  18337. keysRight: number[];
  18338. private _keys;
  18339. private _onCanvasBlurObserver;
  18340. private _onKeyboardObserver;
  18341. private _engine;
  18342. private _scene;
  18343. /**
  18344. * Attach the input controls to a specific dom element to get the input from.
  18345. * @param element Defines the element the controls should be listened from
  18346. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18347. */
  18348. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18349. /**
  18350. * Detach the current controls from the specified dom element.
  18351. * @param element Defines the element to stop listening the inputs from
  18352. */
  18353. detachControl(element: Nullable<HTMLElement>): void;
  18354. /**
  18355. * Update the current camera state depending on the inputs that have been used this frame.
  18356. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18357. */
  18358. checkInputs(): void;
  18359. /**
  18360. * Gets the class name of the current intput.
  18361. * @returns the class name
  18362. */
  18363. getClassName(): string;
  18364. /** @hidden */
  18365. _onLostFocus(): void;
  18366. /**
  18367. * Get the friendly name associated with the input class.
  18368. * @returns the input friendly name
  18369. */
  18370. getSimpleName(): string;
  18371. }
  18372. }
  18373. declare module BABYLON {
  18374. /**
  18375. * Gather the list of pointer event types as constants.
  18376. */
  18377. export class PointerEventTypes {
  18378. /**
  18379. * 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.
  18380. */
  18381. static readonly POINTERDOWN: number;
  18382. /**
  18383. * The pointerup event is fired when a pointer is no longer active.
  18384. */
  18385. static readonly POINTERUP: number;
  18386. /**
  18387. * The pointermove event is fired when a pointer changes coordinates.
  18388. */
  18389. static readonly POINTERMOVE: number;
  18390. /**
  18391. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18392. */
  18393. static readonly POINTERWHEEL: number;
  18394. /**
  18395. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18396. */
  18397. static readonly POINTERPICK: number;
  18398. /**
  18399. * The pointertap event is fired when a the object has been touched and released without drag.
  18400. */
  18401. static readonly POINTERTAP: number;
  18402. /**
  18403. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18404. */
  18405. static readonly POINTERDOUBLETAP: number;
  18406. }
  18407. /**
  18408. * Base class of pointer info types.
  18409. */
  18410. export class PointerInfoBase {
  18411. /**
  18412. * Defines the type of event (PointerEventTypes)
  18413. */
  18414. type: number;
  18415. /**
  18416. * Defines the related dom event
  18417. */
  18418. event: PointerEvent | MouseWheelEvent;
  18419. /**
  18420. * Instantiates the base class of pointers info.
  18421. * @param type Defines the type of event (PointerEventTypes)
  18422. * @param event Defines the related dom event
  18423. */
  18424. constructor(
  18425. /**
  18426. * Defines the type of event (PointerEventTypes)
  18427. */
  18428. type: number,
  18429. /**
  18430. * Defines the related dom event
  18431. */
  18432. event: PointerEvent | MouseWheelEvent);
  18433. }
  18434. /**
  18435. * This class is used to store pointer related info for the onPrePointerObservable event.
  18436. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18437. */
  18438. export class PointerInfoPre extends PointerInfoBase {
  18439. /**
  18440. * Ray from a pointer if availible (eg. 6dof controller)
  18441. */
  18442. ray: Nullable<Ray>;
  18443. /**
  18444. * Defines the local position of the pointer on the canvas.
  18445. */
  18446. localPosition: Vector2;
  18447. /**
  18448. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18449. */
  18450. skipOnPointerObservable: boolean;
  18451. /**
  18452. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18453. * @param type Defines the type of event (PointerEventTypes)
  18454. * @param event Defines the related dom event
  18455. * @param localX Defines the local x coordinates of the pointer when the event occured
  18456. * @param localY Defines the local y coordinates of the pointer when the event occured
  18457. */
  18458. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18459. }
  18460. /**
  18461. * This type contains all the data related to a pointer event in Babylon.js.
  18462. * 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.
  18463. */
  18464. export class PointerInfo extends PointerInfoBase {
  18465. /**
  18466. * Defines the picking info associated to the info (if any)\
  18467. */
  18468. pickInfo: Nullable<PickingInfo>;
  18469. /**
  18470. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18471. * @param type Defines the type of event (PointerEventTypes)
  18472. * @param event Defines the related dom event
  18473. * @param pickInfo Defines the picking info associated to the info (if any)\
  18474. */
  18475. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18476. /**
  18477. * Defines the picking info associated to the info (if any)\
  18478. */
  18479. pickInfo: Nullable<PickingInfo>);
  18480. }
  18481. /**
  18482. * Data relating to a touch event on the screen.
  18483. */
  18484. export interface PointerTouch {
  18485. /**
  18486. * X coordinate of touch.
  18487. */
  18488. x: number;
  18489. /**
  18490. * Y coordinate of touch.
  18491. */
  18492. y: number;
  18493. /**
  18494. * Id of touch. Unique for each finger.
  18495. */
  18496. pointerId: number;
  18497. /**
  18498. * Event type passed from DOM.
  18499. */
  18500. type: any;
  18501. }
  18502. }
  18503. declare module BABYLON {
  18504. /**
  18505. * Manage the mouse inputs to control the movement of a free camera.
  18506. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18507. */
  18508. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18509. /**
  18510. * Define if touch is enabled in the mouse input
  18511. */
  18512. touchEnabled: boolean;
  18513. /**
  18514. * Defines the camera the input is attached to.
  18515. */
  18516. camera: FreeCamera;
  18517. /**
  18518. * Defines the buttons associated with the input to handle camera move.
  18519. */
  18520. buttons: number[];
  18521. /**
  18522. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18523. */
  18524. angularSensibility: number;
  18525. private _pointerInput;
  18526. private _onMouseMove;
  18527. private _observer;
  18528. private previousPosition;
  18529. /**
  18530. * Observable for when a pointer move event occurs containing the move offset
  18531. */
  18532. onPointerMovedObservable: Observable<{
  18533. offsetX: number;
  18534. offsetY: number;
  18535. }>;
  18536. /**
  18537. * @hidden
  18538. * If the camera should be rotated automatically based on pointer movement
  18539. */
  18540. _allowCameraRotation: boolean;
  18541. /**
  18542. * Manage the mouse inputs to control the movement of a free camera.
  18543. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18544. * @param touchEnabled Defines if touch is enabled or not
  18545. */
  18546. constructor(
  18547. /**
  18548. * Define if touch is enabled in the mouse input
  18549. */
  18550. touchEnabled?: boolean);
  18551. /**
  18552. * Attach the input controls to a specific dom element to get the input from.
  18553. * @param element Defines the element the controls should be listened from
  18554. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18555. */
  18556. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18557. /**
  18558. * Called on JS contextmenu event.
  18559. * Override this method to provide functionality.
  18560. */
  18561. protected onContextMenu(evt: PointerEvent): void;
  18562. /**
  18563. * Detach the current controls from the specified dom element.
  18564. * @param element Defines the element to stop listening the inputs from
  18565. */
  18566. detachControl(element: Nullable<HTMLElement>): void;
  18567. /**
  18568. * Gets the class name of the current intput.
  18569. * @returns the class name
  18570. */
  18571. getClassName(): string;
  18572. /**
  18573. * Get the friendly name associated with the input class.
  18574. * @returns the input friendly name
  18575. */
  18576. getSimpleName(): string;
  18577. }
  18578. }
  18579. declare module BABYLON {
  18580. /**
  18581. * Manage the touch inputs to control the movement of a free camera.
  18582. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18583. */
  18584. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18585. /**
  18586. * Defines the camera the input is attached to.
  18587. */
  18588. camera: FreeCamera;
  18589. /**
  18590. * Defines the touch sensibility for rotation.
  18591. * The higher the faster.
  18592. */
  18593. touchAngularSensibility: number;
  18594. /**
  18595. * Defines the touch sensibility for move.
  18596. * The higher the faster.
  18597. */
  18598. touchMoveSensibility: number;
  18599. private _offsetX;
  18600. private _offsetY;
  18601. private _pointerPressed;
  18602. private _pointerInput;
  18603. private _observer;
  18604. private _onLostFocus;
  18605. /**
  18606. * Attach the input controls to a specific dom element to get the input from.
  18607. * @param element Defines the element the controls should be listened from
  18608. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18609. */
  18610. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18611. /**
  18612. * Detach the current controls from the specified dom element.
  18613. * @param element Defines the element to stop listening the inputs from
  18614. */
  18615. detachControl(element: Nullable<HTMLElement>): void;
  18616. /**
  18617. * Update the current camera state depending on the inputs that have been used this frame.
  18618. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18619. */
  18620. checkInputs(): void;
  18621. /**
  18622. * Gets the class name of the current intput.
  18623. * @returns the class name
  18624. */
  18625. getClassName(): string;
  18626. /**
  18627. * Get the friendly name associated with the input class.
  18628. * @returns the input friendly name
  18629. */
  18630. getSimpleName(): string;
  18631. }
  18632. }
  18633. declare module BABYLON {
  18634. /**
  18635. * Default Inputs manager for the FreeCamera.
  18636. * It groups all the default supported inputs for ease of use.
  18637. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18638. */
  18639. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18640. /**
  18641. * @hidden
  18642. */
  18643. _mouseInput: Nullable<FreeCameraMouseInput>;
  18644. /**
  18645. * Instantiates a new FreeCameraInputsManager.
  18646. * @param camera Defines the camera the inputs belong to
  18647. */
  18648. constructor(camera: FreeCamera);
  18649. /**
  18650. * Add keyboard input support to the input manager.
  18651. * @returns the current input manager
  18652. */
  18653. addKeyboard(): FreeCameraInputsManager;
  18654. /**
  18655. * Add mouse input support to the input manager.
  18656. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18657. * @returns the current input manager
  18658. */
  18659. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18660. /**
  18661. * Removes the mouse input support from the manager
  18662. * @returns the current input manager
  18663. */
  18664. removeMouse(): FreeCameraInputsManager;
  18665. /**
  18666. * Add touch input support to the input manager.
  18667. * @returns the current input manager
  18668. */
  18669. addTouch(): FreeCameraInputsManager;
  18670. /**
  18671. * Remove all attached input methods from a camera
  18672. */
  18673. clear(): void;
  18674. }
  18675. }
  18676. declare module BABYLON {
  18677. /**
  18678. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18679. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18680. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18681. */
  18682. export class FreeCamera extends TargetCamera {
  18683. /**
  18684. * Define the collision ellipsoid of the camera.
  18685. * This is helpful to simulate a camera body like the player body around the camera
  18686. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18687. */
  18688. ellipsoid: Vector3;
  18689. /**
  18690. * Define an offset for the position of the ellipsoid around the camera.
  18691. * This can be helpful to determine the center of the body near the gravity center of the body
  18692. * instead of its head.
  18693. */
  18694. ellipsoidOffset: Vector3;
  18695. /**
  18696. * Enable or disable collisions of the camera with the rest of the scene objects.
  18697. */
  18698. checkCollisions: boolean;
  18699. /**
  18700. * Enable or disable gravity on the camera.
  18701. */
  18702. applyGravity: boolean;
  18703. /**
  18704. * Define the input manager associated to the camera.
  18705. */
  18706. inputs: FreeCameraInputsManager;
  18707. /**
  18708. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18709. * Higher values reduce sensitivity.
  18710. */
  18711. get angularSensibility(): number;
  18712. /**
  18713. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18714. * Higher values reduce sensitivity.
  18715. */
  18716. set angularSensibility(value: number);
  18717. /**
  18718. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18719. */
  18720. get keysUp(): number[];
  18721. set keysUp(value: number[]);
  18722. /**
  18723. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18724. */
  18725. get keysUpward(): number[];
  18726. set keysUpward(value: number[]);
  18727. /**
  18728. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18729. */
  18730. get keysDown(): number[];
  18731. set keysDown(value: number[]);
  18732. /**
  18733. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18734. */
  18735. get keysDownward(): number[];
  18736. set keysDownward(value: number[]);
  18737. /**
  18738. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18739. */
  18740. get keysLeft(): number[];
  18741. set keysLeft(value: number[]);
  18742. /**
  18743. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18744. */
  18745. get keysRight(): number[];
  18746. set keysRight(value: number[]);
  18747. /**
  18748. * Event raised when the camera collide with a mesh in the scene.
  18749. */
  18750. onCollide: (collidedMesh: AbstractMesh) => void;
  18751. private _collider;
  18752. private _needMoveForGravity;
  18753. private _oldPosition;
  18754. private _diffPosition;
  18755. private _newPosition;
  18756. /** @hidden */
  18757. _localDirection: Vector3;
  18758. /** @hidden */
  18759. _transformedDirection: Vector3;
  18760. /**
  18761. * Instantiates a Free Camera.
  18762. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18763. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18764. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18765. * @param name Define the name of the camera in the scene
  18766. * @param position Define the start position of the camera in the scene
  18767. * @param scene Define the scene the camera belongs to
  18768. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18769. */
  18770. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18771. /**
  18772. * Attached controls to the current camera.
  18773. * @param element Defines the element the controls should be listened from
  18774. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18775. */
  18776. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18777. /**
  18778. * Detach the current controls from the camera.
  18779. * The camera will stop reacting to inputs.
  18780. * @param element Defines the element to stop listening the inputs from
  18781. */
  18782. detachControl(element: HTMLElement): void;
  18783. private _collisionMask;
  18784. /**
  18785. * Define a collision mask to limit the list of object the camera can collide with
  18786. */
  18787. get collisionMask(): number;
  18788. set collisionMask(mask: number);
  18789. /** @hidden */
  18790. _collideWithWorld(displacement: Vector3): void;
  18791. private _onCollisionPositionChange;
  18792. /** @hidden */
  18793. _checkInputs(): void;
  18794. /** @hidden */
  18795. _decideIfNeedsToMove(): boolean;
  18796. /** @hidden */
  18797. _updatePosition(): void;
  18798. /**
  18799. * Destroy the camera and release the current resources hold by it.
  18800. */
  18801. dispose(): void;
  18802. /**
  18803. * Gets the current object class name.
  18804. * @return the class name
  18805. */
  18806. getClassName(): string;
  18807. }
  18808. }
  18809. declare module BABYLON {
  18810. /**
  18811. * Represents a gamepad control stick position
  18812. */
  18813. export class StickValues {
  18814. /**
  18815. * The x component of the control stick
  18816. */
  18817. x: number;
  18818. /**
  18819. * The y component of the control stick
  18820. */
  18821. y: number;
  18822. /**
  18823. * Initializes the gamepad x and y control stick values
  18824. * @param x The x component of the gamepad control stick value
  18825. * @param y The y component of the gamepad control stick value
  18826. */
  18827. constructor(
  18828. /**
  18829. * The x component of the control stick
  18830. */
  18831. x: number,
  18832. /**
  18833. * The y component of the control stick
  18834. */
  18835. y: number);
  18836. }
  18837. /**
  18838. * An interface which manages callbacks for gamepad button changes
  18839. */
  18840. export interface GamepadButtonChanges {
  18841. /**
  18842. * Called when a gamepad has been changed
  18843. */
  18844. changed: boolean;
  18845. /**
  18846. * Called when a gamepad press event has been triggered
  18847. */
  18848. pressChanged: boolean;
  18849. /**
  18850. * Called when a touch event has been triggered
  18851. */
  18852. touchChanged: boolean;
  18853. /**
  18854. * Called when a value has changed
  18855. */
  18856. valueChanged: boolean;
  18857. }
  18858. /**
  18859. * Represents a gamepad
  18860. */
  18861. export class Gamepad {
  18862. /**
  18863. * The id of the gamepad
  18864. */
  18865. id: string;
  18866. /**
  18867. * The index of the gamepad
  18868. */
  18869. index: number;
  18870. /**
  18871. * The browser gamepad
  18872. */
  18873. browserGamepad: any;
  18874. /**
  18875. * Specifies what type of gamepad this represents
  18876. */
  18877. type: number;
  18878. private _leftStick;
  18879. private _rightStick;
  18880. /** @hidden */
  18881. _isConnected: boolean;
  18882. private _leftStickAxisX;
  18883. private _leftStickAxisY;
  18884. private _rightStickAxisX;
  18885. private _rightStickAxisY;
  18886. /**
  18887. * Triggered when the left control stick has been changed
  18888. */
  18889. private _onleftstickchanged;
  18890. /**
  18891. * Triggered when the right control stick has been changed
  18892. */
  18893. private _onrightstickchanged;
  18894. /**
  18895. * Represents a gamepad controller
  18896. */
  18897. static GAMEPAD: number;
  18898. /**
  18899. * Represents a generic controller
  18900. */
  18901. static GENERIC: number;
  18902. /**
  18903. * Represents an XBox controller
  18904. */
  18905. static XBOX: number;
  18906. /**
  18907. * Represents a pose-enabled controller
  18908. */
  18909. static POSE_ENABLED: number;
  18910. /**
  18911. * Represents an Dual Shock controller
  18912. */
  18913. static DUALSHOCK: number;
  18914. /**
  18915. * Specifies whether the left control stick should be Y-inverted
  18916. */
  18917. protected _invertLeftStickY: boolean;
  18918. /**
  18919. * Specifies if the gamepad has been connected
  18920. */
  18921. get isConnected(): boolean;
  18922. /**
  18923. * Initializes the gamepad
  18924. * @param id The id of the gamepad
  18925. * @param index The index of the gamepad
  18926. * @param browserGamepad The browser gamepad
  18927. * @param leftStickX The x component of the left joystick
  18928. * @param leftStickY The y component of the left joystick
  18929. * @param rightStickX The x component of the right joystick
  18930. * @param rightStickY The y component of the right joystick
  18931. */
  18932. constructor(
  18933. /**
  18934. * The id of the gamepad
  18935. */
  18936. id: string,
  18937. /**
  18938. * The index of the gamepad
  18939. */
  18940. index: number,
  18941. /**
  18942. * The browser gamepad
  18943. */
  18944. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  18945. /**
  18946. * Callback triggered when the left joystick has changed
  18947. * @param callback
  18948. */
  18949. onleftstickchanged(callback: (values: StickValues) => void): void;
  18950. /**
  18951. * Callback triggered when the right joystick has changed
  18952. * @param callback
  18953. */
  18954. onrightstickchanged(callback: (values: StickValues) => void): void;
  18955. /**
  18956. * Gets the left joystick
  18957. */
  18958. get leftStick(): StickValues;
  18959. /**
  18960. * Sets the left joystick values
  18961. */
  18962. set leftStick(newValues: StickValues);
  18963. /**
  18964. * Gets the right joystick
  18965. */
  18966. get rightStick(): StickValues;
  18967. /**
  18968. * Sets the right joystick value
  18969. */
  18970. set rightStick(newValues: StickValues);
  18971. /**
  18972. * Updates the gamepad joystick positions
  18973. */
  18974. update(): void;
  18975. /**
  18976. * Disposes the gamepad
  18977. */
  18978. dispose(): void;
  18979. }
  18980. /**
  18981. * Represents a generic gamepad
  18982. */
  18983. export class GenericPad extends Gamepad {
  18984. private _buttons;
  18985. private _onbuttondown;
  18986. private _onbuttonup;
  18987. /**
  18988. * Observable triggered when a button has been pressed
  18989. */
  18990. onButtonDownObservable: Observable<number>;
  18991. /**
  18992. * Observable triggered when a button has been released
  18993. */
  18994. onButtonUpObservable: Observable<number>;
  18995. /**
  18996. * Callback triggered when a button has been pressed
  18997. * @param callback Called when a button has been pressed
  18998. */
  18999. onbuttondown(callback: (buttonPressed: number) => void): void;
  19000. /**
  19001. * Callback triggered when a button has been released
  19002. * @param callback Called when a button has been released
  19003. */
  19004. onbuttonup(callback: (buttonReleased: number) => void): void;
  19005. /**
  19006. * Initializes the generic gamepad
  19007. * @param id The id of the generic gamepad
  19008. * @param index The index of the generic gamepad
  19009. * @param browserGamepad The browser gamepad
  19010. */
  19011. constructor(id: string, index: number, browserGamepad: any);
  19012. private _setButtonValue;
  19013. /**
  19014. * Updates the generic gamepad
  19015. */
  19016. update(): void;
  19017. /**
  19018. * Disposes the generic gamepad
  19019. */
  19020. dispose(): void;
  19021. }
  19022. }
  19023. declare module BABYLON {
  19024. /**
  19025. * Defines the types of pose enabled controllers that are supported
  19026. */
  19027. export enum PoseEnabledControllerType {
  19028. /**
  19029. * HTC Vive
  19030. */
  19031. VIVE = 0,
  19032. /**
  19033. * Oculus Rift
  19034. */
  19035. OCULUS = 1,
  19036. /**
  19037. * Windows mixed reality
  19038. */
  19039. WINDOWS = 2,
  19040. /**
  19041. * Samsung gear VR
  19042. */
  19043. GEAR_VR = 3,
  19044. /**
  19045. * Google Daydream
  19046. */
  19047. DAYDREAM = 4,
  19048. /**
  19049. * Generic
  19050. */
  19051. GENERIC = 5
  19052. }
  19053. /**
  19054. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19055. */
  19056. export interface MutableGamepadButton {
  19057. /**
  19058. * Value of the button/trigger
  19059. */
  19060. value: number;
  19061. /**
  19062. * If the button/trigger is currently touched
  19063. */
  19064. touched: boolean;
  19065. /**
  19066. * If the button/trigger is currently pressed
  19067. */
  19068. pressed: boolean;
  19069. }
  19070. /**
  19071. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19072. * @hidden
  19073. */
  19074. export interface ExtendedGamepadButton extends GamepadButton {
  19075. /**
  19076. * If the button/trigger is currently pressed
  19077. */
  19078. readonly pressed: boolean;
  19079. /**
  19080. * If the button/trigger is currently touched
  19081. */
  19082. readonly touched: boolean;
  19083. /**
  19084. * Value of the button/trigger
  19085. */
  19086. readonly value: number;
  19087. }
  19088. /** @hidden */
  19089. export interface _GamePadFactory {
  19090. /**
  19091. * Returns whether or not the current gamepad can be created for this type of controller.
  19092. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19093. * @returns true if it can be created, otherwise false
  19094. */
  19095. canCreate(gamepadInfo: any): boolean;
  19096. /**
  19097. * Creates a new instance of the Gamepad.
  19098. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19099. * @returns the new gamepad instance
  19100. */
  19101. create(gamepadInfo: any): Gamepad;
  19102. }
  19103. /**
  19104. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19105. */
  19106. export class PoseEnabledControllerHelper {
  19107. /** @hidden */
  19108. static _ControllerFactories: _GamePadFactory[];
  19109. /** @hidden */
  19110. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19111. /**
  19112. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19113. * @param vrGamepad the gamepad to initialized
  19114. * @returns a vr controller of the type the gamepad identified as
  19115. */
  19116. static InitiateController(vrGamepad: any): Gamepad;
  19117. }
  19118. /**
  19119. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19120. */
  19121. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19122. /**
  19123. * If the controller is used in a webXR session
  19124. */
  19125. isXR: boolean;
  19126. private _deviceRoomPosition;
  19127. private _deviceRoomRotationQuaternion;
  19128. /**
  19129. * The device position in babylon space
  19130. */
  19131. devicePosition: Vector3;
  19132. /**
  19133. * The device rotation in babylon space
  19134. */
  19135. deviceRotationQuaternion: Quaternion;
  19136. /**
  19137. * The scale factor of the device in babylon space
  19138. */
  19139. deviceScaleFactor: number;
  19140. /**
  19141. * (Likely devicePosition should be used instead) The device position in its room space
  19142. */
  19143. position: Vector3;
  19144. /**
  19145. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19146. */
  19147. rotationQuaternion: Quaternion;
  19148. /**
  19149. * The type of controller (Eg. Windows mixed reality)
  19150. */
  19151. controllerType: PoseEnabledControllerType;
  19152. protected _calculatedPosition: Vector3;
  19153. private _calculatedRotation;
  19154. /**
  19155. * The raw pose from the device
  19156. */
  19157. rawPose: DevicePose;
  19158. private _trackPosition;
  19159. private _maxRotationDistFromHeadset;
  19160. private _draggedRoomRotation;
  19161. /**
  19162. * @hidden
  19163. */
  19164. _disableTrackPosition(fixedPosition: Vector3): void;
  19165. /**
  19166. * Internal, the mesh attached to the controller
  19167. * @hidden
  19168. */
  19169. _mesh: Nullable<AbstractMesh>;
  19170. private _poseControlledCamera;
  19171. private _leftHandSystemQuaternion;
  19172. /**
  19173. * Internal, matrix used to convert room space to babylon space
  19174. * @hidden
  19175. */
  19176. _deviceToWorld: Matrix;
  19177. /**
  19178. * Node to be used when casting a ray from the controller
  19179. * @hidden
  19180. */
  19181. _pointingPoseNode: Nullable<TransformNode>;
  19182. /**
  19183. * Name of the child mesh that can be used to cast a ray from the controller
  19184. */
  19185. static readonly POINTING_POSE: string;
  19186. /**
  19187. * Creates a new PoseEnabledController from a gamepad
  19188. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19189. */
  19190. constructor(browserGamepad: any);
  19191. private _workingMatrix;
  19192. /**
  19193. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19194. */
  19195. update(): void;
  19196. /**
  19197. * Updates only the pose device and mesh without doing any button event checking
  19198. */
  19199. protected _updatePoseAndMesh(): void;
  19200. /**
  19201. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19202. * @param poseData raw pose fromthe device
  19203. */
  19204. updateFromDevice(poseData: DevicePose): void;
  19205. /**
  19206. * @hidden
  19207. */
  19208. _meshAttachedObservable: Observable<AbstractMesh>;
  19209. /**
  19210. * Attaches a mesh to the controller
  19211. * @param mesh the mesh to be attached
  19212. */
  19213. attachToMesh(mesh: AbstractMesh): void;
  19214. /**
  19215. * Attaches the controllers mesh to a camera
  19216. * @param camera the camera the mesh should be attached to
  19217. */
  19218. attachToPoseControlledCamera(camera: TargetCamera): void;
  19219. /**
  19220. * Disposes of the controller
  19221. */
  19222. dispose(): void;
  19223. /**
  19224. * The mesh that is attached to the controller
  19225. */
  19226. get mesh(): Nullable<AbstractMesh>;
  19227. /**
  19228. * Gets the ray of the controller in the direction the controller is pointing
  19229. * @param length the length the resulting ray should be
  19230. * @returns a ray in the direction the controller is pointing
  19231. */
  19232. getForwardRay(length?: number): Ray;
  19233. }
  19234. }
  19235. declare module BABYLON {
  19236. /**
  19237. * Defines the WebVRController object that represents controllers tracked in 3D space
  19238. */
  19239. export abstract class WebVRController extends PoseEnabledController {
  19240. /**
  19241. * Internal, the default controller model for the controller
  19242. */
  19243. protected _defaultModel: Nullable<AbstractMesh>;
  19244. /**
  19245. * Fired when the trigger state has changed
  19246. */
  19247. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19248. /**
  19249. * Fired when the main button state has changed
  19250. */
  19251. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19252. /**
  19253. * Fired when the secondary button state has changed
  19254. */
  19255. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19256. /**
  19257. * Fired when the pad state has changed
  19258. */
  19259. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19260. /**
  19261. * Fired when controllers stick values have changed
  19262. */
  19263. onPadValuesChangedObservable: Observable<StickValues>;
  19264. /**
  19265. * Array of button availible on the controller
  19266. */
  19267. protected _buttons: Array<MutableGamepadButton>;
  19268. private _onButtonStateChange;
  19269. /**
  19270. * Fired when a controller button's state has changed
  19271. * @param callback the callback containing the button that was modified
  19272. */
  19273. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19274. /**
  19275. * X and Y axis corresponding to the controllers joystick
  19276. */
  19277. pad: StickValues;
  19278. /**
  19279. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19280. */
  19281. hand: string;
  19282. /**
  19283. * The default controller model for the controller
  19284. */
  19285. get defaultModel(): Nullable<AbstractMesh>;
  19286. /**
  19287. * Creates a new WebVRController from a gamepad
  19288. * @param vrGamepad the gamepad that the WebVRController should be created from
  19289. */
  19290. constructor(vrGamepad: any);
  19291. /**
  19292. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19293. */
  19294. update(): void;
  19295. /**
  19296. * Function to be called when a button is modified
  19297. */
  19298. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19299. /**
  19300. * Loads a mesh and attaches it to the controller
  19301. * @param scene the scene the mesh should be added to
  19302. * @param meshLoaded callback for when the mesh has been loaded
  19303. */
  19304. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19305. private _setButtonValue;
  19306. private _changes;
  19307. private _checkChanges;
  19308. /**
  19309. * Disposes of th webVRCOntroller
  19310. */
  19311. dispose(): void;
  19312. }
  19313. }
  19314. declare module BABYLON {
  19315. /**
  19316. * The HemisphericLight simulates the ambient environment light,
  19317. * so the passed direction is the light reflection direction, not the incoming direction.
  19318. */
  19319. export class HemisphericLight extends Light {
  19320. /**
  19321. * The groundColor is the light in the opposite direction to the one specified during creation.
  19322. * 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.
  19323. */
  19324. groundColor: Color3;
  19325. /**
  19326. * The light reflection direction, not the incoming direction.
  19327. */
  19328. direction: Vector3;
  19329. /**
  19330. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19331. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19332. * The HemisphericLight can't cast shadows.
  19333. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19334. * @param name The friendly name of the light
  19335. * @param direction The direction of the light reflection
  19336. * @param scene The scene the light belongs to
  19337. */
  19338. constructor(name: string, direction: Vector3, scene: Scene);
  19339. protected _buildUniformLayout(): void;
  19340. /**
  19341. * Returns the string "HemisphericLight".
  19342. * @return The class name
  19343. */
  19344. getClassName(): string;
  19345. /**
  19346. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19347. * Returns the updated direction.
  19348. * @param target The target the direction should point to
  19349. * @return The computed direction
  19350. */
  19351. setDirectionToTarget(target: Vector3): Vector3;
  19352. /**
  19353. * Returns the shadow generator associated to the light.
  19354. * @returns Always null for hemispheric lights because it does not support shadows.
  19355. */
  19356. getShadowGenerator(): Nullable<IShadowGenerator>;
  19357. /**
  19358. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19359. * @param effect The effect to update
  19360. * @param lightIndex The index of the light in the effect to update
  19361. * @returns The hemispheric light
  19362. */
  19363. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19364. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19365. /**
  19366. * Computes the world matrix of the node
  19367. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19368. * @param useWasUpdatedFlag defines a reserved property
  19369. * @returns the world matrix
  19370. */
  19371. computeWorldMatrix(): Matrix;
  19372. /**
  19373. * Returns the integer 3.
  19374. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19375. */
  19376. getTypeID(): number;
  19377. /**
  19378. * Prepares the list of defines specific to the light type.
  19379. * @param defines the list of defines
  19380. * @param lightIndex defines the index of the light for the effect
  19381. */
  19382. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19383. }
  19384. }
  19385. declare module BABYLON {
  19386. /** @hidden */
  19387. export var vrMultiviewToSingleviewPixelShader: {
  19388. name: string;
  19389. shader: string;
  19390. };
  19391. }
  19392. declare module BABYLON {
  19393. /**
  19394. * Renders to multiple views with a single draw call
  19395. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19396. */
  19397. export class MultiviewRenderTarget extends RenderTargetTexture {
  19398. /**
  19399. * Creates a multiview render target
  19400. * @param scene scene used with the render target
  19401. * @param size the size of the render target (used for each view)
  19402. */
  19403. constructor(scene: Scene, size?: number | {
  19404. width: number;
  19405. height: number;
  19406. } | {
  19407. ratio: number;
  19408. });
  19409. /**
  19410. * @hidden
  19411. * @param faceIndex the face index, if its a cube texture
  19412. */
  19413. _bindFrameBuffer(faceIndex?: number): void;
  19414. /**
  19415. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19416. * @returns the view count
  19417. */
  19418. getViewCount(): number;
  19419. }
  19420. }
  19421. declare module BABYLON {
  19422. interface Engine {
  19423. /**
  19424. * Creates a new multiview render target
  19425. * @param width defines the width of the texture
  19426. * @param height defines the height of the texture
  19427. * @returns the created multiview texture
  19428. */
  19429. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19430. /**
  19431. * Binds a multiview framebuffer to be drawn to
  19432. * @param multiviewTexture texture to bind
  19433. */
  19434. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19435. }
  19436. interface Camera {
  19437. /**
  19438. * @hidden
  19439. * 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)
  19440. */
  19441. _useMultiviewToSingleView: boolean;
  19442. /**
  19443. * @hidden
  19444. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  19445. */
  19446. _multiviewTexture: Nullable<RenderTargetTexture>;
  19447. /**
  19448. * @hidden
  19449. * ensures the multiview texture of the camera exists and has the specified width/height
  19450. * @param width height to set on the multiview texture
  19451. * @param height width to set on the multiview texture
  19452. */
  19453. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19454. }
  19455. interface Scene {
  19456. /** @hidden */
  19457. _transformMatrixR: Matrix;
  19458. /** @hidden */
  19459. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19460. /** @hidden */
  19461. _createMultiviewUbo(): void;
  19462. /** @hidden */
  19463. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19464. /** @hidden */
  19465. _renderMultiviewToSingleView(camera: Camera): void;
  19466. }
  19467. }
  19468. declare module BABYLON {
  19469. /**
  19470. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19471. * This will not be used for webXR as it supports displaying texture arrays directly
  19472. */
  19473. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19474. /**
  19475. * Initializes a VRMultiviewToSingleview
  19476. * @param name name of the post process
  19477. * @param camera camera to be applied to
  19478. * @param scaleFactor scaling factor to the size of the output texture
  19479. */
  19480. constructor(name: string, camera: Camera, scaleFactor: number);
  19481. }
  19482. }
  19483. declare module BABYLON {
  19484. /**
  19485. * Interface used to define additional presentation attributes
  19486. */
  19487. export interface IVRPresentationAttributes {
  19488. /**
  19489. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19490. */
  19491. highRefreshRate: boolean;
  19492. /**
  19493. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19494. */
  19495. foveationLevel: number;
  19496. }
  19497. interface Engine {
  19498. /** @hidden */
  19499. _vrDisplay: any;
  19500. /** @hidden */
  19501. _vrSupported: boolean;
  19502. /** @hidden */
  19503. _oldSize: Size;
  19504. /** @hidden */
  19505. _oldHardwareScaleFactor: number;
  19506. /** @hidden */
  19507. _vrExclusivePointerMode: boolean;
  19508. /** @hidden */
  19509. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19510. /** @hidden */
  19511. _onVRDisplayPointerRestricted: () => void;
  19512. /** @hidden */
  19513. _onVRDisplayPointerUnrestricted: () => void;
  19514. /** @hidden */
  19515. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19516. /** @hidden */
  19517. _onVrDisplayDisconnect: Nullable<() => void>;
  19518. /** @hidden */
  19519. _onVrDisplayPresentChange: Nullable<() => void>;
  19520. /**
  19521. * Observable signaled when VR display mode changes
  19522. */
  19523. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19524. /**
  19525. * Observable signaled when VR request present is complete
  19526. */
  19527. onVRRequestPresentComplete: Observable<boolean>;
  19528. /**
  19529. * Observable signaled when VR request present starts
  19530. */
  19531. onVRRequestPresentStart: Observable<Engine>;
  19532. /**
  19533. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19534. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19535. */
  19536. isInVRExclusivePointerMode: boolean;
  19537. /**
  19538. * Gets a boolean indicating if a webVR device was detected
  19539. * @returns true if a webVR device was detected
  19540. */
  19541. isVRDevicePresent(): boolean;
  19542. /**
  19543. * Gets the current webVR device
  19544. * @returns the current webVR device (or null)
  19545. */
  19546. getVRDevice(): any;
  19547. /**
  19548. * Initializes a webVR display and starts listening to display change events
  19549. * The onVRDisplayChangedObservable will be notified upon these changes
  19550. * @returns A promise containing a VRDisplay and if vr is supported
  19551. */
  19552. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19553. /** @hidden */
  19554. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19555. /**
  19556. * Gets or sets the presentation attributes used to configure VR rendering
  19557. */
  19558. vrPresentationAttributes?: IVRPresentationAttributes;
  19559. /**
  19560. * Call this function to switch to webVR mode
  19561. * Will do nothing if webVR is not supported or if there is no webVR device
  19562. * @param options the webvr options provided to the camera. mainly used for multiview
  19563. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19564. */
  19565. enableVR(options: WebVROptions): void;
  19566. /** @hidden */
  19567. _onVRFullScreenTriggered(): void;
  19568. }
  19569. }
  19570. declare module BABYLON {
  19571. /**
  19572. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19573. * IMPORTANT!! The data is right-hand data.
  19574. * @export
  19575. * @interface DevicePose
  19576. */
  19577. export interface DevicePose {
  19578. /**
  19579. * The position of the device, values in array are [x,y,z].
  19580. */
  19581. readonly position: Nullable<Float32Array>;
  19582. /**
  19583. * The linearVelocity of the device, values in array are [x,y,z].
  19584. */
  19585. readonly linearVelocity: Nullable<Float32Array>;
  19586. /**
  19587. * The linearAcceleration of the device, values in array are [x,y,z].
  19588. */
  19589. readonly linearAcceleration: Nullable<Float32Array>;
  19590. /**
  19591. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19592. */
  19593. readonly orientation: Nullable<Float32Array>;
  19594. /**
  19595. * The angularVelocity of the device, values in array are [x,y,z].
  19596. */
  19597. readonly angularVelocity: Nullable<Float32Array>;
  19598. /**
  19599. * The angularAcceleration of the device, values in array are [x,y,z].
  19600. */
  19601. readonly angularAcceleration: Nullable<Float32Array>;
  19602. }
  19603. /**
  19604. * Interface representing a pose controlled object in Babylon.
  19605. * A pose controlled object has both regular pose values as well as pose values
  19606. * from an external device such as a VR head mounted display
  19607. */
  19608. export interface PoseControlled {
  19609. /**
  19610. * The position of the object in babylon space.
  19611. */
  19612. position: Vector3;
  19613. /**
  19614. * The rotation quaternion of the object in babylon space.
  19615. */
  19616. rotationQuaternion: Quaternion;
  19617. /**
  19618. * The position of the device in babylon space.
  19619. */
  19620. devicePosition?: Vector3;
  19621. /**
  19622. * The rotation quaternion of the device in babylon space.
  19623. */
  19624. deviceRotationQuaternion: Quaternion;
  19625. /**
  19626. * The raw pose coming from the device.
  19627. */
  19628. rawPose: Nullable<DevicePose>;
  19629. /**
  19630. * The scale of the device to be used when translating from device space to babylon space.
  19631. */
  19632. deviceScaleFactor: number;
  19633. /**
  19634. * Updates the poseControlled values based on the input device pose.
  19635. * @param poseData the pose data to update the object with
  19636. */
  19637. updateFromDevice(poseData: DevicePose): void;
  19638. }
  19639. /**
  19640. * Set of options to customize the webVRCamera
  19641. */
  19642. export interface WebVROptions {
  19643. /**
  19644. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19645. */
  19646. trackPosition?: boolean;
  19647. /**
  19648. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19649. */
  19650. positionScale?: number;
  19651. /**
  19652. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19653. */
  19654. displayName?: string;
  19655. /**
  19656. * Should the native controller meshes be initialized. (default: true)
  19657. */
  19658. controllerMeshes?: boolean;
  19659. /**
  19660. * Creating a default HemiLight only on controllers. (default: true)
  19661. */
  19662. defaultLightingOnControllers?: boolean;
  19663. /**
  19664. * If you don't want to use the default VR button of the helper. (default: false)
  19665. */
  19666. useCustomVRButton?: boolean;
  19667. /**
  19668. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19669. */
  19670. customVRButton?: HTMLButtonElement;
  19671. /**
  19672. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19673. */
  19674. rayLength?: number;
  19675. /**
  19676. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19677. */
  19678. defaultHeight?: number;
  19679. /**
  19680. * If multiview should be used if availible (default: false)
  19681. */
  19682. useMultiview?: boolean;
  19683. }
  19684. /**
  19685. * This represents a WebVR camera.
  19686. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19687. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19688. */
  19689. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19690. private webVROptions;
  19691. /**
  19692. * @hidden
  19693. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19694. */
  19695. _vrDevice: any;
  19696. /**
  19697. * The rawPose of the vrDevice.
  19698. */
  19699. rawPose: Nullable<DevicePose>;
  19700. private _onVREnabled;
  19701. private _specsVersion;
  19702. private _attached;
  19703. private _frameData;
  19704. protected _descendants: Array<Node>;
  19705. private _deviceRoomPosition;
  19706. /** @hidden */
  19707. _deviceRoomRotationQuaternion: Quaternion;
  19708. private _standingMatrix;
  19709. /**
  19710. * Represents device position in babylon space.
  19711. */
  19712. devicePosition: Vector3;
  19713. /**
  19714. * Represents device rotation in babylon space.
  19715. */
  19716. deviceRotationQuaternion: Quaternion;
  19717. /**
  19718. * The scale of the device to be used when translating from device space to babylon space.
  19719. */
  19720. deviceScaleFactor: number;
  19721. private _deviceToWorld;
  19722. private _worldToDevice;
  19723. /**
  19724. * References to the webVR controllers for the vrDevice.
  19725. */
  19726. controllers: Array<WebVRController>;
  19727. /**
  19728. * Emits an event when a controller is attached.
  19729. */
  19730. onControllersAttachedObservable: Observable<WebVRController[]>;
  19731. /**
  19732. * Emits an event when a controller's mesh has been loaded;
  19733. */
  19734. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19735. /**
  19736. * Emits an event when the HMD's pose has been updated.
  19737. */
  19738. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19739. private _poseSet;
  19740. /**
  19741. * If the rig cameras be used as parent instead of this camera.
  19742. */
  19743. rigParenting: boolean;
  19744. private _lightOnControllers;
  19745. private _defaultHeight?;
  19746. /**
  19747. * Instantiates a WebVRFreeCamera.
  19748. * @param name The name of the WebVRFreeCamera
  19749. * @param position The starting anchor position for the camera
  19750. * @param scene The scene the camera belongs to
  19751. * @param webVROptions a set of customizable options for the webVRCamera
  19752. */
  19753. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19754. /**
  19755. * Gets the device distance from the ground in meters.
  19756. * @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.
  19757. */
  19758. deviceDistanceToRoomGround(): number;
  19759. /**
  19760. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19761. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19762. */
  19763. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19764. /**
  19765. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19766. * @returns A promise with a boolean set to if the standing matrix is supported.
  19767. */
  19768. useStandingMatrixAsync(): Promise<boolean>;
  19769. /**
  19770. * Disposes the camera
  19771. */
  19772. dispose(): void;
  19773. /**
  19774. * Gets a vrController by name.
  19775. * @param name The name of the controller to retreive
  19776. * @returns the controller matching the name specified or null if not found
  19777. */
  19778. getControllerByName(name: string): Nullable<WebVRController>;
  19779. private _leftController;
  19780. /**
  19781. * The controller corresponding to the users left hand.
  19782. */
  19783. get leftController(): Nullable<WebVRController>;
  19784. private _rightController;
  19785. /**
  19786. * The controller corresponding to the users right hand.
  19787. */
  19788. get rightController(): Nullable<WebVRController>;
  19789. /**
  19790. * Casts a ray forward from the vrCamera's gaze.
  19791. * @param length Length of the ray (default: 100)
  19792. * @returns the ray corresponding to the gaze
  19793. */
  19794. getForwardRay(length?: number): Ray;
  19795. /**
  19796. * @hidden
  19797. * Updates the camera based on device's frame data
  19798. */
  19799. _checkInputs(): void;
  19800. /**
  19801. * Updates the poseControlled values based on the input device pose.
  19802. * @param poseData Pose coming from the device
  19803. */
  19804. updateFromDevice(poseData: DevicePose): void;
  19805. private _htmlElementAttached;
  19806. private _detachIfAttached;
  19807. /**
  19808. * WebVR's attach control will start broadcasting frames to the device.
  19809. * Note that in certain browsers (chrome for example) this function must be called
  19810. * within a user-interaction callback. Example:
  19811. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19812. *
  19813. * @param element html element to attach the vrDevice to
  19814. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19815. */
  19816. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19817. /**
  19818. * Detaches the camera from the html element and disables VR
  19819. *
  19820. * @param element html element to detach from
  19821. */
  19822. detachControl(element: HTMLElement): void;
  19823. /**
  19824. * @returns the name of this class
  19825. */
  19826. getClassName(): string;
  19827. /**
  19828. * Calls resetPose on the vrDisplay
  19829. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19830. */
  19831. resetToCurrentRotation(): void;
  19832. /**
  19833. * @hidden
  19834. * Updates the rig cameras (left and right eye)
  19835. */
  19836. _updateRigCameras(): void;
  19837. private _workingVector;
  19838. private _oneVector;
  19839. private _workingMatrix;
  19840. private updateCacheCalled;
  19841. private _correctPositionIfNotTrackPosition;
  19842. /**
  19843. * @hidden
  19844. * Updates the cached values of the camera
  19845. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19846. */
  19847. _updateCache(ignoreParentClass?: boolean): void;
  19848. /**
  19849. * @hidden
  19850. * Get current device position in babylon world
  19851. */
  19852. _computeDevicePosition(): void;
  19853. /**
  19854. * Updates the current device position and rotation in the babylon world
  19855. */
  19856. update(): void;
  19857. /**
  19858. * @hidden
  19859. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19860. * @returns an identity matrix
  19861. */
  19862. _getViewMatrix(): Matrix;
  19863. private _tmpMatrix;
  19864. /**
  19865. * This function is called by the two RIG cameras.
  19866. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19867. * @hidden
  19868. */
  19869. _getWebVRViewMatrix(): Matrix;
  19870. /** @hidden */
  19871. _getWebVRProjectionMatrix(): Matrix;
  19872. private _onGamepadConnectedObserver;
  19873. private _onGamepadDisconnectedObserver;
  19874. private _updateCacheWhenTrackingDisabledObserver;
  19875. /**
  19876. * Initializes the controllers and their meshes
  19877. */
  19878. initControllers(): void;
  19879. }
  19880. }
  19881. declare module BABYLON {
  19882. /**
  19883. * "Static Class" containing the most commonly used helper while dealing with material for
  19884. * rendering purpose.
  19885. *
  19886. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  19887. *
  19888. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  19889. */
  19890. export class MaterialHelper {
  19891. /**
  19892. * Bind the current view position to an effect.
  19893. * @param effect The effect to be bound
  19894. * @param scene The scene the eyes position is used from
  19895. * @param variableName name of the shader variable that will hold the eye position
  19896. */
  19897. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  19898. /**
  19899. * Helps preparing the defines values about the UVs in used in the effect.
  19900. * UVs are shared as much as we can accross channels in the shaders.
  19901. * @param texture The texture we are preparing the UVs for
  19902. * @param defines The defines to update
  19903. * @param key The channel key "diffuse", "specular"... used in the shader
  19904. */
  19905. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  19906. /**
  19907. * Binds a texture matrix value to its corrsponding uniform
  19908. * @param texture The texture to bind the matrix for
  19909. * @param uniformBuffer The uniform buffer receivin the data
  19910. * @param key The channel key "diffuse", "specular"... used in the shader
  19911. */
  19912. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  19913. /**
  19914. * Gets the current status of the fog (should it be enabled?)
  19915. * @param mesh defines the mesh to evaluate for fog support
  19916. * @param scene defines the hosting scene
  19917. * @returns true if fog must be enabled
  19918. */
  19919. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  19920. /**
  19921. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  19922. * @param mesh defines the current mesh
  19923. * @param scene defines the current scene
  19924. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  19925. * @param pointsCloud defines if point cloud rendering has to be turned on
  19926. * @param fogEnabled defines if fog has to be turned on
  19927. * @param alphaTest defines if alpha testing has to be turned on
  19928. * @param defines defines the current list of defines
  19929. */
  19930. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  19931. /**
  19932. * Helper used to prepare the list of defines associated with frame values for shader compilation
  19933. * @param scene defines the current scene
  19934. * @param engine defines the current engine
  19935. * @param defines specifies the list of active defines
  19936. * @param useInstances defines if instances have to be turned on
  19937. * @param useClipPlane defines if clip plane have to be turned on
  19938. * @param useInstances defines if instances have to be turned on
  19939. * @param useThinInstances defines if thin instances have to be turned on
  19940. */
  19941. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  19942. /**
  19943. * Prepares the defines for bones
  19944. * @param mesh The mesh containing the geometry data we will draw
  19945. * @param defines The defines to update
  19946. */
  19947. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  19948. /**
  19949. * Prepares the defines for morph targets
  19950. * @param mesh The mesh containing the geometry data we will draw
  19951. * @param defines The defines to update
  19952. */
  19953. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  19954. /**
  19955. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  19956. * @param mesh The mesh containing the geometry data we will draw
  19957. * @param defines The defines to update
  19958. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  19959. * @param useBones Precise whether bones should be used or not (override mesh info)
  19960. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  19961. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  19962. * @returns false if defines are considered not dirty and have not been checked
  19963. */
  19964. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  19965. /**
  19966. * Prepares the defines related to multiview
  19967. * @param scene The scene we are intending to draw
  19968. * @param defines The defines to update
  19969. */
  19970. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  19971. /**
  19972. * Prepares the defines related to the light information passed in parameter
  19973. * @param scene The scene we are intending to draw
  19974. * @param mesh The mesh the effect is compiling for
  19975. * @param light The light the effect is compiling for
  19976. * @param lightIndex The index of the light
  19977. * @param defines The defines to update
  19978. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  19979. * @param state Defines the current state regarding what is needed (normals, etc...)
  19980. */
  19981. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  19982. needNormals: boolean;
  19983. needRebuild: boolean;
  19984. shadowEnabled: boolean;
  19985. specularEnabled: boolean;
  19986. lightmapMode: boolean;
  19987. }): void;
  19988. /**
  19989. * Prepares the defines related to the light information passed in parameter
  19990. * @param scene The scene we are intending to draw
  19991. * @param mesh The mesh the effect is compiling for
  19992. * @param defines The defines to update
  19993. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  19994. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  19995. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  19996. * @returns true if normals will be required for the rest of the effect
  19997. */
  19998. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  19999. /**
  20000. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20001. * @param lightIndex defines the light index
  20002. * @param uniformsList The uniform list
  20003. * @param samplersList The sampler list
  20004. * @param projectedLightTexture defines if projected texture must be used
  20005. * @param uniformBuffersList defines an optional list of uniform buffers
  20006. */
  20007. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20008. /**
  20009. * Prepares the uniforms and samplers list to be used in the effect
  20010. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20011. * @param samplersList The sampler list
  20012. * @param defines The defines helping in the list generation
  20013. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20014. */
  20015. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20016. /**
  20017. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20018. * @param defines The defines to update while falling back
  20019. * @param fallbacks The authorized effect fallbacks
  20020. * @param maxSimultaneousLights The maximum number of lights allowed
  20021. * @param rank the current rank of the Effect
  20022. * @returns The newly affected rank
  20023. */
  20024. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20025. private static _TmpMorphInfluencers;
  20026. /**
  20027. * Prepares the list of attributes required for morph targets according to the effect defines.
  20028. * @param attribs The current list of supported attribs
  20029. * @param mesh The mesh to prepare the morph targets attributes for
  20030. * @param influencers The number of influencers
  20031. */
  20032. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20033. /**
  20034. * Prepares the list of attributes required for morph targets according to the effect defines.
  20035. * @param attribs The current list of supported attribs
  20036. * @param mesh The mesh to prepare the morph targets attributes for
  20037. * @param defines The current Defines of the effect
  20038. */
  20039. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20040. /**
  20041. * Prepares the list of attributes required for bones according to the effect defines.
  20042. * @param attribs The current list of supported attribs
  20043. * @param mesh The mesh to prepare the bones attributes for
  20044. * @param defines The current Defines of the effect
  20045. * @param fallbacks The current efffect fallback strategy
  20046. */
  20047. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20048. /**
  20049. * Check and prepare the list of attributes required for instances according to the effect defines.
  20050. * @param attribs The current list of supported attribs
  20051. * @param defines The current MaterialDefines of the effect
  20052. */
  20053. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20054. /**
  20055. * Add the list of attributes required for instances to the attribs array.
  20056. * @param attribs The current list of supported attribs
  20057. */
  20058. static PushAttributesForInstances(attribs: string[]): void;
  20059. /**
  20060. * Binds the light information to the effect.
  20061. * @param light The light containing the generator
  20062. * @param effect The effect we are binding the data to
  20063. * @param lightIndex The light index in the effect used to render
  20064. */
  20065. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20066. /**
  20067. * Binds the lights information from the scene to the effect for the given mesh.
  20068. * @param light Light to bind
  20069. * @param lightIndex Light index
  20070. * @param scene The scene where the light belongs to
  20071. * @param effect The effect we are binding the data to
  20072. * @param useSpecular Defines if specular is supported
  20073. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20074. */
  20075. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20076. /**
  20077. * Binds the lights information from the scene to the effect for the given mesh.
  20078. * @param scene The scene the lights belongs to
  20079. * @param mesh The mesh we are binding the information to render
  20080. * @param effect The effect we are binding the data to
  20081. * @param defines The generated defines for the effect
  20082. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20083. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20084. */
  20085. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20086. private static _tempFogColor;
  20087. /**
  20088. * Binds the fog information from the scene to the effect for the given mesh.
  20089. * @param scene The scene the lights belongs to
  20090. * @param mesh The mesh we are binding the information to render
  20091. * @param effect The effect we are binding the data to
  20092. * @param linearSpace Defines if the fog effect is applied in linear space
  20093. */
  20094. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20095. /**
  20096. * Binds the bones information from the mesh to the effect.
  20097. * @param mesh The mesh we are binding the information to render
  20098. * @param effect The effect we are binding the data to
  20099. */
  20100. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20101. /**
  20102. * Binds the morph targets information from the mesh to the effect.
  20103. * @param abstractMesh The mesh we are binding the information to render
  20104. * @param effect The effect we are binding the data to
  20105. */
  20106. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20107. /**
  20108. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20109. * @param defines The generated defines used in the effect
  20110. * @param effect The effect we are binding the data to
  20111. * @param scene The scene we are willing to render with logarithmic scale for
  20112. */
  20113. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20114. /**
  20115. * Binds the clip plane information from the scene to the effect.
  20116. * @param scene The scene the clip plane information are extracted from
  20117. * @param effect The effect we are binding the data to
  20118. */
  20119. static BindClipPlane(effect: Effect, scene: Scene): void;
  20120. }
  20121. }
  20122. declare module BABYLON {
  20123. /**
  20124. * Block used to expose an input value
  20125. */
  20126. export class InputBlock extends NodeMaterialBlock {
  20127. private _mode;
  20128. private _associatedVariableName;
  20129. private _storedValue;
  20130. private _valueCallback;
  20131. private _type;
  20132. private _animationType;
  20133. /** Gets or set a value used to limit the range of float values */
  20134. min: number;
  20135. /** Gets or set a value used to limit the range of float values */
  20136. max: number;
  20137. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20138. isBoolean: boolean;
  20139. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20140. matrixMode: number;
  20141. /** @hidden */
  20142. _systemValue: Nullable<NodeMaterialSystemValues>;
  20143. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20144. visibleInInspector: boolean;
  20145. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20146. isConstant: boolean;
  20147. /** Gets or sets the group to use to display this block in the Inspector */
  20148. groupInInspector: string;
  20149. /** Gets an observable raised when the value is changed */
  20150. onValueChangedObservable: Observable<InputBlock>;
  20151. /**
  20152. * Gets or sets the connection point type (default is float)
  20153. */
  20154. get type(): NodeMaterialBlockConnectionPointTypes;
  20155. /**
  20156. * Creates a new InputBlock
  20157. * @param name defines the block name
  20158. * @param target defines the target of that block (Vertex by default)
  20159. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20160. */
  20161. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20162. /**
  20163. * Gets the output component
  20164. */
  20165. get output(): NodeMaterialConnectionPoint;
  20166. /**
  20167. * Set the source of this connection point to a vertex attribute
  20168. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20169. * @returns the current connection point
  20170. */
  20171. setAsAttribute(attributeName?: string): InputBlock;
  20172. /**
  20173. * Set the source of this connection point to a system value
  20174. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20175. * @returns the current connection point
  20176. */
  20177. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20178. /**
  20179. * Gets or sets the value of that point.
  20180. * Please note that this value will be ignored if valueCallback is defined
  20181. */
  20182. get value(): any;
  20183. set value(value: any);
  20184. /**
  20185. * Gets or sets a callback used to get the value of that point.
  20186. * Please note that setting this value will force the connection point to ignore the value property
  20187. */
  20188. get valueCallback(): () => any;
  20189. set valueCallback(value: () => any);
  20190. /**
  20191. * Gets or sets the associated variable name in the shader
  20192. */
  20193. get associatedVariableName(): string;
  20194. set associatedVariableName(value: string);
  20195. /** Gets or sets the type of animation applied to the input */
  20196. get animationType(): AnimatedInputBlockTypes;
  20197. set animationType(value: AnimatedInputBlockTypes);
  20198. /**
  20199. * Gets a boolean indicating that this connection point not defined yet
  20200. */
  20201. get isUndefined(): boolean;
  20202. /**
  20203. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20204. * In this case the connection point name must be the name of the uniform to use.
  20205. * Can only be set on inputs
  20206. */
  20207. get isUniform(): boolean;
  20208. set isUniform(value: boolean);
  20209. /**
  20210. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20211. * In this case the connection point name must be the name of the attribute to use
  20212. * Can only be set on inputs
  20213. */
  20214. get isAttribute(): boolean;
  20215. set isAttribute(value: boolean);
  20216. /**
  20217. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20218. * Can only be set on exit points
  20219. */
  20220. get isVarying(): boolean;
  20221. set isVarying(value: boolean);
  20222. /**
  20223. * Gets a boolean indicating that the current connection point is a system value
  20224. */
  20225. get isSystemValue(): boolean;
  20226. /**
  20227. * Gets or sets the current well known value or null if not defined as a system value
  20228. */
  20229. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20230. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20231. /**
  20232. * Gets the current class name
  20233. * @returns the class name
  20234. */
  20235. getClassName(): string;
  20236. /**
  20237. * Animate the input if animationType !== None
  20238. * @param scene defines the rendering scene
  20239. */
  20240. animate(scene: Scene): void;
  20241. private _emitDefine;
  20242. initialize(state: NodeMaterialBuildState): void;
  20243. /**
  20244. * Set the input block to its default value (based on its type)
  20245. */
  20246. setDefaultValue(): void;
  20247. private _emitConstant;
  20248. /** @hidden */
  20249. get _noContextSwitch(): boolean;
  20250. private _emit;
  20251. /** @hidden */
  20252. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20253. /** @hidden */
  20254. _transmit(effect: Effect, scene: Scene): void;
  20255. protected _buildBlock(state: NodeMaterialBuildState): void;
  20256. protected _dumpPropertiesCode(): string;
  20257. dispose(): void;
  20258. serialize(): any;
  20259. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20260. }
  20261. }
  20262. declare module BABYLON {
  20263. /**
  20264. * Enum used to define the compatibility state between two connection points
  20265. */
  20266. export enum NodeMaterialConnectionPointCompatibilityStates {
  20267. /** Points are compatibles */
  20268. Compatible = 0,
  20269. /** Points are incompatible because of their types */
  20270. TypeIncompatible = 1,
  20271. /** Points are incompatible because of their targets (vertex vs fragment) */
  20272. TargetIncompatible = 2
  20273. }
  20274. /**
  20275. * Defines the direction of a connection point
  20276. */
  20277. export enum NodeMaterialConnectionPointDirection {
  20278. /** Input */
  20279. Input = 0,
  20280. /** Output */
  20281. Output = 1
  20282. }
  20283. /**
  20284. * Defines a connection point for a block
  20285. */
  20286. export class NodeMaterialConnectionPoint {
  20287. /** @hidden */
  20288. _ownerBlock: NodeMaterialBlock;
  20289. /** @hidden */
  20290. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20291. private _endpoints;
  20292. private _associatedVariableName;
  20293. private _direction;
  20294. /** @hidden */
  20295. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20296. /** @hidden */
  20297. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20298. private _type;
  20299. /** @hidden */
  20300. _enforceAssociatedVariableName: boolean;
  20301. /** Gets the direction of the point */
  20302. get direction(): NodeMaterialConnectionPointDirection;
  20303. /** Indicates that this connection point needs dual validation before being connected to another point */
  20304. needDualDirectionValidation: boolean;
  20305. /**
  20306. * Gets or sets the additional types supported by this connection point
  20307. */
  20308. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20309. /**
  20310. * Gets or sets the additional types excluded by this connection point
  20311. */
  20312. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20313. /**
  20314. * Observable triggered when this point is connected
  20315. */
  20316. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20317. /**
  20318. * Gets or sets the associated variable name in the shader
  20319. */
  20320. get associatedVariableName(): string;
  20321. set associatedVariableName(value: string);
  20322. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20323. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20324. /**
  20325. * Gets or sets the connection point type (default is float)
  20326. */
  20327. get type(): NodeMaterialBlockConnectionPointTypes;
  20328. set type(value: NodeMaterialBlockConnectionPointTypes);
  20329. /**
  20330. * Gets or sets the connection point name
  20331. */
  20332. name: string;
  20333. /**
  20334. * Gets or sets the connection point name
  20335. */
  20336. displayName: string;
  20337. /**
  20338. * Gets or sets a boolean indicating that this connection point can be omitted
  20339. */
  20340. isOptional: boolean;
  20341. /**
  20342. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  20343. */
  20344. isExposedOnFrame: boolean;
  20345. /**
  20346. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20347. */
  20348. define: string;
  20349. /** @hidden */
  20350. _prioritizeVertex: boolean;
  20351. private _target;
  20352. /** Gets or sets the target of that connection point */
  20353. get target(): NodeMaterialBlockTargets;
  20354. set target(value: NodeMaterialBlockTargets);
  20355. /**
  20356. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20357. */
  20358. get isConnected(): boolean;
  20359. /**
  20360. * Gets a boolean indicating that the current point is connected to an input block
  20361. */
  20362. get isConnectedToInputBlock(): boolean;
  20363. /**
  20364. * Gets a the connected input block (if any)
  20365. */
  20366. get connectInputBlock(): Nullable<InputBlock>;
  20367. /** Get the other side of the connection (if any) */
  20368. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20369. /** Get the block that owns this connection point */
  20370. get ownerBlock(): NodeMaterialBlock;
  20371. /** Get the block connected on the other side of this connection (if any) */
  20372. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20373. /** Get the block connected on the endpoints of this connection (if any) */
  20374. get connectedBlocks(): Array<NodeMaterialBlock>;
  20375. /** Gets the list of connected endpoints */
  20376. get endpoints(): NodeMaterialConnectionPoint[];
  20377. /** Gets a boolean indicating if that output point is connected to at least one input */
  20378. get hasEndpoints(): boolean;
  20379. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20380. get isConnectedInVertexShader(): boolean;
  20381. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20382. get isConnectedInFragmentShader(): boolean;
  20383. /**
  20384. * Creates a block suitable to be used as an input for this input point.
  20385. * If null is returned, a block based on the point type will be created.
  20386. * @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
  20387. */
  20388. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20389. /**
  20390. * Creates a new connection point
  20391. * @param name defines the connection point name
  20392. * @param ownerBlock defines the block hosting this connection point
  20393. * @param direction defines the direction of the connection point
  20394. */
  20395. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20396. /**
  20397. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20398. * @returns the class name
  20399. */
  20400. getClassName(): string;
  20401. /**
  20402. * Gets a boolean indicating if the current point can be connected to another point
  20403. * @param connectionPoint defines the other connection point
  20404. * @returns a boolean
  20405. */
  20406. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20407. /**
  20408. * Gets a number indicating if the current point can be connected to another point
  20409. * @param connectionPoint defines the other connection point
  20410. * @returns a number defining the compatibility state
  20411. */
  20412. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20413. /**
  20414. * Connect this point to another connection point
  20415. * @param connectionPoint defines the other connection point
  20416. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20417. * @returns the current connection point
  20418. */
  20419. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20420. /**
  20421. * Disconnect this point from one of his endpoint
  20422. * @param endpoint defines the other connection point
  20423. * @returns the current connection point
  20424. */
  20425. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20426. /**
  20427. * Serializes this point in a JSON representation
  20428. * @param isInput defines if the connection point is an input (default is true)
  20429. * @returns the serialized point object
  20430. */
  20431. serialize(isInput?: boolean): any;
  20432. /**
  20433. * Release resources
  20434. */
  20435. dispose(): void;
  20436. }
  20437. }
  20438. declare module BABYLON {
  20439. /**
  20440. * Enum used to define the material modes
  20441. */
  20442. export enum NodeMaterialModes {
  20443. /** Regular material */
  20444. Material = 0,
  20445. /** For post process */
  20446. PostProcess = 1,
  20447. /** For particle system */
  20448. Particle = 2
  20449. }
  20450. }
  20451. declare module BABYLON {
  20452. /**
  20453. * Block used to read a texture from a sampler
  20454. */
  20455. export class TextureBlock extends NodeMaterialBlock {
  20456. private _defineName;
  20457. private _linearDefineName;
  20458. private _gammaDefineName;
  20459. private _tempTextureRead;
  20460. private _samplerName;
  20461. private _transformedUVName;
  20462. private _textureTransformName;
  20463. private _textureInfoName;
  20464. private _mainUVName;
  20465. private _mainUVDefineName;
  20466. private _fragmentOnly;
  20467. /**
  20468. * Gets or sets the texture associated with the node
  20469. */
  20470. texture: Nullable<Texture>;
  20471. /**
  20472. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20473. */
  20474. convertToGammaSpace: boolean;
  20475. /**
  20476. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20477. */
  20478. convertToLinearSpace: boolean;
  20479. /**
  20480. * Create a new TextureBlock
  20481. * @param name defines the block name
  20482. */
  20483. constructor(name: string, fragmentOnly?: boolean);
  20484. /**
  20485. * Gets the current class name
  20486. * @returns the class name
  20487. */
  20488. getClassName(): string;
  20489. /**
  20490. * Gets the uv input component
  20491. */
  20492. get uv(): NodeMaterialConnectionPoint;
  20493. /**
  20494. * Gets the rgba output component
  20495. */
  20496. get rgba(): NodeMaterialConnectionPoint;
  20497. /**
  20498. * Gets the rgb output component
  20499. */
  20500. get rgb(): NodeMaterialConnectionPoint;
  20501. /**
  20502. * Gets the r output component
  20503. */
  20504. get r(): NodeMaterialConnectionPoint;
  20505. /**
  20506. * Gets the g output component
  20507. */
  20508. get g(): NodeMaterialConnectionPoint;
  20509. /**
  20510. * Gets the b output component
  20511. */
  20512. get b(): NodeMaterialConnectionPoint;
  20513. /**
  20514. * Gets the a output component
  20515. */
  20516. get a(): NodeMaterialConnectionPoint;
  20517. get target(): NodeMaterialBlockTargets;
  20518. autoConfigure(material: NodeMaterial): void;
  20519. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20520. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20521. isReady(): boolean;
  20522. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20523. private get _isMixed();
  20524. private _injectVertexCode;
  20525. private _writeTextureRead;
  20526. private _writeOutput;
  20527. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20528. protected _dumpPropertiesCode(): string;
  20529. serialize(): any;
  20530. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20531. }
  20532. }
  20533. declare module BABYLON {
  20534. /** @hidden */
  20535. export var reflectionFunction: {
  20536. name: string;
  20537. shader: string;
  20538. };
  20539. }
  20540. declare module BABYLON {
  20541. /**
  20542. * Base block used to read a reflection texture from a sampler
  20543. */
  20544. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  20545. /** @hidden */
  20546. _define3DName: string;
  20547. /** @hidden */
  20548. _defineCubicName: string;
  20549. /** @hidden */
  20550. _defineExplicitName: string;
  20551. /** @hidden */
  20552. _defineProjectionName: string;
  20553. /** @hidden */
  20554. _defineLocalCubicName: string;
  20555. /** @hidden */
  20556. _defineSphericalName: string;
  20557. /** @hidden */
  20558. _definePlanarName: string;
  20559. /** @hidden */
  20560. _defineEquirectangularName: string;
  20561. /** @hidden */
  20562. _defineMirroredEquirectangularFixedName: string;
  20563. /** @hidden */
  20564. _defineEquirectangularFixedName: string;
  20565. /** @hidden */
  20566. _defineSkyboxName: string;
  20567. /** @hidden */
  20568. _defineOppositeZ: string;
  20569. /** @hidden */
  20570. _cubeSamplerName: string;
  20571. /** @hidden */
  20572. _2DSamplerName: string;
  20573. protected _positionUVWName: string;
  20574. protected _directionWName: string;
  20575. protected _reflectionVectorName: string;
  20576. /** @hidden */
  20577. _reflectionCoordsName: string;
  20578. /** @hidden */
  20579. _reflectionMatrixName: string;
  20580. protected _reflectionColorName: string;
  20581. /**
  20582. * Gets or sets the texture associated with the node
  20583. */
  20584. texture: Nullable<BaseTexture>;
  20585. /**
  20586. * Create a new ReflectionTextureBaseBlock
  20587. * @param name defines the block name
  20588. */
  20589. constructor(name: string);
  20590. /**
  20591. * Gets the current class name
  20592. * @returns the class name
  20593. */
  20594. getClassName(): string;
  20595. /**
  20596. * Gets the world position input component
  20597. */
  20598. abstract get position(): NodeMaterialConnectionPoint;
  20599. /**
  20600. * Gets the world position input component
  20601. */
  20602. abstract get worldPosition(): NodeMaterialConnectionPoint;
  20603. /**
  20604. * Gets the world normal input component
  20605. */
  20606. abstract get worldNormal(): NodeMaterialConnectionPoint;
  20607. /**
  20608. * Gets the world input component
  20609. */
  20610. abstract get world(): NodeMaterialConnectionPoint;
  20611. /**
  20612. * Gets the camera (or eye) position component
  20613. */
  20614. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  20615. /**
  20616. * Gets the view input component
  20617. */
  20618. abstract get view(): NodeMaterialConnectionPoint;
  20619. protected _getTexture(): Nullable<BaseTexture>;
  20620. autoConfigure(material: NodeMaterial): void;
  20621. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20622. isReady(): boolean;
  20623. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20624. /**
  20625. * Gets the code to inject in the vertex shader
  20626. * @param state current state of the node material building
  20627. * @returns the shader code
  20628. */
  20629. handleVertexSide(state: NodeMaterialBuildState): string;
  20630. /**
  20631. * Handles the inits for the fragment code path
  20632. * @param state node material build state
  20633. */
  20634. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  20635. /**
  20636. * Generates the reflection coords code for the fragment code path
  20637. * @param worldNormalVarName name of the world normal variable
  20638. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  20639. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  20640. * @returns the shader code
  20641. */
  20642. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  20643. /**
  20644. * Generates the reflection color code for the fragment code path
  20645. * @param lodVarName name of the lod variable
  20646. * @param swizzleLookupTexture swizzle to use for the final color variable
  20647. * @returns the shader code
  20648. */
  20649. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  20650. /**
  20651. * Generates the code corresponding to the connected output points
  20652. * @param state node material build state
  20653. * @param varName name of the variable to output
  20654. * @returns the shader code
  20655. */
  20656. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  20657. protected _buildBlock(state: NodeMaterialBuildState): this;
  20658. protected _dumpPropertiesCode(): string;
  20659. serialize(): any;
  20660. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20661. }
  20662. }
  20663. declare module BABYLON {
  20664. /**
  20665. * Defines a connection point to be used for points with a custom object type
  20666. */
  20667. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  20668. private _blockType;
  20669. private _blockName;
  20670. private _nameForCheking?;
  20671. /**
  20672. * Creates a new connection point
  20673. * @param name defines the connection point name
  20674. * @param ownerBlock defines the block hosting this connection point
  20675. * @param direction defines the direction of the connection point
  20676. */
  20677. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  20678. /**
  20679. * Gets a number indicating if the current point can be connected to another point
  20680. * @param connectionPoint defines the other connection point
  20681. * @returns a number defining the compatibility state
  20682. */
  20683. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20684. /**
  20685. * Creates a block suitable to be used as an input for this input point.
  20686. * If null is returned, a block based on the point type will be created.
  20687. * @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
  20688. */
  20689. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20690. }
  20691. }
  20692. declare module BABYLON {
  20693. /**
  20694. * Enum defining the type of properties that can be edited in the property pages in the NME
  20695. */
  20696. export enum PropertyTypeForEdition {
  20697. /** property is a boolean */
  20698. Boolean = 0,
  20699. /** property is a float */
  20700. Float = 1,
  20701. /** property is a Vector2 */
  20702. Vector2 = 2,
  20703. /** property is a list of values */
  20704. List = 3
  20705. }
  20706. /**
  20707. * Interface that defines an option in a variable of type list
  20708. */
  20709. export interface IEditablePropertyListOption {
  20710. /** label of the option */
  20711. "label": string;
  20712. /** value of the option */
  20713. "value": number;
  20714. }
  20715. /**
  20716. * Interface that defines the options available for an editable property
  20717. */
  20718. export interface IEditablePropertyOption {
  20719. /** min value */
  20720. "min"?: number;
  20721. /** max value */
  20722. "max"?: number;
  20723. /** notifiers: indicates which actions to take when the property is changed */
  20724. "notifiers"?: {
  20725. /** the material should be rebuilt */
  20726. "rebuild"?: boolean;
  20727. /** the preview should be updated */
  20728. "update"?: boolean;
  20729. };
  20730. /** list of the options for a variable of type list */
  20731. "options"?: IEditablePropertyListOption[];
  20732. }
  20733. /**
  20734. * Interface that describes an editable property
  20735. */
  20736. export interface IPropertyDescriptionForEdition {
  20737. /** name of the property */
  20738. "propertyName": string;
  20739. /** display name of the property */
  20740. "displayName": string;
  20741. /** type of the property */
  20742. "type": PropertyTypeForEdition;
  20743. /** group of the property - all properties with the same group value will be displayed in a specific section */
  20744. "groupName": string;
  20745. /** options for the property */
  20746. "options": IEditablePropertyOption;
  20747. }
  20748. /**
  20749. * Decorator that flags a property in a node material block as being editable
  20750. */
  20751. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  20752. }
  20753. declare module BABYLON {
  20754. /**
  20755. * Block used to implement the refraction part of the sub surface module of the PBR material
  20756. */
  20757. export class RefractionBlock extends NodeMaterialBlock {
  20758. /** @hidden */
  20759. _define3DName: string;
  20760. /** @hidden */
  20761. _refractionMatrixName: string;
  20762. /** @hidden */
  20763. _defineLODRefractionAlpha: string;
  20764. /** @hidden */
  20765. _defineLinearSpecularRefraction: string;
  20766. /** @hidden */
  20767. _defineOppositeZ: string;
  20768. /** @hidden */
  20769. _cubeSamplerName: string;
  20770. /** @hidden */
  20771. _2DSamplerName: string;
  20772. /** @hidden */
  20773. _vRefractionMicrosurfaceInfosName: string;
  20774. /** @hidden */
  20775. _vRefractionInfosName: string;
  20776. private _scene;
  20777. /**
  20778. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20779. * Materials half opaque for instance using refraction could benefit from this control.
  20780. */
  20781. linkRefractionWithTransparency: boolean;
  20782. /**
  20783. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20784. */
  20785. invertRefractionY: boolean;
  20786. /**
  20787. * Gets or sets the texture associated with the node
  20788. */
  20789. texture: Nullable<BaseTexture>;
  20790. /**
  20791. * Create a new RefractionBlock
  20792. * @param name defines the block name
  20793. */
  20794. constructor(name: string);
  20795. /**
  20796. * Gets the current class name
  20797. * @returns the class name
  20798. */
  20799. getClassName(): string;
  20800. /**
  20801. * Gets the intensity input component
  20802. */
  20803. get intensity(): NodeMaterialConnectionPoint;
  20804. /**
  20805. * Gets the index of refraction input component
  20806. */
  20807. get indexOfRefraction(): NodeMaterialConnectionPoint;
  20808. /**
  20809. * Gets the tint at distance input component
  20810. */
  20811. get tintAtDistance(): NodeMaterialConnectionPoint;
  20812. /**
  20813. * Gets the view input component
  20814. */
  20815. get view(): NodeMaterialConnectionPoint;
  20816. /**
  20817. * Gets the refraction object output component
  20818. */
  20819. get refraction(): NodeMaterialConnectionPoint;
  20820. /**
  20821. * Returns true if the block has a texture
  20822. */
  20823. get hasTexture(): boolean;
  20824. protected _getTexture(): Nullable<BaseTexture>;
  20825. autoConfigure(material: NodeMaterial): void;
  20826. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20827. isReady(): boolean;
  20828. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  20829. /**
  20830. * Gets the main code of the block (fragment side)
  20831. * @param state current state of the node material building
  20832. * @returns the shader code
  20833. */
  20834. getCode(state: NodeMaterialBuildState): string;
  20835. protected _buildBlock(state: NodeMaterialBuildState): this;
  20836. protected _dumpPropertiesCode(): string;
  20837. serialize(): any;
  20838. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20839. }
  20840. }
  20841. declare module BABYLON {
  20842. /**
  20843. * Base block used as input for post process
  20844. */
  20845. export class CurrentScreenBlock extends NodeMaterialBlock {
  20846. private _samplerName;
  20847. private _linearDefineName;
  20848. private _gammaDefineName;
  20849. private _mainUVName;
  20850. private _tempTextureRead;
  20851. /**
  20852. * Gets or sets the texture associated with the node
  20853. */
  20854. texture: Nullable<BaseTexture>;
  20855. /**
  20856. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20857. */
  20858. convertToGammaSpace: boolean;
  20859. /**
  20860. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20861. */
  20862. convertToLinearSpace: boolean;
  20863. /**
  20864. * Create a new CurrentScreenBlock
  20865. * @param name defines the block name
  20866. */
  20867. constructor(name: string);
  20868. /**
  20869. * Gets the current class name
  20870. * @returns the class name
  20871. */
  20872. getClassName(): string;
  20873. /**
  20874. * Gets the uv input component
  20875. */
  20876. get uv(): NodeMaterialConnectionPoint;
  20877. /**
  20878. * Gets the rgba output component
  20879. */
  20880. get rgba(): NodeMaterialConnectionPoint;
  20881. /**
  20882. * Gets the rgb output component
  20883. */
  20884. get rgb(): NodeMaterialConnectionPoint;
  20885. /**
  20886. * Gets the r output component
  20887. */
  20888. get r(): NodeMaterialConnectionPoint;
  20889. /**
  20890. * Gets the g output component
  20891. */
  20892. get g(): NodeMaterialConnectionPoint;
  20893. /**
  20894. * Gets the b output component
  20895. */
  20896. get b(): NodeMaterialConnectionPoint;
  20897. /**
  20898. * Gets the a output component
  20899. */
  20900. get a(): NodeMaterialConnectionPoint;
  20901. /**
  20902. * Initialize the block and prepare the context for build
  20903. * @param state defines the state that will be used for the build
  20904. */
  20905. initialize(state: NodeMaterialBuildState): void;
  20906. get target(): NodeMaterialBlockTargets;
  20907. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20908. isReady(): boolean;
  20909. private _injectVertexCode;
  20910. private _writeTextureRead;
  20911. private _writeOutput;
  20912. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20913. serialize(): any;
  20914. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20915. }
  20916. }
  20917. declare module BABYLON {
  20918. /**
  20919. * Base block used for the particle texture
  20920. */
  20921. export class ParticleTextureBlock extends NodeMaterialBlock {
  20922. private _samplerName;
  20923. private _linearDefineName;
  20924. private _gammaDefineName;
  20925. private _tempTextureRead;
  20926. /**
  20927. * Gets or sets the texture associated with the node
  20928. */
  20929. texture: Nullable<BaseTexture>;
  20930. /**
  20931. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20932. */
  20933. convertToGammaSpace: boolean;
  20934. /**
  20935. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20936. */
  20937. convertToLinearSpace: boolean;
  20938. /**
  20939. * Create a new ParticleTextureBlock
  20940. * @param name defines the block name
  20941. */
  20942. constructor(name: string);
  20943. /**
  20944. * Gets the current class name
  20945. * @returns the class name
  20946. */
  20947. getClassName(): string;
  20948. /**
  20949. * Gets the uv input component
  20950. */
  20951. get uv(): NodeMaterialConnectionPoint;
  20952. /**
  20953. * Gets the rgba output component
  20954. */
  20955. get rgba(): NodeMaterialConnectionPoint;
  20956. /**
  20957. * Gets the rgb output component
  20958. */
  20959. get rgb(): NodeMaterialConnectionPoint;
  20960. /**
  20961. * Gets the r output component
  20962. */
  20963. get r(): NodeMaterialConnectionPoint;
  20964. /**
  20965. * Gets the g output component
  20966. */
  20967. get g(): NodeMaterialConnectionPoint;
  20968. /**
  20969. * Gets the b output component
  20970. */
  20971. get b(): NodeMaterialConnectionPoint;
  20972. /**
  20973. * Gets the a output component
  20974. */
  20975. get a(): NodeMaterialConnectionPoint;
  20976. /**
  20977. * Initialize the block and prepare the context for build
  20978. * @param state defines the state that will be used for the build
  20979. */
  20980. initialize(state: NodeMaterialBuildState): void;
  20981. autoConfigure(material: NodeMaterial): void;
  20982. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20983. isReady(): boolean;
  20984. private _writeOutput;
  20985. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20986. serialize(): any;
  20987. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20988. }
  20989. }
  20990. declare module BABYLON {
  20991. /**
  20992. * Class used to store shared data between 2 NodeMaterialBuildState
  20993. */
  20994. export class NodeMaterialBuildStateSharedData {
  20995. /**
  20996. * Gets the list of emitted varyings
  20997. */
  20998. temps: string[];
  20999. /**
  21000. * Gets the list of emitted varyings
  21001. */
  21002. varyings: string[];
  21003. /**
  21004. * Gets the varying declaration string
  21005. */
  21006. varyingDeclaration: string;
  21007. /**
  21008. * Input blocks
  21009. */
  21010. inputBlocks: InputBlock[];
  21011. /**
  21012. * Input blocks
  21013. */
  21014. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21015. /**
  21016. * Bindable blocks (Blocks that need to set data to the effect)
  21017. */
  21018. bindableBlocks: NodeMaterialBlock[];
  21019. /**
  21020. * List of blocks that can provide a compilation fallback
  21021. */
  21022. blocksWithFallbacks: NodeMaterialBlock[];
  21023. /**
  21024. * List of blocks that can provide a define update
  21025. */
  21026. blocksWithDefines: NodeMaterialBlock[];
  21027. /**
  21028. * List of blocks that can provide a repeatable content
  21029. */
  21030. repeatableContentBlocks: NodeMaterialBlock[];
  21031. /**
  21032. * List of blocks that can provide a dynamic list of uniforms
  21033. */
  21034. dynamicUniformBlocks: NodeMaterialBlock[];
  21035. /**
  21036. * List of blocks that can block the isReady function for the material
  21037. */
  21038. blockingBlocks: NodeMaterialBlock[];
  21039. /**
  21040. * Gets the list of animated inputs
  21041. */
  21042. animatedInputs: InputBlock[];
  21043. /**
  21044. * Build Id used to avoid multiple recompilations
  21045. */
  21046. buildId: number;
  21047. /** List of emitted variables */
  21048. variableNames: {
  21049. [key: string]: number;
  21050. };
  21051. /** List of emitted defines */
  21052. defineNames: {
  21053. [key: string]: number;
  21054. };
  21055. /** Should emit comments? */
  21056. emitComments: boolean;
  21057. /** Emit build activity */
  21058. verbose: boolean;
  21059. /** Gets or sets the hosting scene */
  21060. scene: Scene;
  21061. /**
  21062. * Gets the compilation hints emitted at compilation time
  21063. */
  21064. hints: {
  21065. needWorldViewMatrix: boolean;
  21066. needWorldViewProjectionMatrix: boolean;
  21067. needAlphaBlending: boolean;
  21068. needAlphaTesting: boolean;
  21069. };
  21070. /**
  21071. * List of compilation checks
  21072. */
  21073. checks: {
  21074. emitVertex: boolean;
  21075. emitFragment: boolean;
  21076. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21077. };
  21078. /**
  21079. * Is vertex program allowed to be empty?
  21080. */
  21081. allowEmptyVertexProgram: boolean;
  21082. /** Creates a new shared data */
  21083. constructor();
  21084. /**
  21085. * Emits console errors and exceptions if there is a failing check
  21086. */
  21087. emitErrors(): void;
  21088. }
  21089. }
  21090. declare module BABYLON {
  21091. /**
  21092. * Class used to store node based material build state
  21093. */
  21094. export class NodeMaterialBuildState {
  21095. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21096. supportUniformBuffers: boolean;
  21097. /**
  21098. * Gets the list of emitted attributes
  21099. */
  21100. attributes: string[];
  21101. /**
  21102. * Gets the list of emitted uniforms
  21103. */
  21104. uniforms: string[];
  21105. /**
  21106. * Gets the list of emitted constants
  21107. */
  21108. constants: string[];
  21109. /**
  21110. * Gets the list of emitted samplers
  21111. */
  21112. samplers: string[];
  21113. /**
  21114. * Gets the list of emitted functions
  21115. */
  21116. functions: {
  21117. [key: string]: string;
  21118. };
  21119. /**
  21120. * Gets the list of emitted extensions
  21121. */
  21122. extensions: {
  21123. [key: string]: string;
  21124. };
  21125. /**
  21126. * Gets the target of the compilation state
  21127. */
  21128. target: NodeMaterialBlockTargets;
  21129. /**
  21130. * Gets the list of emitted counters
  21131. */
  21132. counters: {
  21133. [key: string]: number;
  21134. };
  21135. /**
  21136. * Shared data between multiple NodeMaterialBuildState instances
  21137. */
  21138. sharedData: NodeMaterialBuildStateSharedData;
  21139. /** @hidden */
  21140. _vertexState: NodeMaterialBuildState;
  21141. /** @hidden */
  21142. _attributeDeclaration: string;
  21143. /** @hidden */
  21144. _uniformDeclaration: string;
  21145. /** @hidden */
  21146. _constantDeclaration: string;
  21147. /** @hidden */
  21148. _samplerDeclaration: string;
  21149. /** @hidden */
  21150. _varyingTransfer: string;
  21151. /** @hidden */
  21152. _injectAtEnd: string;
  21153. private _repeatableContentAnchorIndex;
  21154. /** @hidden */
  21155. _builtCompilationString: string;
  21156. /**
  21157. * Gets the emitted compilation strings
  21158. */
  21159. compilationString: string;
  21160. /**
  21161. * Finalize the compilation strings
  21162. * @param state defines the current compilation state
  21163. */
  21164. finalize(state: NodeMaterialBuildState): void;
  21165. /** @hidden */
  21166. get _repeatableContentAnchor(): string;
  21167. /** @hidden */
  21168. _getFreeVariableName(prefix: string): string;
  21169. /** @hidden */
  21170. _getFreeDefineName(prefix: string): string;
  21171. /** @hidden */
  21172. _excludeVariableName(name: string): void;
  21173. /** @hidden */
  21174. _emit2DSampler(name: string): void;
  21175. /** @hidden */
  21176. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21177. /** @hidden */
  21178. _emitExtension(name: string, extension: string, define?: string): void;
  21179. /** @hidden */
  21180. _emitFunction(name: string, code: string, comments: string): void;
  21181. /** @hidden */
  21182. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21183. replaceStrings?: {
  21184. search: RegExp;
  21185. replace: string;
  21186. }[];
  21187. repeatKey?: string;
  21188. }): string;
  21189. /** @hidden */
  21190. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21191. repeatKey?: string;
  21192. removeAttributes?: boolean;
  21193. removeUniforms?: boolean;
  21194. removeVaryings?: boolean;
  21195. removeIfDef?: boolean;
  21196. replaceStrings?: {
  21197. search: RegExp;
  21198. replace: string;
  21199. }[];
  21200. }, storeKey?: string): void;
  21201. /** @hidden */
  21202. _registerTempVariable(name: string): boolean;
  21203. /** @hidden */
  21204. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21205. /** @hidden */
  21206. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21207. /** @hidden */
  21208. _emitFloat(value: number): string;
  21209. }
  21210. }
  21211. declare module BABYLON {
  21212. /**
  21213. * Helper class used to generate session unique ID
  21214. */
  21215. export class UniqueIdGenerator {
  21216. private static _UniqueIdCounter;
  21217. /**
  21218. * Gets an unique (relatively to the current scene) Id
  21219. */
  21220. static get UniqueId(): number;
  21221. }
  21222. }
  21223. declare module BABYLON {
  21224. /**
  21225. * Defines a block that can be used inside a node based material
  21226. */
  21227. export class NodeMaterialBlock {
  21228. private _buildId;
  21229. private _buildTarget;
  21230. private _target;
  21231. private _isFinalMerger;
  21232. private _isInput;
  21233. protected _isUnique: boolean;
  21234. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21235. inputsAreExclusive: boolean;
  21236. /** @hidden */
  21237. _codeVariableName: string;
  21238. /** @hidden */
  21239. _inputs: NodeMaterialConnectionPoint[];
  21240. /** @hidden */
  21241. _outputs: NodeMaterialConnectionPoint[];
  21242. /** @hidden */
  21243. _preparationId: number;
  21244. /**
  21245. * Gets or sets the name of the block
  21246. */
  21247. name: string;
  21248. /**
  21249. * Gets or sets the unique id of the node
  21250. */
  21251. uniqueId: number;
  21252. /**
  21253. * Gets or sets the comments associated with this block
  21254. */
  21255. comments: string;
  21256. /**
  21257. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21258. */
  21259. get isUnique(): boolean;
  21260. /**
  21261. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21262. */
  21263. get isFinalMerger(): boolean;
  21264. /**
  21265. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21266. */
  21267. get isInput(): boolean;
  21268. /**
  21269. * Gets or sets the build Id
  21270. */
  21271. get buildId(): number;
  21272. set buildId(value: number);
  21273. /**
  21274. * Gets or sets the target of the block
  21275. */
  21276. get target(): NodeMaterialBlockTargets;
  21277. set target(value: NodeMaterialBlockTargets);
  21278. /**
  21279. * Gets the list of input points
  21280. */
  21281. get inputs(): NodeMaterialConnectionPoint[];
  21282. /** Gets the list of output points */
  21283. get outputs(): NodeMaterialConnectionPoint[];
  21284. /**
  21285. * Find an input by its name
  21286. * @param name defines the name of the input to look for
  21287. * @returns the input or null if not found
  21288. */
  21289. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21290. /**
  21291. * Find an output by its name
  21292. * @param name defines the name of the outputto look for
  21293. * @returns the output or null if not found
  21294. */
  21295. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21296. /**
  21297. * Creates a new NodeMaterialBlock
  21298. * @param name defines the block name
  21299. * @param target defines the target of that block (Vertex by default)
  21300. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21301. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21302. */
  21303. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21304. /**
  21305. * Initialize the block and prepare the context for build
  21306. * @param state defines the state that will be used for the build
  21307. */
  21308. initialize(state: NodeMaterialBuildState): void;
  21309. /**
  21310. * Bind data to effect. Will only be called for blocks with isBindable === true
  21311. * @param effect defines the effect to bind data to
  21312. * @param nodeMaterial defines the hosting NodeMaterial
  21313. * @param mesh defines the mesh that will be rendered
  21314. * @param subMesh defines the submesh that will be rendered
  21315. */
  21316. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21317. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21318. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21319. protected _writeFloat(value: number): string;
  21320. /**
  21321. * Gets the current class name e.g. "NodeMaterialBlock"
  21322. * @returns the class name
  21323. */
  21324. getClassName(): string;
  21325. /**
  21326. * Register a new input. Must be called inside a block constructor
  21327. * @param name defines the connection point name
  21328. * @param type defines the connection point type
  21329. * @param isOptional defines a boolean indicating that this input can be omitted
  21330. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21331. * @param point an already created connection point. If not provided, create a new one
  21332. * @returns the current block
  21333. */
  21334. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21335. /**
  21336. * Register a new output. Must be called inside a block constructor
  21337. * @param name defines the connection point name
  21338. * @param type defines the connection point type
  21339. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21340. * @param point an already created connection point. If not provided, create a new one
  21341. * @returns the current block
  21342. */
  21343. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21344. /**
  21345. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21346. * @param forOutput defines an optional connection point to check compatibility with
  21347. * @returns the first available input or null
  21348. */
  21349. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21350. /**
  21351. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21352. * @param forBlock defines an optional block to check compatibility with
  21353. * @returns the first available input or null
  21354. */
  21355. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21356. /**
  21357. * Gets the sibling of the given output
  21358. * @param current defines the current output
  21359. * @returns the next output in the list or null
  21360. */
  21361. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21362. /**
  21363. * Connect current block with another block
  21364. * @param other defines the block to connect with
  21365. * @param options define the various options to help pick the right connections
  21366. * @returns the current block
  21367. */
  21368. connectTo(other: NodeMaterialBlock, options?: {
  21369. input?: string;
  21370. output?: string;
  21371. outputSwizzle?: string;
  21372. }): this | undefined;
  21373. protected _buildBlock(state: NodeMaterialBuildState): void;
  21374. /**
  21375. * Add uniforms, samplers and uniform buffers at compilation time
  21376. * @param state defines the state to update
  21377. * @param nodeMaterial defines the node material requesting the update
  21378. * @param defines defines the material defines to update
  21379. * @param uniformBuffers defines the list of uniform buffer names
  21380. */
  21381. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21382. /**
  21383. * Add potential fallbacks if shader compilation fails
  21384. * @param mesh defines the mesh to be rendered
  21385. * @param fallbacks defines the current prioritized list of fallbacks
  21386. */
  21387. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21388. /**
  21389. * Initialize defines for shader compilation
  21390. * @param mesh defines the mesh to be rendered
  21391. * @param nodeMaterial defines the node material requesting the update
  21392. * @param defines defines the material defines to update
  21393. * @param useInstances specifies that instances should be used
  21394. */
  21395. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21396. /**
  21397. * Update defines for shader compilation
  21398. * @param mesh defines the mesh to be rendered
  21399. * @param nodeMaterial defines the node material requesting the update
  21400. * @param defines defines the material defines to update
  21401. * @param useInstances specifies that instances should be used
  21402. * @param subMesh defines which submesh to render
  21403. */
  21404. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21405. /**
  21406. * Lets the block try to connect some inputs automatically
  21407. * @param material defines the hosting NodeMaterial
  21408. */
  21409. autoConfigure(material: NodeMaterial): void;
  21410. /**
  21411. * Function called when a block is declared as repeatable content generator
  21412. * @param vertexShaderState defines the current compilation state for the vertex shader
  21413. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21414. * @param mesh defines the mesh to be rendered
  21415. * @param defines defines the material defines to update
  21416. */
  21417. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21418. /**
  21419. * Checks if the block is ready
  21420. * @param mesh defines the mesh to be rendered
  21421. * @param nodeMaterial defines the node material requesting the update
  21422. * @param defines defines the material defines to update
  21423. * @param useInstances specifies that instances should be used
  21424. * @returns true if the block is ready
  21425. */
  21426. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21427. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21428. private _processBuild;
  21429. /**
  21430. * Compile the current node and generate the shader code
  21431. * @param state defines the current compilation state (uniforms, samplers, current string)
  21432. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21433. * @returns true if already built
  21434. */
  21435. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21436. protected _inputRename(name: string): string;
  21437. protected _outputRename(name: string): string;
  21438. protected _dumpPropertiesCode(): string;
  21439. /** @hidden */
  21440. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21441. /** @hidden */
  21442. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21443. /**
  21444. * Clone the current block to a new identical block
  21445. * @param scene defines the hosting scene
  21446. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21447. * @returns a copy of the current block
  21448. */
  21449. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21450. /**
  21451. * Serializes this block in a JSON representation
  21452. * @returns the serialized block object
  21453. */
  21454. serialize(): any;
  21455. /** @hidden */
  21456. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21457. private _deserializePortDisplayNamesAndExposedOnFrame;
  21458. /**
  21459. * Release resources
  21460. */
  21461. dispose(): void;
  21462. }
  21463. }
  21464. declare module BABYLON {
  21465. /**
  21466. * Base class of materials working in push mode in babylon JS
  21467. * @hidden
  21468. */
  21469. export class PushMaterial extends Material {
  21470. protected _activeEffect: Effect;
  21471. protected _normalMatrix: Matrix;
  21472. constructor(name: string, scene: Scene);
  21473. getEffect(): Effect;
  21474. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21475. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21476. /**
  21477. * Binds the given world matrix to the active effect
  21478. *
  21479. * @param world the matrix to bind
  21480. */
  21481. bindOnlyWorldMatrix(world: Matrix): void;
  21482. /**
  21483. * Binds the given normal matrix to the active effect
  21484. *
  21485. * @param normalMatrix the matrix to bind
  21486. */
  21487. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21488. bind(world: Matrix, mesh?: Mesh): void;
  21489. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21490. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21491. }
  21492. }
  21493. declare module BABYLON {
  21494. /**
  21495. * Root class for all node material optimizers
  21496. */
  21497. export class NodeMaterialOptimizer {
  21498. /**
  21499. * Function used to optimize a NodeMaterial graph
  21500. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21501. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21502. */
  21503. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21504. }
  21505. }
  21506. declare module BABYLON {
  21507. /**
  21508. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21509. */
  21510. export class TransformBlock extends NodeMaterialBlock {
  21511. /**
  21512. * Defines the value to use to complement W value to transform it to a Vector4
  21513. */
  21514. complementW: number;
  21515. /**
  21516. * Defines the value to use to complement z value to transform it to a Vector4
  21517. */
  21518. complementZ: number;
  21519. /**
  21520. * Creates a new TransformBlock
  21521. * @param name defines the block name
  21522. */
  21523. constructor(name: string);
  21524. /**
  21525. * Gets the current class name
  21526. * @returns the class name
  21527. */
  21528. getClassName(): string;
  21529. /**
  21530. * Gets the vector input
  21531. */
  21532. get vector(): NodeMaterialConnectionPoint;
  21533. /**
  21534. * Gets the output component
  21535. */
  21536. get output(): NodeMaterialConnectionPoint;
  21537. /**
  21538. * Gets the xyz output component
  21539. */
  21540. get xyz(): NodeMaterialConnectionPoint;
  21541. /**
  21542. * Gets the matrix transform input
  21543. */
  21544. get transform(): NodeMaterialConnectionPoint;
  21545. protected _buildBlock(state: NodeMaterialBuildState): this;
  21546. /**
  21547. * Update defines for shader compilation
  21548. * @param mesh defines the mesh to be rendered
  21549. * @param nodeMaterial defines the node material requesting the update
  21550. * @param defines defines the material defines to update
  21551. * @param useInstances specifies that instances should be used
  21552. * @param subMesh defines which submesh to render
  21553. */
  21554. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21555. serialize(): any;
  21556. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21557. protected _dumpPropertiesCode(): string;
  21558. }
  21559. }
  21560. declare module BABYLON {
  21561. /**
  21562. * Block used to output the vertex position
  21563. */
  21564. export class VertexOutputBlock extends NodeMaterialBlock {
  21565. /**
  21566. * Creates a new VertexOutputBlock
  21567. * @param name defines the block name
  21568. */
  21569. constructor(name: string);
  21570. /**
  21571. * Gets the current class name
  21572. * @returns the class name
  21573. */
  21574. getClassName(): string;
  21575. /**
  21576. * Gets the vector input component
  21577. */
  21578. get vector(): NodeMaterialConnectionPoint;
  21579. protected _buildBlock(state: NodeMaterialBuildState): this;
  21580. }
  21581. }
  21582. declare module BABYLON {
  21583. /**
  21584. * Block used to output the final color
  21585. */
  21586. export class FragmentOutputBlock extends NodeMaterialBlock {
  21587. /**
  21588. * Create a new FragmentOutputBlock
  21589. * @param name defines the block name
  21590. */
  21591. constructor(name: string);
  21592. /**
  21593. * Gets the current class name
  21594. * @returns the class name
  21595. */
  21596. getClassName(): string;
  21597. /**
  21598. * Gets the rgba input component
  21599. */
  21600. get rgba(): NodeMaterialConnectionPoint;
  21601. /**
  21602. * Gets the rgb input component
  21603. */
  21604. get rgb(): NodeMaterialConnectionPoint;
  21605. /**
  21606. * Gets the a input component
  21607. */
  21608. get a(): NodeMaterialConnectionPoint;
  21609. protected _buildBlock(state: NodeMaterialBuildState): this;
  21610. }
  21611. }
  21612. declare module BABYLON {
  21613. /**
  21614. * Block used for the particle ramp gradient section
  21615. */
  21616. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  21617. /**
  21618. * Create a new ParticleRampGradientBlock
  21619. * @param name defines the block name
  21620. */
  21621. constructor(name: string);
  21622. /**
  21623. * Gets the current class name
  21624. * @returns the class name
  21625. */
  21626. getClassName(): string;
  21627. /**
  21628. * Gets the color input component
  21629. */
  21630. get color(): NodeMaterialConnectionPoint;
  21631. /**
  21632. * Gets the rampColor output component
  21633. */
  21634. get rampColor(): NodeMaterialConnectionPoint;
  21635. /**
  21636. * Initialize the block and prepare the context for build
  21637. * @param state defines the state that will be used for the build
  21638. */
  21639. initialize(state: NodeMaterialBuildState): void;
  21640. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21641. }
  21642. }
  21643. declare module BABYLON {
  21644. /**
  21645. * Block used for the particle blend multiply section
  21646. */
  21647. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  21648. /**
  21649. * Create a new ParticleBlendMultiplyBlock
  21650. * @param name defines the block name
  21651. */
  21652. constructor(name: string);
  21653. /**
  21654. * Gets the current class name
  21655. * @returns the class name
  21656. */
  21657. getClassName(): string;
  21658. /**
  21659. * Gets the color input component
  21660. */
  21661. get color(): NodeMaterialConnectionPoint;
  21662. /**
  21663. * Gets the alphaTexture input component
  21664. */
  21665. get alphaTexture(): NodeMaterialConnectionPoint;
  21666. /**
  21667. * Gets the alphaColor input component
  21668. */
  21669. get alphaColor(): NodeMaterialConnectionPoint;
  21670. /**
  21671. * Gets the blendColor output component
  21672. */
  21673. get blendColor(): NodeMaterialConnectionPoint;
  21674. /**
  21675. * Initialize the block and prepare the context for build
  21676. * @param state defines the state that will be used for the build
  21677. */
  21678. initialize(state: NodeMaterialBuildState): void;
  21679. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21680. }
  21681. }
  21682. declare module BABYLON {
  21683. /**
  21684. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  21685. */
  21686. export class VectorMergerBlock extends NodeMaterialBlock {
  21687. /**
  21688. * Create a new VectorMergerBlock
  21689. * @param name defines the block name
  21690. */
  21691. constructor(name: string);
  21692. /**
  21693. * Gets the current class name
  21694. * @returns the class name
  21695. */
  21696. getClassName(): string;
  21697. /**
  21698. * Gets the xyz component (input)
  21699. */
  21700. get xyzIn(): NodeMaterialConnectionPoint;
  21701. /**
  21702. * Gets the xy component (input)
  21703. */
  21704. get xyIn(): NodeMaterialConnectionPoint;
  21705. /**
  21706. * Gets the x component (input)
  21707. */
  21708. get x(): NodeMaterialConnectionPoint;
  21709. /**
  21710. * Gets the y component (input)
  21711. */
  21712. get y(): NodeMaterialConnectionPoint;
  21713. /**
  21714. * Gets the z component (input)
  21715. */
  21716. get z(): NodeMaterialConnectionPoint;
  21717. /**
  21718. * Gets the w component (input)
  21719. */
  21720. get w(): NodeMaterialConnectionPoint;
  21721. /**
  21722. * Gets the xyzw component (output)
  21723. */
  21724. get xyzw(): NodeMaterialConnectionPoint;
  21725. /**
  21726. * Gets the xyz component (output)
  21727. */
  21728. get xyzOut(): NodeMaterialConnectionPoint;
  21729. /**
  21730. * Gets the xy component (output)
  21731. */
  21732. get xyOut(): NodeMaterialConnectionPoint;
  21733. /**
  21734. * Gets the xy component (output)
  21735. * @deprecated Please use xyOut instead.
  21736. */
  21737. get xy(): NodeMaterialConnectionPoint;
  21738. /**
  21739. * Gets the xyz component (output)
  21740. * @deprecated Please use xyzOut instead.
  21741. */
  21742. get xyz(): NodeMaterialConnectionPoint;
  21743. protected _buildBlock(state: NodeMaterialBuildState): this;
  21744. }
  21745. }
  21746. declare module BABYLON {
  21747. /**
  21748. * Block used to remap a float from a range to a new one
  21749. */
  21750. export class RemapBlock extends NodeMaterialBlock {
  21751. /**
  21752. * Gets or sets the source range
  21753. */
  21754. sourceRange: Vector2;
  21755. /**
  21756. * Gets or sets the target range
  21757. */
  21758. targetRange: Vector2;
  21759. /**
  21760. * Creates a new RemapBlock
  21761. * @param name defines the block name
  21762. */
  21763. constructor(name: string);
  21764. /**
  21765. * Gets the current class name
  21766. * @returns the class name
  21767. */
  21768. getClassName(): string;
  21769. /**
  21770. * Gets the input component
  21771. */
  21772. get input(): NodeMaterialConnectionPoint;
  21773. /**
  21774. * Gets the source min input component
  21775. */
  21776. get sourceMin(): NodeMaterialConnectionPoint;
  21777. /**
  21778. * Gets the source max input component
  21779. */
  21780. get sourceMax(): NodeMaterialConnectionPoint;
  21781. /**
  21782. * Gets the target min input component
  21783. */
  21784. get targetMin(): NodeMaterialConnectionPoint;
  21785. /**
  21786. * Gets the target max input component
  21787. */
  21788. get targetMax(): NodeMaterialConnectionPoint;
  21789. /**
  21790. * Gets the output component
  21791. */
  21792. get output(): NodeMaterialConnectionPoint;
  21793. protected _buildBlock(state: NodeMaterialBuildState): this;
  21794. protected _dumpPropertiesCode(): string;
  21795. serialize(): any;
  21796. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21797. }
  21798. }
  21799. declare module BABYLON {
  21800. /**
  21801. * Block used to multiply 2 values
  21802. */
  21803. export class MultiplyBlock extends NodeMaterialBlock {
  21804. /**
  21805. * Creates a new MultiplyBlock
  21806. * @param name defines the block name
  21807. */
  21808. constructor(name: string);
  21809. /**
  21810. * Gets the current class name
  21811. * @returns the class name
  21812. */
  21813. getClassName(): string;
  21814. /**
  21815. * Gets the left operand input component
  21816. */
  21817. get left(): NodeMaterialConnectionPoint;
  21818. /**
  21819. * Gets the right operand input component
  21820. */
  21821. get right(): NodeMaterialConnectionPoint;
  21822. /**
  21823. * Gets the output component
  21824. */
  21825. get output(): NodeMaterialConnectionPoint;
  21826. protected _buildBlock(state: NodeMaterialBuildState): this;
  21827. }
  21828. }
  21829. declare module BABYLON {
  21830. /**
  21831. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  21832. */
  21833. export class ColorSplitterBlock extends NodeMaterialBlock {
  21834. /**
  21835. * Create a new ColorSplitterBlock
  21836. * @param name defines the block name
  21837. */
  21838. constructor(name: string);
  21839. /**
  21840. * Gets the current class name
  21841. * @returns the class name
  21842. */
  21843. getClassName(): string;
  21844. /**
  21845. * Gets the rgba component (input)
  21846. */
  21847. get rgba(): NodeMaterialConnectionPoint;
  21848. /**
  21849. * Gets the rgb component (input)
  21850. */
  21851. get rgbIn(): NodeMaterialConnectionPoint;
  21852. /**
  21853. * Gets the rgb component (output)
  21854. */
  21855. get rgbOut(): NodeMaterialConnectionPoint;
  21856. /**
  21857. * Gets the r component (output)
  21858. */
  21859. get r(): NodeMaterialConnectionPoint;
  21860. /**
  21861. * Gets the g component (output)
  21862. */
  21863. get g(): NodeMaterialConnectionPoint;
  21864. /**
  21865. * Gets the b component (output)
  21866. */
  21867. get b(): NodeMaterialConnectionPoint;
  21868. /**
  21869. * Gets the a component (output)
  21870. */
  21871. get a(): NodeMaterialConnectionPoint;
  21872. protected _inputRename(name: string): string;
  21873. protected _outputRename(name: string): string;
  21874. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21875. }
  21876. }
  21877. declare module BABYLON {
  21878. /**
  21879. * Interface used to configure the node material editor
  21880. */
  21881. export interface INodeMaterialEditorOptions {
  21882. /** Define the URl to load node editor script */
  21883. editorURL?: string;
  21884. }
  21885. /** @hidden */
  21886. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  21887. NORMAL: boolean;
  21888. TANGENT: boolean;
  21889. UV1: boolean;
  21890. /** BONES */
  21891. NUM_BONE_INFLUENCERS: number;
  21892. BonesPerMesh: number;
  21893. BONETEXTURE: boolean;
  21894. /** MORPH TARGETS */
  21895. MORPHTARGETS: boolean;
  21896. MORPHTARGETS_NORMAL: boolean;
  21897. MORPHTARGETS_TANGENT: boolean;
  21898. MORPHTARGETS_UV: boolean;
  21899. NUM_MORPH_INFLUENCERS: number;
  21900. /** IMAGE PROCESSING */
  21901. IMAGEPROCESSING: boolean;
  21902. VIGNETTE: boolean;
  21903. VIGNETTEBLENDMODEMULTIPLY: boolean;
  21904. VIGNETTEBLENDMODEOPAQUE: boolean;
  21905. TONEMAPPING: boolean;
  21906. TONEMAPPING_ACES: boolean;
  21907. CONTRAST: boolean;
  21908. EXPOSURE: boolean;
  21909. COLORCURVES: boolean;
  21910. COLORGRADING: boolean;
  21911. COLORGRADING3D: boolean;
  21912. SAMPLER3DGREENDEPTH: boolean;
  21913. SAMPLER3DBGRMAP: boolean;
  21914. IMAGEPROCESSINGPOSTPROCESS: boolean;
  21915. /** MISC. */
  21916. BUMPDIRECTUV: number;
  21917. constructor();
  21918. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  21919. }
  21920. /**
  21921. * Class used to configure NodeMaterial
  21922. */
  21923. export interface INodeMaterialOptions {
  21924. /**
  21925. * Defines if blocks should emit comments
  21926. */
  21927. emitComments: boolean;
  21928. }
  21929. /**
  21930. * Class used to create a node based material built by assembling shader blocks
  21931. */
  21932. export class NodeMaterial extends PushMaterial {
  21933. private static _BuildIdGenerator;
  21934. private _options;
  21935. private _vertexCompilationState;
  21936. private _fragmentCompilationState;
  21937. private _sharedData;
  21938. private _buildId;
  21939. private _buildWasSuccessful;
  21940. private _cachedWorldViewMatrix;
  21941. private _cachedWorldViewProjectionMatrix;
  21942. private _optimizers;
  21943. private _animationFrame;
  21944. /** Define the Url to load node editor script */
  21945. static EditorURL: string;
  21946. /** Define the Url to load snippets */
  21947. static SnippetUrl: string;
  21948. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  21949. static IgnoreTexturesAtLoadTime: boolean;
  21950. private BJSNODEMATERIALEDITOR;
  21951. /** Get the inspector from bundle or global */
  21952. private _getGlobalNodeMaterialEditor;
  21953. /**
  21954. * Snippet ID if the material was created from the snippet server
  21955. */
  21956. snippetId: string;
  21957. /**
  21958. * Gets or sets data used by visual editor
  21959. * @see https://nme.babylonjs.com
  21960. */
  21961. editorData: any;
  21962. /**
  21963. * 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)
  21964. */
  21965. ignoreAlpha: boolean;
  21966. /**
  21967. * Defines the maximum number of lights that can be used in the material
  21968. */
  21969. maxSimultaneousLights: number;
  21970. /**
  21971. * Observable raised when the material is built
  21972. */
  21973. onBuildObservable: Observable<NodeMaterial>;
  21974. /**
  21975. * Gets or sets the root nodes of the material vertex shader
  21976. */
  21977. _vertexOutputNodes: NodeMaterialBlock[];
  21978. /**
  21979. * Gets or sets the root nodes of the material fragment (pixel) shader
  21980. */
  21981. _fragmentOutputNodes: NodeMaterialBlock[];
  21982. /** Gets or sets options to control the node material overall behavior */
  21983. get options(): INodeMaterialOptions;
  21984. set options(options: INodeMaterialOptions);
  21985. /**
  21986. * Default configuration related to image processing available in the standard Material.
  21987. */
  21988. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  21989. /**
  21990. * Gets the image processing configuration used either in this material.
  21991. */
  21992. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  21993. /**
  21994. * Sets the Default image processing configuration used either in the this material.
  21995. *
  21996. * If sets to null, the scene one is in use.
  21997. */
  21998. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  21999. /**
  22000. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22001. */
  22002. attachedBlocks: NodeMaterialBlock[];
  22003. /**
  22004. * Specifies the mode of the node material
  22005. * @hidden
  22006. */
  22007. _mode: NodeMaterialModes;
  22008. /**
  22009. * Gets the mode property
  22010. */
  22011. get mode(): NodeMaterialModes;
  22012. /**
  22013. * Create a new node based material
  22014. * @param name defines the material name
  22015. * @param scene defines the hosting scene
  22016. * @param options defines creation option
  22017. */
  22018. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22019. /**
  22020. * Gets the current class name of the material e.g. "NodeMaterial"
  22021. * @returns the class name
  22022. */
  22023. getClassName(): string;
  22024. /**
  22025. * Keep track of the image processing observer to allow dispose and replace.
  22026. */
  22027. private _imageProcessingObserver;
  22028. /**
  22029. * Attaches a new image processing configuration to the Standard Material.
  22030. * @param configuration
  22031. */
  22032. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22033. /**
  22034. * Get a block by its name
  22035. * @param name defines the name of the block to retrieve
  22036. * @returns the required block or null if not found
  22037. */
  22038. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22039. /**
  22040. * Get a block by its name
  22041. * @param predicate defines the predicate used to find the good candidate
  22042. * @returns the required block or null if not found
  22043. */
  22044. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22045. /**
  22046. * Get an input block by its name
  22047. * @param predicate defines the predicate used to find the good candidate
  22048. * @returns the required input block or null if not found
  22049. */
  22050. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22051. /**
  22052. * Gets the list of input blocks attached to this material
  22053. * @returns an array of InputBlocks
  22054. */
  22055. getInputBlocks(): InputBlock[];
  22056. /**
  22057. * Adds a new optimizer to the list of optimizers
  22058. * @param optimizer defines the optimizers to add
  22059. * @returns the current material
  22060. */
  22061. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22062. /**
  22063. * Remove an optimizer from the list of optimizers
  22064. * @param optimizer defines the optimizers to remove
  22065. * @returns the current material
  22066. */
  22067. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22068. /**
  22069. * Add a new block to the list of output nodes
  22070. * @param node defines the node to add
  22071. * @returns the current material
  22072. */
  22073. addOutputNode(node: NodeMaterialBlock): this;
  22074. /**
  22075. * Remove a block from the list of root nodes
  22076. * @param node defines the node to remove
  22077. * @returns the current material
  22078. */
  22079. removeOutputNode(node: NodeMaterialBlock): this;
  22080. private _addVertexOutputNode;
  22081. private _removeVertexOutputNode;
  22082. private _addFragmentOutputNode;
  22083. private _removeFragmentOutputNode;
  22084. /**
  22085. * Specifies if the material will require alpha blending
  22086. * @returns a boolean specifying if alpha blending is needed
  22087. */
  22088. needAlphaBlending(): boolean;
  22089. /**
  22090. * Specifies if this material should be rendered in alpha test mode
  22091. * @returns a boolean specifying if an alpha test is needed.
  22092. */
  22093. needAlphaTesting(): boolean;
  22094. private _initializeBlock;
  22095. private _resetDualBlocks;
  22096. /**
  22097. * Remove a block from the current node material
  22098. * @param block defines the block to remove
  22099. */
  22100. removeBlock(block: NodeMaterialBlock): void;
  22101. /**
  22102. * Build the material and generates the inner effect
  22103. * @param verbose defines if the build should log activity
  22104. */
  22105. build(verbose?: boolean): void;
  22106. /**
  22107. * Runs an otpimization phase to try to improve the shader code
  22108. */
  22109. optimize(): void;
  22110. private _prepareDefinesForAttributes;
  22111. /**
  22112. * Create a post process from the material
  22113. * @param camera The camera to apply the render pass to.
  22114. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22115. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22116. * @param engine The engine which the post process will be applied. (default: current engine)
  22117. * @param reusable If the post process can be reused on the same frame. (default: false)
  22118. * @param textureType Type of textures used when performing the post process. (default: 0)
  22119. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22120. * @returns the post process created
  22121. */
  22122. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22123. /**
  22124. * Create the post process effect from the material
  22125. * @param postProcess The post process to create the effect for
  22126. */
  22127. createEffectForPostProcess(postProcess: PostProcess): void;
  22128. private _createEffectOrPostProcess;
  22129. private _createEffectForParticles;
  22130. /**
  22131. * Create the effect to be used as the custom effect for a particle system
  22132. * @param particleSystem Particle system to create the effect for
  22133. * @param onCompiled defines a function to call when the effect creation is successful
  22134. * @param onError defines a function to call when the effect creation has failed
  22135. */
  22136. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22137. private _processDefines;
  22138. /**
  22139. * Get if the submesh is ready to be used and all its information available.
  22140. * Child classes can use it to update shaders
  22141. * @param mesh defines the mesh to check
  22142. * @param subMesh defines which submesh to check
  22143. * @param useInstances specifies that instances should be used
  22144. * @returns a boolean indicating that the submesh is ready or not
  22145. */
  22146. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22147. /**
  22148. * Get a string representing the shaders built by the current node graph
  22149. */
  22150. get compiledShaders(): string;
  22151. /**
  22152. * Binds the world matrix to the material
  22153. * @param world defines the world transformation matrix
  22154. */
  22155. bindOnlyWorldMatrix(world: Matrix): void;
  22156. /**
  22157. * Binds the submesh to this material by preparing the effect and shader to draw
  22158. * @param world defines the world transformation matrix
  22159. * @param mesh defines the mesh containing the submesh
  22160. * @param subMesh defines the submesh to bind the material to
  22161. */
  22162. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22163. /**
  22164. * Gets the active textures from the material
  22165. * @returns an array of textures
  22166. */
  22167. getActiveTextures(): BaseTexture[];
  22168. /**
  22169. * Gets the list of texture blocks
  22170. * @returns an array of texture blocks
  22171. */
  22172. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22173. /**
  22174. * Specifies if the material uses a texture
  22175. * @param texture defines the texture to check against the material
  22176. * @returns a boolean specifying if the material uses the texture
  22177. */
  22178. hasTexture(texture: BaseTexture): boolean;
  22179. /**
  22180. * Disposes the material
  22181. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22182. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22183. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22184. */
  22185. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22186. /** Creates the node editor window. */
  22187. private _createNodeEditor;
  22188. /**
  22189. * Launch the node material editor
  22190. * @param config Define the configuration of the editor
  22191. * @return a promise fulfilled when the node editor is visible
  22192. */
  22193. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22194. /**
  22195. * Clear the current material
  22196. */
  22197. clear(): void;
  22198. /**
  22199. * Clear the current material and set it to a default state
  22200. */
  22201. setToDefault(): void;
  22202. /**
  22203. * Clear the current material and set it to a default state for post process
  22204. */
  22205. setToDefaultPostProcess(): void;
  22206. /**
  22207. * Clear the current material and set it to a default state for particle
  22208. */
  22209. setToDefaultParticle(): void;
  22210. /**
  22211. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22212. * @param url defines the url to load from
  22213. * @returns a promise that will fullfil when the material is fully loaded
  22214. */
  22215. loadAsync(url: string): Promise<void>;
  22216. private _gatherBlocks;
  22217. /**
  22218. * Generate a string containing the code declaration required to create an equivalent of this material
  22219. * @returns a string
  22220. */
  22221. generateCode(): string;
  22222. /**
  22223. * Serializes this material in a JSON representation
  22224. * @returns the serialized material object
  22225. */
  22226. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22227. private _restoreConnections;
  22228. /**
  22229. * Clear the current graph and load a new one from a serialization object
  22230. * @param source defines the JSON representation of the material
  22231. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22232. * @param merge defines whether or not the source must be merged or replace the current content
  22233. */
  22234. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  22235. /**
  22236. * Makes a duplicate of the current material.
  22237. * @param name - name to use for the new material.
  22238. */
  22239. clone(name: string): NodeMaterial;
  22240. /**
  22241. * Creates a node material from parsed material data
  22242. * @param source defines the JSON representation of the material
  22243. * @param scene defines the hosting scene
  22244. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22245. * @returns a new node material
  22246. */
  22247. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22248. /**
  22249. * Creates a node material from a snippet saved in a remote file
  22250. * @param name defines the name of the material to create
  22251. * @param url defines the url to load from
  22252. * @param scene defines the hosting scene
  22253. * @returns a promise that will resolve to the new node material
  22254. */
  22255. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22256. /**
  22257. * Creates a node material from a snippet saved by the node material editor
  22258. * @param snippetId defines the snippet to load
  22259. * @param scene defines the hosting scene
  22260. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22261. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22262. * @returns a promise that will resolve to the new node material
  22263. */
  22264. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22265. /**
  22266. * Creates a new node material set to default basic configuration
  22267. * @param name defines the name of the material
  22268. * @param scene defines the hosting scene
  22269. * @returns a new NodeMaterial
  22270. */
  22271. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22272. }
  22273. }
  22274. declare module BABYLON {
  22275. /**
  22276. * Size options for a post process
  22277. */
  22278. export type PostProcessOptions = {
  22279. width: number;
  22280. height: number;
  22281. };
  22282. /**
  22283. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22284. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22285. */
  22286. export class PostProcess {
  22287. /** Name of the PostProcess. */
  22288. name: string;
  22289. /**
  22290. * Gets or sets the unique id of the post process
  22291. */
  22292. uniqueId: number;
  22293. /**
  22294. * Width of the texture to apply the post process on
  22295. */
  22296. width: number;
  22297. /**
  22298. * Height of the texture to apply the post process on
  22299. */
  22300. height: number;
  22301. /**
  22302. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22303. */
  22304. nodeMaterialSource: Nullable<NodeMaterial>;
  22305. /**
  22306. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22307. * @hidden
  22308. */
  22309. _outputTexture: Nullable<InternalTexture>;
  22310. /**
  22311. * Sampling mode used by the shader
  22312. * See https://doc.babylonjs.com/classes/3.1/texture
  22313. */
  22314. renderTargetSamplingMode: number;
  22315. /**
  22316. * Clear color to use when screen clearing
  22317. */
  22318. clearColor: Color4;
  22319. /**
  22320. * If the buffer needs to be cleared before applying the post process. (default: true)
  22321. * Should be set to false if shader will overwrite all previous pixels.
  22322. */
  22323. autoClear: boolean;
  22324. /**
  22325. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22326. */
  22327. alphaMode: number;
  22328. /**
  22329. * Sets the setAlphaBlendConstants of the babylon engine
  22330. */
  22331. alphaConstants: Color4;
  22332. /**
  22333. * Animations to be used for the post processing
  22334. */
  22335. animations: Animation[];
  22336. /**
  22337. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22338. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22339. */
  22340. enablePixelPerfectMode: boolean;
  22341. /**
  22342. * Force the postprocess to be applied without taking in account viewport
  22343. */
  22344. forceFullscreenViewport: boolean;
  22345. /**
  22346. * List of inspectable custom properties (used by the Inspector)
  22347. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22348. */
  22349. inspectableCustomProperties: IInspectable[];
  22350. /**
  22351. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22352. *
  22353. * | Value | Type | Description |
  22354. * | ----- | ----------------------------------- | ----------- |
  22355. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22356. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22357. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22358. *
  22359. */
  22360. scaleMode: number;
  22361. /**
  22362. * Force textures to be a power of two (default: false)
  22363. */
  22364. alwaysForcePOT: boolean;
  22365. private _samples;
  22366. /**
  22367. * Number of sample textures (default: 1)
  22368. */
  22369. get samples(): number;
  22370. set samples(n: number);
  22371. /**
  22372. * Modify the scale of the post process to be the same as the viewport (default: false)
  22373. */
  22374. adaptScaleToCurrentViewport: boolean;
  22375. private _camera;
  22376. private _scene;
  22377. private _engine;
  22378. private _options;
  22379. private _reusable;
  22380. private _textureType;
  22381. private _textureFormat;
  22382. /**
  22383. * Smart array of input and output textures for the post process.
  22384. * @hidden
  22385. */
  22386. _textures: SmartArray<InternalTexture>;
  22387. /**
  22388. * The index in _textures that corresponds to the output texture.
  22389. * @hidden
  22390. */
  22391. _currentRenderTextureInd: number;
  22392. private _effect;
  22393. private _samplers;
  22394. private _fragmentUrl;
  22395. private _vertexUrl;
  22396. private _parameters;
  22397. private _scaleRatio;
  22398. protected _indexParameters: any;
  22399. private _shareOutputWithPostProcess;
  22400. private _texelSize;
  22401. private _forcedOutputTexture;
  22402. /**
  22403. * Returns the fragment url or shader name used in the post process.
  22404. * @returns the fragment url or name in the shader store.
  22405. */
  22406. getEffectName(): string;
  22407. /**
  22408. * An event triggered when the postprocess is activated.
  22409. */
  22410. onActivateObservable: Observable<Camera>;
  22411. private _onActivateObserver;
  22412. /**
  22413. * A function that is added to the onActivateObservable
  22414. */
  22415. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22416. /**
  22417. * An event triggered when the postprocess changes its size.
  22418. */
  22419. onSizeChangedObservable: Observable<PostProcess>;
  22420. private _onSizeChangedObserver;
  22421. /**
  22422. * A function that is added to the onSizeChangedObservable
  22423. */
  22424. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22425. /**
  22426. * An event triggered when the postprocess applies its effect.
  22427. */
  22428. onApplyObservable: Observable<Effect>;
  22429. private _onApplyObserver;
  22430. /**
  22431. * A function that is added to the onApplyObservable
  22432. */
  22433. set onApply(callback: (effect: Effect) => void);
  22434. /**
  22435. * An event triggered before rendering the postprocess
  22436. */
  22437. onBeforeRenderObservable: Observable<Effect>;
  22438. private _onBeforeRenderObserver;
  22439. /**
  22440. * A function that is added to the onBeforeRenderObservable
  22441. */
  22442. set onBeforeRender(callback: (effect: Effect) => void);
  22443. /**
  22444. * An event triggered after rendering the postprocess
  22445. */
  22446. onAfterRenderObservable: Observable<Effect>;
  22447. private _onAfterRenderObserver;
  22448. /**
  22449. * A function that is added to the onAfterRenderObservable
  22450. */
  22451. set onAfterRender(callback: (efect: Effect) => void);
  22452. /**
  22453. * 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
  22454. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22455. */
  22456. get inputTexture(): InternalTexture;
  22457. set inputTexture(value: InternalTexture);
  22458. /**
  22459. * Gets the camera which post process is applied to.
  22460. * @returns The camera the post process is applied to.
  22461. */
  22462. getCamera(): Camera;
  22463. /**
  22464. * Gets the texel size of the postprocess.
  22465. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22466. */
  22467. get texelSize(): Vector2;
  22468. /**
  22469. * Creates a new instance PostProcess
  22470. * @param name The name of the PostProcess.
  22471. * @param fragmentUrl The url of the fragment shader to be used.
  22472. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22473. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22474. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22475. * @param camera The camera to apply the render pass to.
  22476. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22477. * @param engine The engine which the post process will be applied. (default: current engine)
  22478. * @param reusable If the post process can be reused on the same frame. (default: false)
  22479. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22480. * @param textureType Type of textures used when performing the post process. (default: 0)
  22481. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22482. * @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
  22483. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  22484. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22485. */
  22486. constructor(
  22487. /** Name of the PostProcess. */
  22488. 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);
  22489. /**
  22490. * Gets a string idenfifying the name of the class
  22491. * @returns "PostProcess" string
  22492. */
  22493. getClassName(): string;
  22494. /**
  22495. * Gets the engine which this post process belongs to.
  22496. * @returns The engine the post process was enabled with.
  22497. */
  22498. getEngine(): Engine;
  22499. /**
  22500. * The effect that is created when initializing the post process.
  22501. * @returns The created effect corresponding the the postprocess.
  22502. */
  22503. getEffect(): Effect;
  22504. /**
  22505. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22506. * @param postProcess The post process to share the output with.
  22507. * @returns This post process.
  22508. */
  22509. shareOutputWith(postProcess: PostProcess): PostProcess;
  22510. /**
  22511. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22512. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22513. */
  22514. useOwnOutput(): void;
  22515. /**
  22516. * Updates the effect with the current post process compile time values and recompiles the shader.
  22517. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22518. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22519. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22520. * @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
  22521. * @param onCompiled Called when the shader has been compiled.
  22522. * @param onError Called if there is an error when compiling a shader.
  22523. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22524. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22525. */
  22526. 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;
  22527. /**
  22528. * The post process is reusable if it can be used multiple times within one frame.
  22529. * @returns If the post process is reusable
  22530. */
  22531. isReusable(): boolean;
  22532. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22533. markTextureDirty(): void;
  22534. /**
  22535. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22536. * 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.
  22537. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22538. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22539. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22540. * @returns The target texture that was bound to be written to.
  22541. */
  22542. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22543. /**
  22544. * If the post process is supported.
  22545. */
  22546. get isSupported(): boolean;
  22547. /**
  22548. * The aspect ratio of the output texture.
  22549. */
  22550. get aspectRatio(): number;
  22551. /**
  22552. * Get a value indicating if the post-process is ready to be used
  22553. * @returns true if the post-process is ready (shader is compiled)
  22554. */
  22555. isReady(): boolean;
  22556. /**
  22557. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22558. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22559. */
  22560. apply(): Nullable<Effect>;
  22561. private _disposeTextures;
  22562. /**
  22563. * Disposes the post process.
  22564. * @param camera The camera to dispose the post process on.
  22565. */
  22566. dispose(camera?: Camera): void;
  22567. }
  22568. }
  22569. declare module BABYLON {
  22570. /** @hidden */
  22571. export var kernelBlurVaryingDeclaration: {
  22572. name: string;
  22573. shader: string;
  22574. };
  22575. }
  22576. declare module BABYLON {
  22577. /** @hidden */
  22578. export var kernelBlurFragment: {
  22579. name: string;
  22580. shader: string;
  22581. };
  22582. }
  22583. declare module BABYLON {
  22584. /** @hidden */
  22585. export var kernelBlurFragment2: {
  22586. name: string;
  22587. shader: string;
  22588. };
  22589. }
  22590. declare module BABYLON {
  22591. /** @hidden */
  22592. export var kernelBlurPixelShader: {
  22593. name: string;
  22594. shader: string;
  22595. };
  22596. }
  22597. declare module BABYLON {
  22598. /** @hidden */
  22599. export var kernelBlurVertex: {
  22600. name: string;
  22601. shader: string;
  22602. };
  22603. }
  22604. declare module BABYLON {
  22605. /** @hidden */
  22606. export var kernelBlurVertexShader: {
  22607. name: string;
  22608. shader: string;
  22609. };
  22610. }
  22611. declare module BABYLON {
  22612. /**
  22613. * The Blur Post Process which blurs an image based on a kernel and direction.
  22614. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22615. */
  22616. export class BlurPostProcess extends PostProcess {
  22617. /** The direction in which to blur the image. */
  22618. direction: Vector2;
  22619. private blockCompilation;
  22620. protected _kernel: number;
  22621. protected _idealKernel: number;
  22622. protected _packedFloat: boolean;
  22623. private _staticDefines;
  22624. /**
  22625. * Sets the length in pixels of the blur sample region
  22626. */
  22627. set kernel(v: number);
  22628. /**
  22629. * Gets the length in pixels of the blur sample region
  22630. */
  22631. get kernel(): number;
  22632. /**
  22633. * Sets wether or not the blur needs to unpack/repack floats
  22634. */
  22635. set packedFloat(v: boolean);
  22636. /**
  22637. * Gets wether or not the blur is unpacking/repacking floats
  22638. */
  22639. get packedFloat(): boolean;
  22640. /**
  22641. * Creates a new instance BlurPostProcess
  22642. * @param name The name of the effect.
  22643. * @param direction The direction in which to blur the image.
  22644. * @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.
  22645. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22646. * @param camera The camera to apply the render pass to.
  22647. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22648. * @param engine The engine which the post process will be applied. (default: current engine)
  22649. * @param reusable If the post process can be reused on the same frame. (default: false)
  22650. * @param textureType Type of textures used when performing the post process. (default: 0)
  22651. * @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)
  22652. */
  22653. constructor(name: string,
  22654. /** The direction in which to blur the image. */
  22655. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  22656. /**
  22657. * Updates the effect with the current post process compile time values and recompiles the shader.
  22658. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22659. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22660. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22661. * @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
  22662. * @param onCompiled Called when the shader has been compiled.
  22663. * @param onError Called if there is an error when compiling a shader.
  22664. */
  22665. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22666. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22667. /**
  22668. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  22669. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  22670. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  22671. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  22672. * The gaps between physical kernels are compensated for in the weighting of the samples
  22673. * @param idealKernel Ideal blur kernel.
  22674. * @return Nearest best kernel.
  22675. */
  22676. protected _nearestBestKernel(idealKernel: number): number;
  22677. /**
  22678. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  22679. * @param x The point on the Gaussian distribution to sample.
  22680. * @return the value of the Gaussian function at x.
  22681. */
  22682. protected _gaussianWeight(x: number): number;
  22683. /**
  22684. * Generates a string that can be used as a floating point number in GLSL.
  22685. * @param x Value to print.
  22686. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  22687. * @return GLSL float string.
  22688. */
  22689. protected _glslFloat(x: number, decimalFigures?: number): string;
  22690. }
  22691. }
  22692. declare module BABYLON {
  22693. /**
  22694. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22695. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22696. * You can then easily use it as a reflectionTexture on a flat surface.
  22697. * In case the surface is not a plane, please consider relying on reflection probes.
  22698. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22699. */
  22700. export class MirrorTexture extends RenderTargetTexture {
  22701. private scene;
  22702. /**
  22703. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  22704. * 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.
  22705. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22706. */
  22707. mirrorPlane: Plane;
  22708. /**
  22709. * Define the blur ratio used to blur the reflection if needed.
  22710. */
  22711. set blurRatio(value: number);
  22712. get blurRatio(): number;
  22713. /**
  22714. * Define the adaptive blur kernel used to blur the reflection if needed.
  22715. * This will autocompute the closest best match for the `blurKernel`
  22716. */
  22717. set adaptiveBlurKernel(value: number);
  22718. /**
  22719. * Define the blur kernel used to blur the reflection if needed.
  22720. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22721. */
  22722. set blurKernel(value: number);
  22723. /**
  22724. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  22725. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22726. */
  22727. set blurKernelX(value: number);
  22728. get blurKernelX(): number;
  22729. /**
  22730. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  22731. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22732. */
  22733. set blurKernelY(value: number);
  22734. get blurKernelY(): number;
  22735. private _autoComputeBlurKernel;
  22736. protected _onRatioRescale(): void;
  22737. private _updateGammaSpace;
  22738. private _imageProcessingConfigChangeObserver;
  22739. private _transformMatrix;
  22740. private _mirrorMatrix;
  22741. private _savedViewMatrix;
  22742. private _blurX;
  22743. private _blurY;
  22744. private _adaptiveBlurKernel;
  22745. private _blurKernelX;
  22746. private _blurKernelY;
  22747. private _blurRatio;
  22748. /**
  22749. * Instantiates a Mirror Texture.
  22750. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22751. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22752. * You can then easily use it as a reflectionTexture on a flat surface.
  22753. * In case the surface is not a plane, please consider relying on reflection probes.
  22754. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22755. * @param name
  22756. * @param size
  22757. * @param scene
  22758. * @param generateMipMaps
  22759. * @param type
  22760. * @param samplingMode
  22761. * @param generateDepthBuffer
  22762. */
  22763. constructor(name: string, size: number | {
  22764. width: number;
  22765. height: number;
  22766. } | {
  22767. ratio: number;
  22768. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  22769. private _preparePostProcesses;
  22770. /**
  22771. * Clone the mirror texture.
  22772. * @returns the cloned texture
  22773. */
  22774. clone(): MirrorTexture;
  22775. /**
  22776. * Serialize the texture to a JSON representation you could use in Parse later on
  22777. * @returns the serialized JSON representation
  22778. */
  22779. serialize(): any;
  22780. /**
  22781. * Dispose the texture and release its associated resources.
  22782. */
  22783. dispose(): void;
  22784. }
  22785. }
  22786. declare module BABYLON {
  22787. /**
  22788. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  22789. * @see http://doc.babylonjs.com/babylon101/materials#texture
  22790. */
  22791. export class Texture extends BaseTexture {
  22792. /**
  22793. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  22794. */
  22795. static SerializeBuffers: boolean;
  22796. /** @hidden */
  22797. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  22798. /** @hidden */
  22799. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  22800. /** @hidden */
  22801. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  22802. /** nearest is mag = nearest and min = nearest and mip = linear */
  22803. static readonly NEAREST_SAMPLINGMODE: number;
  22804. /** nearest is mag = nearest and min = nearest and mip = linear */
  22805. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  22806. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22807. static readonly BILINEAR_SAMPLINGMODE: number;
  22808. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22809. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  22810. /** Trilinear is mag = linear and min = linear and mip = linear */
  22811. static readonly TRILINEAR_SAMPLINGMODE: number;
  22812. /** Trilinear is mag = linear and min = linear and mip = linear */
  22813. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  22814. /** mag = nearest and min = nearest and mip = nearest */
  22815. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  22816. /** mag = nearest and min = linear and mip = nearest */
  22817. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  22818. /** mag = nearest and min = linear and mip = linear */
  22819. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  22820. /** mag = nearest and min = linear and mip = none */
  22821. static readonly NEAREST_LINEAR: number;
  22822. /** mag = nearest and min = nearest and mip = none */
  22823. static readonly NEAREST_NEAREST: number;
  22824. /** mag = linear and min = nearest and mip = nearest */
  22825. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  22826. /** mag = linear and min = nearest and mip = linear */
  22827. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  22828. /** mag = linear and min = linear and mip = none */
  22829. static readonly LINEAR_LINEAR: number;
  22830. /** mag = linear and min = nearest and mip = none */
  22831. static readonly LINEAR_NEAREST: number;
  22832. /** Explicit coordinates mode */
  22833. static readonly EXPLICIT_MODE: number;
  22834. /** Spherical coordinates mode */
  22835. static readonly SPHERICAL_MODE: number;
  22836. /** Planar coordinates mode */
  22837. static readonly PLANAR_MODE: number;
  22838. /** Cubic coordinates mode */
  22839. static readonly CUBIC_MODE: number;
  22840. /** Projection coordinates mode */
  22841. static readonly PROJECTION_MODE: number;
  22842. /** Inverse Cubic coordinates mode */
  22843. static readonly SKYBOX_MODE: number;
  22844. /** Inverse Cubic coordinates mode */
  22845. static readonly INVCUBIC_MODE: number;
  22846. /** Equirectangular coordinates mode */
  22847. static readonly EQUIRECTANGULAR_MODE: number;
  22848. /** Equirectangular Fixed coordinates mode */
  22849. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  22850. /** Equirectangular Fixed Mirrored coordinates mode */
  22851. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  22852. /** Texture is not repeating outside of 0..1 UVs */
  22853. static readonly CLAMP_ADDRESSMODE: number;
  22854. /** Texture is repeating outside of 0..1 UVs */
  22855. static readonly WRAP_ADDRESSMODE: number;
  22856. /** Texture is repeating and mirrored */
  22857. static readonly MIRROR_ADDRESSMODE: number;
  22858. /**
  22859. * 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
  22860. */
  22861. static UseSerializedUrlIfAny: boolean;
  22862. /**
  22863. * Define the url of the texture.
  22864. */
  22865. url: Nullable<string>;
  22866. /**
  22867. * Define an offset on the texture to offset the u coordinates of the UVs
  22868. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  22869. */
  22870. uOffset: number;
  22871. /**
  22872. * Define an offset on the texture to offset the v coordinates of the UVs
  22873. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  22874. */
  22875. vOffset: number;
  22876. /**
  22877. * Define an offset on the texture to scale the u coordinates of the UVs
  22878. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  22879. */
  22880. uScale: number;
  22881. /**
  22882. * Define an offset on the texture to scale the v coordinates of the UVs
  22883. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  22884. */
  22885. vScale: number;
  22886. /**
  22887. * Define an offset on the texture to rotate around the u coordinates of the UVs
  22888. * @see http://doc.babylonjs.com/how_to/more_materials
  22889. */
  22890. uAng: number;
  22891. /**
  22892. * Define an offset on the texture to rotate around the v coordinates of the UVs
  22893. * @see http://doc.babylonjs.com/how_to/more_materials
  22894. */
  22895. vAng: number;
  22896. /**
  22897. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  22898. * @see http://doc.babylonjs.com/how_to/more_materials
  22899. */
  22900. wAng: number;
  22901. /**
  22902. * Defines the center of rotation (U)
  22903. */
  22904. uRotationCenter: number;
  22905. /**
  22906. * Defines the center of rotation (V)
  22907. */
  22908. vRotationCenter: number;
  22909. /**
  22910. * Defines the center of rotation (W)
  22911. */
  22912. wRotationCenter: number;
  22913. /**
  22914. * Are mip maps generated for this texture or not.
  22915. */
  22916. get noMipmap(): boolean;
  22917. /**
  22918. * List of inspectable custom properties (used by the Inspector)
  22919. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22920. */
  22921. inspectableCustomProperties: Nullable<IInspectable[]>;
  22922. private _noMipmap;
  22923. /** @hidden */
  22924. _invertY: boolean;
  22925. private _rowGenerationMatrix;
  22926. private _cachedTextureMatrix;
  22927. private _projectionModeMatrix;
  22928. private _t0;
  22929. private _t1;
  22930. private _t2;
  22931. private _cachedUOffset;
  22932. private _cachedVOffset;
  22933. private _cachedUScale;
  22934. private _cachedVScale;
  22935. private _cachedUAng;
  22936. private _cachedVAng;
  22937. private _cachedWAng;
  22938. private _cachedProjectionMatrixId;
  22939. private _cachedCoordinatesMode;
  22940. /** @hidden */
  22941. protected _initialSamplingMode: number;
  22942. /** @hidden */
  22943. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  22944. private _deleteBuffer;
  22945. protected _format: Nullable<number>;
  22946. private _delayedOnLoad;
  22947. private _delayedOnError;
  22948. private _mimeType?;
  22949. /**
  22950. * Observable triggered once the texture has been loaded.
  22951. */
  22952. onLoadObservable: Observable<Texture>;
  22953. protected _isBlocking: boolean;
  22954. /**
  22955. * Is the texture preventing material to render while loading.
  22956. * If false, a default texture will be used instead of the loading one during the preparation step.
  22957. */
  22958. set isBlocking(value: boolean);
  22959. get isBlocking(): boolean;
  22960. /**
  22961. * Get the current sampling mode associated with the texture.
  22962. */
  22963. get samplingMode(): number;
  22964. /**
  22965. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  22966. */
  22967. get invertY(): boolean;
  22968. /**
  22969. * Instantiates a new texture.
  22970. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  22971. * @see http://doc.babylonjs.com/babylon101/materials#texture
  22972. * @param url defines the url of the picture to load as a texture
  22973. * @param sceneOrEngine defines the scene or engine the texture will belong to
  22974. * @param noMipmap defines if the texture will require mip maps or not
  22975. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  22976. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  22977. * @param onLoad defines a callback triggered when the texture has been loaded
  22978. * @param onError defines a callback triggered when an error occurred during the loading session
  22979. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  22980. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  22981. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  22982. * @param mimeType defines an optional mime type information
  22983. */
  22984. 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);
  22985. /**
  22986. * Update the url (and optional buffer) of this texture if url was null during construction.
  22987. * @param url the url of the texture
  22988. * @param buffer the buffer of the texture (defaults to null)
  22989. * @param onLoad callback called when the texture is loaded (defaults to null)
  22990. */
  22991. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  22992. /**
  22993. * Finish the loading sequence of a texture flagged as delayed load.
  22994. * @hidden
  22995. */
  22996. delayLoad(): void;
  22997. private _prepareRowForTextureGeneration;
  22998. /**
  22999. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23000. * @returns the transform matrix of the texture.
  23001. */
  23002. getTextureMatrix(uBase?: number): Matrix;
  23003. /**
  23004. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23005. * @returns The reflection texture transform
  23006. */
  23007. getReflectionTextureMatrix(): Matrix;
  23008. /**
  23009. * Clones the texture.
  23010. * @returns the cloned texture
  23011. */
  23012. clone(): Texture;
  23013. /**
  23014. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23015. * @returns The JSON representation of the texture
  23016. */
  23017. serialize(): any;
  23018. /**
  23019. * Get the current class name of the texture useful for serialization or dynamic coding.
  23020. * @returns "Texture"
  23021. */
  23022. getClassName(): string;
  23023. /**
  23024. * Dispose the texture and release its associated resources.
  23025. */
  23026. dispose(): void;
  23027. /**
  23028. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23029. * @param parsedTexture Define the JSON representation of the texture
  23030. * @param scene Define the scene the parsed texture should be instantiated in
  23031. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23032. * @returns The parsed texture if successful
  23033. */
  23034. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23035. /**
  23036. * Creates a texture from its base 64 representation.
  23037. * @param data Define the base64 payload without the data: prefix
  23038. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23039. * @param scene Define the scene the texture should belong to
  23040. * @param noMipmap Forces the texture to not create mip map information if true
  23041. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23042. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23043. * @param onLoad define a callback triggered when the texture has been loaded
  23044. * @param onError define a callback triggered when an error occurred during the loading session
  23045. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23046. * @returns the created texture
  23047. */
  23048. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23049. /**
  23050. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23051. * @param data Define the base64 payload without the data: prefix
  23052. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23053. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23054. * @param scene Define the scene the texture should belong to
  23055. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23056. * @param noMipmap Forces the texture to not create mip map information if true
  23057. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23058. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23059. * @param onLoad define a callback triggered when the texture has been loaded
  23060. * @param onError define a callback triggered when an error occurred during the loading session
  23061. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23062. * @returns the created texture
  23063. */
  23064. 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;
  23065. }
  23066. }
  23067. declare module BABYLON {
  23068. /**
  23069. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23070. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23071. */
  23072. export class PostProcessManager {
  23073. private _scene;
  23074. private _indexBuffer;
  23075. private _vertexBuffers;
  23076. /**
  23077. * Creates a new instance PostProcess
  23078. * @param scene The scene that the post process is associated with.
  23079. */
  23080. constructor(scene: Scene);
  23081. private _prepareBuffers;
  23082. private _buildIndexBuffer;
  23083. /**
  23084. * Rebuilds the vertex buffers of the manager.
  23085. * @hidden
  23086. */
  23087. _rebuild(): void;
  23088. /**
  23089. * Prepares a frame to be run through a post process.
  23090. * @param sourceTexture The input texture to the post procesess. (default: null)
  23091. * @param postProcesses An array of post processes to be run. (default: null)
  23092. * @returns True if the post processes were able to be run.
  23093. * @hidden
  23094. */
  23095. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23096. /**
  23097. * Manually render a set of post processes to a texture.
  23098. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23099. * @param postProcesses An array of post processes to be run.
  23100. * @param targetTexture The target texture to render to.
  23101. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23102. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23103. * @param lodLevel defines which lod of the texture to render to
  23104. */
  23105. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  23106. /**
  23107. * Finalize the result of the output of the postprocesses.
  23108. * @param doNotPresent If true the result will not be displayed to the screen.
  23109. * @param targetTexture The target texture to render to.
  23110. * @param faceIndex The index of the face to bind the target texture to.
  23111. * @param postProcesses The array of post processes to render.
  23112. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23113. * @hidden
  23114. */
  23115. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23116. /**
  23117. * Disposes of the post process manager.
  23118. */
  23119. dispose(): void;
  23120. }
  23121. }
  23122. declare module BABYLON {
  23123. /**
  23124. * This Helps creating a texture that will be created from a camera in your scene.
  23125. * It is basically a dynamic texture that could be used to create special effects for instance.
  23126. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23127. */
  23128. export class RenderTargetTexture extends Texture {
  23129. isCube: boolean;
  23130. /**
  23131. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23132. */
  23133. static readonly REFRESHRATE_RENDER_ONCE: number;
  23134. /**
  23135. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23136. */
  23137. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23138. /**
  23139. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23140. * the central point of your effect and can save a lot of performances.
  23141. */
  23142. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23143. /**
  23144. * Use this predicate to dynamically define the list of mesh you want to render.
  23145. * If set, the renderList property will be overwritten.
  23146. */
  23147. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23148. private _renderList;
  23149. /**
  23150. * Use this list to define the list of mesh you want to render.
  23151. */
  23152. get renderList(): Nullable<Array<AbstractMesh>>;
  23153. set renderList(value: Nullable<Array<AbstractMesh>>);
  23154. /**
  23155. * Use this function to overload the renderList array at rendering time.
  23156. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23157. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23158. * the cube (if the RTT is a cube, else layerOrFace=0).
  23159. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23160. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23161. * hold dummy elements!
  23162. */
  23163. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23164. private _hookArray;
  23165. /**
  23166. * Define if particles should be rendered in your texture.
  23167. */
  23168. renderParticles: boolean;
  23169. /**
  23170. * Define if sprites should be rendered in your texture.
  23171. */
  23172. renderSprites: boolean;
  23173. /**
  23174. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  23175. */
  23176. coordinatesMode: number;
  23177. /**
  23178. * Define the camera used to render the texture.
  23179. */
  23180. activeCamera: Nullable<Camera>;
  23181. /**
  23182. * Override the mesh isReady function with your own one.
  23183. */
  23184. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  23185. /**
  23186. * Override the render function of the texture with your own one.
  23187. */
  23188. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  23189. /**
  23190. * Define if camera post processes should be use while rendering the texture.
  23191. */
  23192. useCameraPostProcesses: boolean;
  23193. /**
  23194. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  23195. */
  23196. ignoreCameraViewport: boolean;
  23197. private _postProcessManager;
  23198. private _postProcesses;
  23199. private _resizeObserver;
  23200. /**
  23201. * An event triggered when the texture is unbind.
  23202. */
  23203. onBeforeBindObservable: Observable<RenderTargetTexture>;
  23204. /**
  23205. * An event triggered when the texture is unbind.
  23206. */
  23207. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  23208. private _onAfterUnbindObserver;
  23209. /**
  23210. * Set a after unbind callback in the texture.
  23211. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  23212. */
  23213. set onAfterUnbind(callback: () => void);
  23214. /**
  23215. * An event triggered before rendering the texture
  23216. */
  23217. onBeforeRenderObservable: Observable<number>;
  23218. private _onBeforeRenderObserver;
  23219. /**
  23220. * Set a before render callback in the texture.
  23221. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  23222. */
  23223. set onBeforeRender(callback: (faceIndex: number) => void);
  23224. /**
  23225. * An event triggered after rendering the texture
  23226. */
  23227. onAfterRenderObservable: Observable<number>;
  23228. private _onAfterRenderObserver;
  23229. /**
  23230. * Set a after render callback in the texture.
  23231. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  23232. */
  23233. set onAfterRender(callback: (faceIndex: number) => void);
  23234. /**
  23235. * An event triggered after the texture clear
  23236. */
  23237. onClearObservable: Observable<Engine>;
  23238. private _onClearObserver;
  23239. /**
  23240. * Set a clear callback in the texture.
  23241. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  23242. */
  23243. set onClear(callback: (Engine: Engine) => void);
  23244. /**
  23245. * An event triggered when the texture is resized.
  23246. */
  23247. onResizeObservable: Observable<RenderTargetTexture>;
  23248. /**
  23249. * Define the clear color of the Render Target if it should be different from the scene.
  23250. */
  23251. clearColor: Color4;
  23252. protected _size: number | {
  23253. width: number;
  23254. height: number;
  23255. layers?: number;
  23256. };
  23257. protected _initialSizeParameter: number | {
  23258. width: number;
  23259. height: number;
  23260. } | {
  23261. ratio: number;
  23262. };
  23263. protected _sizeRatio: Nullable<number>;
  23264. /** @hidden */
  23265. _generateMipMaps: boolean;
  23266. protected _renderingManager: RenderingManager;
  23267. /** @hidden */
  23268. _waitingRenderList: string[];
  23269. protected _doNotChangeAspectRatio: boolean;
  23270. protected _currentRefreshId: number;
  23271. protected _refreshRate: number;
  23272. protected _textureMatrix: Matrix;
  23273. protected _samples: number;
  23274. protected _renderTargetOptions: RenderTargetCreationOptions;
  23275. /**
  23276. * Gets render target creation options that were used.
  23277. */
  23278. get renderTargetOptions(): RenderTargetCreationOptions;
  23279. protected _onRatioRescale(): void;
  23280. /**
  23281. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  23282. * It must define where the camera used to render the texture is set
  23283. */
  23284. boundingBoxPosition: Vector3;
  23285. private _boundingBoxSize;
  23286. /**
  23287. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  23288. * When defined, the cubemap will switch to local mode
  23289. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  23290. * @example https://www.babylonjs-playground.com/#RNASML
  23291. */
  23292. set boundingBoxSize(value: Vector3);
  23293. get boundingBoxSize(): Vector3;
  23294. /**
  23295. * In case the RTT has been created with a depth texture, get the associated
  23296. * depth texture.
  23297. * Otherwise, return null.
  23298. */
  23299. get depthStencilTexture(): Nullable<InternalTexture>;
  23300. /**
  23301. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  23302. * or used a shadow, depth texture...
  23303. * @param name The friendly name of the texture
  23304. * @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)
  23305. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  23306. * @param generateMipMaps True if mip maps need to be generated after render.
  23307. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  23308. * @param type The type of the buffer in the RTT (int, half float, float...)
  23309. * @param isCube True if a cube texture needs to be created
  23310. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  23311. * @param generateDepthBuffer True to generate a depth buffer
  23312. * @param generateStencilBuffer True to generate a stencil buffer
  23313. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  23314. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  23315. * @param delayAllocation if the texture allocation should be delayed (default: false)
  23316. */
  23317. constructor(name: string, size: number | {
  23318. width: number;
  23319. height: number;
  23320. layers?: number;
  23321. } | {
  23322. ratio: number;
  23323. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  23324. /**
  23325. * Creates a depth stencil texture.
  23326. * This is only available in WebGL 2 or with the depth texture extension available.
  23327. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  23328. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  23329. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  23330. */
  23331. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  23332. private _processSizeParameter;
  23333. /**
  23334. * Define the number of samples to use in case of MSAA.
  23335. * It defaults to one meaning no MSAA has been enabled.
  23336. */
  23337. get samples(): number;
  23338. set samples(value: number);
  23339. /**
  23340. * Resets the refresh counter of the texture and start bak from scratch.
  23341. * Could be useful to regenerate the texture if it is setup to render only once.
  23342. */
  23343. resetRefreshCounter(): void;
  23344. /**
  23345. * Define the refresh rate of the texture or the rendering frequency.
  23346. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  23347. */
  23348. get refreshRate(): number;
  23349. set refreshRate(value: number);
  23350. /**
  23351. * Adds a post process to the render target rendering passes.
  23352. * @param postProcess define the post process to add
  23353. */
  23354. addPostProcess(postProcess: PostProcess): void;
  23355. /**
  23356. * Clear all the post processes attached to the render target
  23357. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  23358. */
  23359. clearPostProcesses(dispose?: boolean): void;
  23360. /**
  23361. * Remove one of the post process from the list of attached post processes to the texture
  23362. * @param postProcess define the post process to remove from the list
  23363. */
  23364. removePostProcess(postProcess: PostProcess): void;
  23365. /** @hidden */
  23366. _shouldRender(): boolean;
  23367. /**
  23368. * Gets the actual render size of the texture.
  23369. * @returns the width of the render size
  23370. */
  23371. getRenderSize(): number;
  23372. /**
  23373. * Gets the actual render width of the texture.
  23374. * @returns the width of the render size
  23375. */
  23376. getRenderWidth(): number;
  23377. /**
  23378. * Gets the actual render height of the texture.
  23379. * @returns the height of the render size
  23380. */
  23381. getRenderHeight(): number;
  23382. /**
  23383. * Gets the actual number of layers of the texture.
  23384. * @returns the number of layers
  23385. */
  23386. getRenderLayers(): number;
  23387. /**
  23388. * Get if the texture can be rescaled or not.
  23389. */
  23390. get canRescale(): boolean;
  23391. /**
  23392. * Resize the texture using a ratio.
  23393. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  23394. */
  23395. scale(ratio: number): void;
  23396. /**
  23397. * Get the texture reflection matrix used to rotate/transform the reflection.
  23398. * @returns the reflection matrix
  23399. */
  23400. getReflectionTextureMatrix(): Matrix;
  23401. /**
  23402. * Resize the texture to a new desired size.
  23403. * Be carrefull as it will recreate all the data in the new texture.
  23404. * @param size Define the new size. It can be:
  23405. * - a number for squared texture,
  23406. * - an object containing { width: number, height: number }
  23407. * - or an object containing a ratio { ratio: number }
  23408. */
  23409. resize(size: number | {
  23410. width: number;
  23411. height: number;
  23412. } | {
  23413. ratio: number;
  23414. }): void;
  23415. private _defaultRenderListPrepared;
  23416. /**
  23417. * Renders all the objects from the render list into the texture.
  23418. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  23419. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  23420. */
  23421. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  23422. private _bestReflectionRenderTargetDimension;
  23423. private _prepareRenderingManager;
  23424. /**
  23425. * @hidden
  23426. * @param faceIndex face index to bind to if this is a cubetexture
  23427. * @param layer defines the index of the texture to bind in the array
  23428. */
  23429. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  23430. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23431. private renderToTarget;
  23432. /**
  23433. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23434. * This allowed control for front to back rendering or reversly depending of the special needs.
  23435. *
  23436. * @param renderingGroupId The rendering group id corresponding to its index
  23437. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23438. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23439. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23440. */
  23441. 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;
  23442. /**
  23443. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23444. *
  23445. * @param renderingGroupId The rendering group id corresponding to its index
  23446. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23447. */
  23448. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23449. /**
  23450. * Clones the texture.
  23451. * @returns the cloned texture
  23452. */
  23453. clone(): RenderTargetTexture;
  23454. /**
  23455. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23456. * @returns The JSON representation of the texture
  23457. */
  23458. serialize(): any;
  23459. /**
  23460. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  23461. */
  23462. disposeFramebufferObjects(): void;
  23463. /**
  23464. * Dispose the texture and release its associated resources.
  23465. */
  23466. dispose(): void;
  23467. /** @hidden */
  23468. _rebuild(): void;
  23469. /**
  23470. * Clear the info related to rendering groups preventing retention point in material dispose.
  23471. */
  23472. freeRenderingGroups(): void;
  23473. /**
  23474. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  23475. * @returns the view count
  23476. */
  23477. getViewCount(): number;
  23478. }
  23479. }
  23480. declare module BABYLON {
  23481. /**
  23482. * Class used to manipulate GUIDs
  23483. */
  23484. export class GUID {
  23485. /**
  23486. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23487. * Be aware Math.random() could cause collisions, but:
  23488. * "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"
  23489. * @returns a pseudo random id
  23490. */
  23491. static RandomId(): string;
  23492. }
  23493. }
  23494. declare module BABYLON {
  23495. /**
  23496. * Options to be used when creating a shadow depth material
  23497. */
  23498. export interface IIOptionShadowDepthMaterial {
  23499. /** Variables in the vertex shader code that need to have their names remapped.
  23500. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  23501. * "var_name" should be either: worldPos or vNormalW
  23502. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  23503. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  23504. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  23505. */
  23506. remappedVariables?: string[];
  23507. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  23508. standalone?: boolean;
  23509. }
  23510. /**
  23511. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  23512. */
  23513. export class ShadowDepthWrapper {
  23514. private _scene;
  23515. private _options?;
  23516. private _baseMaterial;
  23517. private _onEffectCreatedObserver;
  23518. private _subMeshToEffect;
  23519. private _subMeshToDepthEffect;
  23520. private _meshes;
  23521. /** @hidden */
  23522. _matriceNames: any;
  23523. /** Gets the standalone status of the wrapper */
  23524. get standalone(): boolean;
  23525. /** Gets the base material the wrapper is built upon */
  23526. get baseMaterial(): Material;
  23527. /**
  23528. * Instantiate a new shadow depth wrapper.
  23529. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  23530. * generate the shadow depth map. For more information, please refer to the documentation:
  23531. * https://doc.babylonjs.com/babylon101/shadows
  23532. * @param baseMaterial Material to wrap
  23533. * @param scene Define the scene the material belongs to
  23534. * @param options Options used to create the wrapper
  23535. */
  23536. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  23537. /**
  23538. * Gets the effect to use to generate the depth map
  23539. * @param subMesh subMesh to get the effect for
  23540. * @param shadowGenerator shadow generator to get the effect for
  23541. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  23542. */
  23543. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  23544. /**
  23545. * Specifies that the submesh is ready to be used for depth rendering
  23546. * @param subMesh submesh to check
  23547. * @param defines the list of defines to take into account when checking the effect
  23548. * @param shadowGenerator combined with subMesh, it defines the effect to check
  23549. * @param useInstances specifies that instances should be used
  23550. * @returns a boolean indicating that the submesh is ready or not
  23551. */
  23552. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  23553. /**
  23554. * Disposes the resources
  23555. */
  23556. dispose(): void;
  23557. private _makeEffect;
  23558. }
  23559. }
  23560. declare module BABYLON {
  23561. /**
  23562. * Options for compiling materials.
  23563. */
  23564. export interface IMaterialCompilationOptions {
  23565. /**
  23566. * Defines whether clip planes are enabled.
  23567. */
  23568. clipPlane: boolean;
  23569. /**
  23570. * Defines whether instances are enabled.
  23571. */
  23572. useInstances: boolean;
  23573. }
  23574. /**
  23575. * Options passed when calling customShaderNameResolve
  23576. */
  23577. export interface ICustomShaderNameResolveOptions {
  23578. /**
  23579. * 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
  23580. */
  23581. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  23582. }
  23583. /**
  23584. * Base class for the main features of a material in Babylon.js
  23585. */
  23586. export class Material implements IAnimatable {
  23587. /**
  23588. * Returns the triangle fill mode
  23589. */
  23590. static readonly TriangleFillMode: number;
  23591. /**
  23592. * Returns the wireframe mode
  23593. */
  23594. static readonly WireFrameFillMode: number;
  23595. /**
  23596. * Returns the point fill mode
  23597. */
  23598. static readonly PointFillMode: number;
  23599. /**
  23600. * Returns the point list draw mode
  23601. */
  23602. static readonly PointListDrawMode: number;
  23603. /**
  23604. * Returns the line list draw mode
  23605. */
  23606. static readonly LineListDrawMode: number;
  23607. /**
  23608. * Returns the line loop draw mode
  23609. */
  23610. static readonly LineLoopDrawMode: number;
  23611. /**
  23612. * Returns the line strip draw mode
  23613. */
  23614. static readonly LineStripDrawMode: number;
  23615. /**
  23616. * Returns the triangle strip draw mode
  23617. */
  23618. static readonly TriangleStripDrawMode: number;
  23619. /**
  23620. * Returns the triangle fan draw mode
  23621. */
  23622. static readonly TriangleFanDrawMode: number;
  23623. /**
  23624. * Stores the clock-wise side orientation
  23625. */
  23626. static readonly ClockWiseSideOrientation: number;
  23627. /**
  23628. * Stores the counter clock-wise side orientation
  23629. */
  23630. static readonly CounterClockWiseSideOrientation: number;
  23631. /**
  23632. * The dirty texture flag value
  23633. */
  23634. static readonly TextureDirtyFlag: number;
  23635. /**
  23636. * The dirty light flag value
  23637. */
  23638. static readonly LightDirtyFlag: number;
  23639. /**
  23640. * The dirty fresnel flag value
  23641. */
  23642. static readonly FresnelDirtyFlag: number;
  23643. /**
  23644. * The dirty attribute flag value
  23645. */
  23646. static readonly AttributesDirtyFlag: number;
  23647. /**
  23648. * The dirty misc flag value
  23649. */
  23650. static readonly MiscDirtyFlag: number;
  23651. /**
  23652. * The all dirty flag value
  23653. */
  23654. static readonly AllDirtyFlag: number;
  23655. /**
  23656. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  23657. */
  23658. static readonly MATERIAL_OPAQUE: number;
  23659. /**
  23660. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  23661. */
  23662. static readonly MATERIAL_ALPHATEST: number;
  23663. /**
  23664. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23665. */
  23666. static readonly MATERIAL_ALPHABLEND: number;
  23667. /**
  23668. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23669. * They are also discarded below the alpha cutoff threshold to improve performances.
  23670. */
  23671. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  23672. /**
  23673. * The Whiteout method is used to blend normals.
  23674. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  23675. */
  23676. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  23677. /**
  23678. * The Reoriented Normal Mapping method is used to blend normals.
  23679. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  23680. */
  23681. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  23682. /**
  23683. * Custom callback helping to override the default shader used in the material.
  23684. */
  23685. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  23686. /**
  23687. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  23688. */
  23689. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  23690. /**
  23691. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  23692. * This means that the material can keep using a previous shader while a new one is being compiled.
  23693. * This is mostly used when shader parallel compilation is supported (true by default)
  23694. */
  23695. allowShaderHotSwapping: boolean;
  23696. /**
  23697. * The ID of the material
  23698. */
  23699. id: string;
  23700. /**
  23701. * Gets or sets the unique id of the material
  23702. */
  23703. uniqueId: number;
  23704. /**
  23705. * The name of the material
  23706. */
  23707. name: string;
  23708. /**
  23709. * Gets or sets user defined metadata
  23710. */
  23711. metadata: any;
  23712. /**
  23713. * For internal use only. Please do not use.
  23714. */
  23715. reservedDataStore: any;
  23716. /**
  23717. * Specifies if the ready state should be checked on each call
  23718. */
  23719. checkReadyOnEveryCall: boolean;
  23720. /**
  23721. * Specifies if the ready state should be checked once
  23722. */
  23723. checkReadyOnlyOnce: boolean;
  23724. /**
  23725. * The state of the material
  23726. */
  23727. state: string;
  23728. /**
  23729. * The alpha value of the material
  23730. */
  23731. protected _alpha: number;
  23732. /**
  23733. * List of inspectable custom properties (used by the Inspector)
  23734. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23735. */
  23736. inspectableCustomProperties: IInspectable[];
  23737. /**
  23738. * Sets the alpha value of the material
  23739. */
  23740. set alpha(value: number);
  23741. /**
  23742. * Gets the alpha value of the material
  23743. */
  23744. get alpha(): number;
  23745. /**
  23746. * Specifies if back face culling is enabled
  23747. */
  23748. protected _backFaceCulling: boolean;
  23749. /**
  23750. * Sets the back-face culling state
  23751. */
  23752. set backFaceCulling(value: boolean);
  23753. /**
  23754. * Gets the back-face culling state
  23755. */
  23756. get backFaceCulling(): boolean;
  23757. /**
  23758. * Stores the value for side orientation
  23759. */
  23760. sideOrientation: number;
  23761. /**
  23762. * Callback triggered when the material is compiled
  23763. */
  23764. onCompiled: Nullable<(effect: Effect) => void>;
  23765. /**
  23766. * Callback triggered when an error occurs
  23767. */
  23768. onError: Nullable<(effect: Effect, errors: string) => void>;
  23769. /**
  23770. * Callback triggered to get the render target textures
  23771. */
  23772. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  23773. /**
  23774. * Gets a boolean indicating that current material needs to register RTT
  23775. */
  23776. get hasRenderTargetTextures(): boolean;
  23777. /**
  23778. * Specifies if the material should be serialized
  23779. */
  23780. doNotSerialize: boolean;
  23781. /**
  23782. * @hidden
  23783. */
  23784. _storeEffectOnSubMeshes: boolean;
  23785. /**
  23786. * Stores the animations for the material
  23787. */
  23788. animations: Nullable<Array<Animation>>;
  23789. /**
  23790. * An event triggered when the material is disposed
  23791. */
  23792. onDisposeObservable: Observable<Material>;
  23793. /**
  23794. * An observer which watches for dispose events
  23795. */
  23796. private _onDisposeObserver;
  23797. private _onUnBindObservable;
  23798. /**
  23799. * Called during a dispose event
  23800. */
  23801. set onDispose(callback: () => void);
  23802. private _onBindObservable;
  23803. /**
  23804. * An event triggered when the material is bound
  23805. */
  23806. get onBindObservable(): Observable<AbstractMesh>;
  23807. /**
  23808. * An observer which watches for bind events
  23809. */
  23810. private _onBindObserver;
  23811. /**
  23812. * Called during a bind event
  23813. */
  23814. set onBind(callback: (Mesh: AbstractMesh) => void);
  23815. /**
  23816. * An event triggered when the material is unbound
  23817. */
  23818. get onUnBindObservable(): Observable<Material>;
  23819. protected _onEffectCreatedObservable: Nullable<Observable<{
  23820. effect: Effect;
  23821. subMesh: Nullable<SubMesh>;
  23822. }>>;
  23823. /**
  23824. * An event triggered when the effect is (re)created
  23825. */
  23826. get onEffectCreatedObservable(): Observable<{
  23827. effect: Effect;
  23828. subMesh: Nullable<SubMesh>;
  23829. }>;
  23830. /**
  23831. * Stores the value of the alpha mode
  23832. */
  23833. private _alphaMode;
  23834. /**
  23835. * Sets the value of the alpha mode.
  23836. *
  23837. * | Value | Type | Description |
  23838. * | --- | --- | --- |
  23839. * | 0 | ALPHA_DISABLE | |
  23840. * | 1 | ALPHA_ADD | |
  23841. * | 2 | ALPHA_COMBINE | |
  23842. * | 3 | ALPHA_SUBTRACT | |
  23843. * | 4 | ALPHA_MULTIPLY | |
  23844. * | 5 | ALPHA_MAXIMIZED | |
  23845. * | 6 | ALPHA_ONEONE | |
  23846. * | 7 | ALPHA_PREMULTIPLIED | |
  23847. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  23848. * | 9 | ALPHA_INTERPOLATE | |
  23849. * | 10 | ALPHA_SCREENMODE | |
  23850. *
  23851. */
  23852. set alphaMode(value: number);
  23853. /**
  23854. * Gets the value of the alpha mode
  23855. */
  23856. get alphaMode(): number;
  23857. /**
  23858. * Stores the state of the need depth pre-pass value
  23859. */
  23860. private _needDepthPrePass;
  23861. /**
  23862. * Sets the need depth pre-pass value
  23863. */
  23864. set needDepthPrePass(value: boolean);
  23865. /**
  23866. * Gets the depth pre-pass value
  23867. */
  23868. get needDepthPrePass(): boolean;
  23869. /**
  23870. * Specifies if depth writing should be disabled
  23871. */
  23872. disableDepthWrite: boolean;
  23873. /**
  23874. * Specifies if color writing should be disabled
  23875. */
  23876. disableColorWrite: boolean;
  23877. /**
  23878. * Specifies if depth writing should be forced
  23879. */
  23880. forceDepthWrite: boolean;
  23881. /**
  23882. * Specifies the depth function that should be used. 0 means the default engine function
  23883. */
  23884. depthFunction: number;
  23885. /**
  23886. * Specifies if there should be a separate pass for culling
  23887. */
  23888. separateCullingPass: boolean;
  23889. /**
  23890. * Stores the state specifing if fog should be enabled
  23891. */
  23892. private _fogEnabled;
  23893. /**
  23894. * Sets the state for enabling fog
  23895. */
  23896. set fogEnabled(value: boolean);
  23897. /**
  23898. * Gets the value of the fog enabled state
  23899. */
  23900. get fogEnabled(): boolean;
  23901. /**
  23902. * Stores the size of points
  23903. */
  23904. pointSize: number;
  23905. /**
  23906. * Stores the z offset value
  23907. */
  23908. zOffset: number;
  23909. get wireframe(): boolean;
  23910. /**
  23911. * Sets the state of wireframe mode
  23912. */
  23913. set wireframe(value: boolean);
  23914. /**
  23915. * Gets the value specifying if point clouds are enabled
  23916. */
  23917. get pointsCloud(): boolean;
  23918. /**
  23919. * Sets the state of point cloud mode
  23920. */
  23921. set pointsCloud(value: boolean);
  23922. /**
  23923. * Gets the material fill mode
  23924. */
  23925. get fillMode(): number;
  23926. /**
  23927. * Sets the material fill mode
  23928. */
  23929. set fillMode(value: number);
  23930. /**
  23931. * @hidden
  23932. * Stores the effects for the material
  23933. */
  23934. _effect: Nullable<Effect>;
  23935. /**
  23936. * Specifies if uniform buffers should be used
  23937. */
  23938. private _useUBO;
  23939. /**
  23940. * Stores a reference to the scene
  23941. */
  23942. private _scene;
  23943. /**
  23944. * Stores the fill mode state
  23945. */
  23946. private _fillMode;
  23947. /**
  23948. * Specifies if the depth write state should be cached
  23949. */
  23950. private _cachedDepthWriteState;
  23951. /**
  23952. * Specifies if the color write state should be cached
  23953. */
  23954. private _cachedColorWriteState;
  23955. /**
  23956. * Specifies if the depth function state should be cached
  23957. */
  23958. private _cachedDepthFunctionState;
  23959. /**
  23960. * Stores the uniform buffer
  23961. */
  23962. protected _uniformBuffer: UniformBuffer;
  23963. /** @hidden */
  23964. _indexInSceneMaterialArray: number;
  23965. /** @hidden */
  23966. meshMap: Nullable<{
  23967. [id: string]: AbstractMesh | undefined;
  23968. }>;
  23969. /**
  23970. * Creates a material instance
  23971. * @param name defines the name of the material
  23972. * @param scene defines the scene to reference
  23973. * @param doNotAdd specifies if the material should be added to the scene
  23974. */
  23975. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  23976. /**
  23977. * Returns a string representation of the current material
  23978. * @param fullDetails defines a boolean indicating which levels of logging is desired
  23979. * @returns a string with material information
  23980. */
  23981. toString(fullDetails?: boolean): string;
  23982. /**
  23983. * Gets the class name of the material
  23984. * @returns a string with the class name of the material
  23985. */
  23986. getClassName(): string;
  23987. /**
  23988. * Specifies if updates for the material been locked
  23989. */
  23990. get isFrozen(): boolean;
  23991. /**
  23992. * Locks updates for the material
  23993. */
  23994. freeze(): void;
  23995. /**
  23996. * Unlocks updates for the material
  23997. */
  23998. unfreeze(): void;
  23999. /**
  24000. * Specifies if the material is ready to be used
  24001. * @param mesh defines the mesh to check
  24002. * @param useInstances specifies if instances should be used
  24003. * @returns a boolean indicating if the material is ready to be used
  24004. */
  24005. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24006. /**
  24007. * Specifies that the submesh is ready to be used
  24008. * @param mesh defines the mesh to check
  24009. * @param subMesh defines which submesh to check
  24010. * @param useInstances specifies that instances should be used
  24011. * @returns a boolean indicating that the submesh is ready or not
  24012. */
  24013. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24014. /**
  24015. * Returns the material effect
  24016. * @returns the effect associated with the material
  24017. */
  24018. getEffect(): Nullable<Effect>;
  24019. /**
  24020. * Returns the current scene
  24021. * @returns a Scene
  24022. */
  24023. getScene(): Scene;
  24024. /**
  24025. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24026. */
  24027. protected _forceAlphaTest: boolean;
  24028. /**
  24029. * The transparency mode of the material.
  24030. */
  24031. protected _transparencyMode: Nullable<number>;
  24032. /**
  24033. * Gets the current transparency mode.
  24034. */
  24035. get transparencyMode(): Nullable<number>;
  24036. /**
  24037. * Sets the transparency mode of the material.
  24038. *
  24039. * | Value | Type | Description |
  24040. * | ----- | ----------------------------------- | ----------- |
  24041. * | 0 | OPAQUE | |
  24042. * | 1 | ALPHATEST | |
  24043. * | 2 | ALPHABLEND | |
  24044. * | 3 | ALPHATESTANDBLEND | |
  24045. *
  24046. */
  24047. set transparencyMode(value: Nullable<number>);
  24048. /**
  24049. * Returns true if alpha blending should be disabled.
  24050. */
  24051. protected get _disableAlphaBlending(): boolean;
  24052. /**
  24053. * Specifies whether or not this material should be rendered in alpha blend mode.
  24054. * @returns a boolean specifying if alpha blending is needed
  24055. */
  24056. needAlphaBlending(): boolean;
  24057. /**
  24058. * Specifies if the mesh will require alpha blending
  24059. * @param mesh defines the mesh to check
  24060. * @returns a boolean specifying if alpha blending is needed for the mesh
  24061. */
  24062. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  24063. /**
  24064. * Specifies whether or not this material should be rendered in alpha test mode.
  24065. * @returns a boolean specifying if an alpha test is needed.
  24066. */
  24067. needAlphaTesting(): boolean;
  24068. /**
  24069. * Specifies if material alpha testing should be turned on for the mesh
  24070. * @param mesh defines the mesh to check
  24071. */
  24072. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  24073. /**
  24074. * Gets the texture used for the alpha test
  24075. * @returns the texture to use for alpha testing
  24076. */
  24077. getAlphaTestTexture(): Nullable<BaseTexture>;
  24078. /**
  24079. * Marks the material to indicate that it needs to be re-calculated
  24080. */
  24081. markDirty(): void;
  24082. /** @hidden */
  24083. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  24084. /**
  24085. * Binds the material to the mesh
  24086. * @param world defines the world transformation matrix
  24087. * @param mesh defines the mesh to bind the material to
  24088. */
  24089. bind(world: Matrix, mesh?: Mesh): void;
  24090. /**
  24091. * Binds the submesh to the material
  24092. * @param world defines the world transformation matrix
  24093. * @param mesh defines the mesh containing the submesh
  24094. * @param subMesh defines the submesh to bind the material to
  24095. */
  24096. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24097. /**
  24098. * Binds the world matrix to the material
  24099. * @param world defines the world transformation matrix
  24100. */
  24101. bindOnlyWorldMatrix(world: Matrix): void;
  24102. /**
  24103. * Binds the scene's uniform buffer to the effect.
  24104. * @param effect defines the effect to bind to the scene uniform buffer
  24105. * @param sceneUbo defines the uniform buffer storing scene data
  24106. */
  24107. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  24108. /**
  24109. * Binds the view matrix to the effect
  24110. * @param effect defines the effect to bind the view matrix to
  24111. */
  24112. bindView(effect: Effect): void;
  24113. /**
  24114. * Binds the view projection matrix to the effect
  24115. * @param effect defines the effect to bind the view projection matrix to
  24116. */
  24117. bindViewProjection(effect: Effect): void;
  24118. /**
  24119. * Processes to execute after binding the material to a mesh
  24120. * @param mesh defines the rendered mesh
  24121. */
  24122. protected _afterBind(mesh?: Mesh): void;
  24123. /**
  24124. * Unbinds the material from the mesh
  24125. */
  24126. unbind(): void;
  24127. /**
  24128. * Gets the active textures from the material
  24129. * @returns an array of textures
  24130. */
  24131. getActiveTextures(): BaseTexture[];
  24132. /**
  24133. * Specifies if the material uses a texture
  24134. * @param texture defines the texture to check against the material
  24135. * @returns a boolean specifying if the material uses the texture
  24136. */
  24137. hasTexture(texture: BaseTexture): boolean;
  24138. /**
  24139. * Makes a duplicate of the material, and gives it a new name
  24140. * @param name defines the new name for the duplicated material
  24141. * @returns the cloned material
  24142. */
  24143. clone(name: string): Nullable<Material>;
  24144. /**
  24145. * Gets the meshes bound to the material
  24146. * @returns an array of meshes bound to the material
  24147. */
  24148. getBindedMeshes(): AbstractMesh[];
  24149. /**
  24150. * Force shader compilation
  24151. * @param mesh defines the mesh associated with this material
  24152. * @param onCompiled defines a function to execute once the material is compiled
  24153. * @param options defines the options to configure the compilation
  24154. * @param onError defines a function to execute if the material fails compiling
  24155. */
  24156. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  24157. /**
  24158. * Force shader compilation
  24159. * @param mesh defines the mesh that will use this material
  24160. * @param options defines additional options for compiling the shaders
  24161. * @returns a promise that resolves when the compilation completes
  24162. */
  24163. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  24164. private static readonly _AllDirtyCallBack;
  24165. private static readonly _ImageProcessingDirtyCallBack;
  24166. private static readonly _TextureDirtyCallBack;
  24167. private static readonly _FresnelDirtyCallBack;
  24168. private static readonly _MiscDirtyCallBack;
  24169. private static readonly _LightsDirtyCallBack;
  24170. private static readonly _AttributeDirtyCallBack;
  24171. private static _FresnelAndMiscDirtyCallBack;
  24172. private static _TextureAndMiscDirtyCallBack;
  24173. private static readonly _DirtyCallbackArray;
  24174. private static readonly _RunDirtyCallBacks;
  24175. /**
  24176. * Marks a define in the material to indicate that it needs to be re-computed
  24177. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  24178. */
  24179. markAsDirty(flag: number): void;
  24180. /**
  24181. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  24182. * @param func defines a function which checks material defines against the submeshes
  24183. */
  24184. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  24185. /**
  24186. * Indicates that we need to re-calculated for all submeshes
  24187. */
  24188. protected _markAllSubMeshesAsAllDirty(): void;
  24189. /**
  24190. * Indicates that image processing needs to be re-calculated for all submeshes
  24191. */
  24192. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  24193. /**
  24194. * Indicates that textures need to be re-calculated for all submeshes
  24195. */
  24196. protected _markAllSubMeshesAsTexturesDirty(): void;
  24197. /**
  24198. * Indicates that fresnel needs to be re-calculated for all submeshes
  24199. */
  24200. protected _markAllSubMeshesAsFresnelDirty(): void;
  24201. /**
  24202. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  24203. */
  24204. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  24205. /**
  24206. * Indicates that lights need to be re-calculated for all submeshes
  24207. */
  24208. protected _markAllSubMeshesAsLightsDirty(): void;
  24209. /**
  24210. * Indicates that attributes need to be re-calculated for all submeshes
  24211. */
  24212. protected _markAllSubMeshesAsAttributesDirty(): void;
  24213. /**
  24214. * Indicates that misc needs to be re-calculated for all submeshes
  24215. */
  24216. protected _markAllSubMeshesAsMiscDirty(): void;
  24217. /**
  24218. * Indicates that textures and misc need to be re-calculated for all submeshes
  24219. */
  24220. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  24221. /**
  24222. * Disposes the material
  24223. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  24224. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  24225. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  24226. */
  24227. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  24228. /** @hidden */
  24229. private releaseVertexArrayObject;
  24230. /**
  24231. * Serializes this material
  24232. * @returns the serialized material object
  24233. */
  24234. serialize(): any;
  24235. /**
  24236. * Creates a material from parsed material data
  24237. * @param parsedMaterial defines parsed material data
  24238. * @param scene defines the hosting scene
  24239. * @param rootUrl defines the root URL to use to load textures
  24240. * @returns a new material
  24241. */
  24242. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  24243. }
  24244. }
  24245. declare module BABYLON {
  24246. /**
  24247. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24248. * separate meshes. This can be use to improve performances.
  24249. * @see http://doc.babylonjs.com/how_to/multi_materials
  24250. */
  24251. export class MultiMaterial extends Material {
  24252. private _subMaterials;
  24253. /**
  24254. * Gets or Sets the list of Materials used within the multi material.
  24255. * They need to be ordered according to the submeshes order in the associated mesh
  24256. */
  24257. get subMaterials(): Nullable<Material>[];
  24258. set subMaterials(value: Nullable<Material>[]);
  24259. /**
  24260. * Function used to align with Node.getChildren()
  24261. * @returns the list of Materials used within the multi material
  24262. */
  24263. getChildren(): Nullable<Material>[];
  24264. /**
  24265. * Instantiates a new Multi Material
  24266. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24267. * separate meshes. This can be use to improve performances.
  24268. * @see http://doc.babylonjs.com/how_to/multi_materials
  24269. * @param name Define the name in the scene
  24270. * @param scene Define the scene the material belongs to
  24271. */
  24272. constructor(name: string, scene: Scene);
  24273. private _hookArray;
  24274. /**
  24275. * Get one of the submaterial by its index in the submaterials array
  24276. * @param index The index to look the sub material at
  24277. * @returns The Material if the index has been defined
  24278. */
  24279. getSubMaterial(index: number): Nullable<Material>;
  24280. /**
  24281. * Get the list of active textures for the whole sub materials list.
  24282. * @returns All the textures that will be used during the rendering
  24283. */
  24284. getActiveTextures(): BaseTexture[];
  24285. /**
  24286. * Gets the current class name of the material e.g. "MultiMaterial"
  24287. * Mainly use in serialization.
  24288. * @returns the class name
  24289. */
  24290. getClassName(): string;
  24291. /**
  24292. * Checks if the material is ready to render the requested sub mesh
  24293. * @param mesh Define the mesh the submesh belongs to
  24294. * @param subMesh Define the sub mesh to look readyness for
  24295. * @param useInstances Define whether or not the material is used with instances
  24296. * @returns true if ready, otherwise false
  24297. */
  24298. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24299. /**
  24300. * Clones the current material and its related sub materials
  24301. * @param name Define the name of the newly cloned material
  24302. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  24303. * @returns the cloned material
  24304. */
  24305. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  24306. /**
  24307. * Serializes the materials into a JSON representation.
  24308. * @returns the JSON representation
  24309. */
  24310. serialize(): any;
  24311. /**
  24312. * Dispose the material and release its associated resources
  24313. * @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)
  24314. * @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)
  24315. * @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)
  24316. */
  24317. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  24318. /**
  24319. * Creates a MultiMaterial from parsed MultiMaterial data.
  24320. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  24321. * @param scene defines the hosting scene
  24322. * @returns a new MultiMaterial
  24323. */
  24324. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  24325. }
  24326. }
  24327. declare module BABYLON {
  24328. /**
  24329. * Defines a subdivision inside a mesh
  24330. */
  24331. export class SubMesh implements ICullable {
  24332. /** the material index to use */
  24333. materialIndex: number;
  24334. /** vertex index start */
  24335. verticesStart: number;
  24336. /** vertices count */
  24337. verticesCount: number;
  24338. /** index start */
  24339. indexStart: number;
  24340. /** indices count */
  24341. indexCount: number;
  24342. /** @hidden */
  24343. _materialDefines: Nullable<MaterialDefines>;
  24344. /** @hidden */
  24345. _materialEffect: Nullable<Effect>;
  24346. /** @hidden */
  24347. _effectOverride: Nullable<Effect>;
  24348. /**
  24349. * Gets material defines used by the effect associated to the sub mesh
  24350. */
  24351. get materialDefines(): Nullable<MaterialDefines>;
  24352. /**
  24353. * Sets material defines used by the effect associated to the sub mesh
  24354. */
  24355. set materialDefines(defines: Nullable<MaterialDefines>);
  24356. /**
  24357. * Gets associated effect
  24358. */
  24359. get effect(): Nullable<Effect>;
  24360. /**
  24361. * Sets associated effect (effect used to render this submesh)
  24362. * @param effect defines the effect to associate with
  24363. * @param defines defines the set of defines used to compile this effect
  24364. */
  24365. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  24366. /** @hidden */
  24367. _linesIndexCount: number;
  24368. private _mesh;
  24369. private _renderingMesh;
  24370. private _boundingInfo;
  24371. private _linesIndexBuffer;
  24372. /** @hidden */
  24373. _lastColliderWorldVertices: Nullable<Vector3[]>;
  24374. /** @hidden */
  24375. _trianglePlanes: Plane[];
  24376. /** @hidden */
  24377. _lastColliderTransformMatrix: Nullable<Matrix>;
  24378. /** @hidden */
  24379. _renderId: number;
  24380. /** @hidden */
  24381. _alphaIndex: number;
  24382. /** @hidden */
  24383. _distanceToCamera: number;
  24384. /** @hidden */
  24385. _id: number;
  24386. private _currentMaterial;
  24387. /**
  24388. * Add a new submesh to a mesh
  24389. * @param materialIndex defines the material index to use
  24390. * @param verticesStart defines vertex index start
  24391. * @param verticesCount defines vertices count
  24392. * @param indexStart defines index start
  24393. * @param indexCount defines indices count
  24394. * @param mesh defines the parent mesh
  24395. * @param renderingMesh defines an optional rendering mesh
  24396. * @param createBoundingBox defines if bounding box should be created for this submesh
  24397. * @returns the new submesh
  24398. */
  24399. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  24400. /**
  24401. * Creates a new submesh
  24402. * @param materialIndex defines the material index to use
  24403. * @param verticesStart defines vertex index start
  24404. * @param verticesCount defines vertices count
  24405. * @param indexStart defines index start
  24406. * @param indexCount defines indices count
  24407. * @param mesh defines the parent mesh
  24408. * @param renderingMesh defines an optional rendering mesh
  24409. * @param createBoundingBox defines if bounding box should be created for this submesh
  24410. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  24411. */
  24412. constructor(
  24413. /** the material index to use */
  24414. materialIndex: number,
  24415. /** vertex index start */
  24416. verticesStart: number,
  24417. /** vertices count */
  24418. verticesCount: number,
  24419. /** index start */
  24420. indexStart: number,
  24421. /** indices count */
  24422. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  24423. /**
  24424. * Returns true if this submesh covers the entire parent mesh
  24425. * @ignorenaming
  24426. */
  24427. get IsGlobal(): boolean;
  24428. /**
  24429. * Returns the submesh BoudingInfo object
  24430. * @returns current bounding info (or mesh's one if the submesh is global)
  24431. */
  24432. getBoundingInfo(): BoundingInfo;
  24433. /**
  24434. * Sets the submesh BoundingInfo
  24435. * @param boundingInfo defines the new bounding info to use
  24436. * @returns the SubMesh
  24437. */
  24438. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  24439. /**
  24440. * Returns the mesh of the current submesh
  24441. * @return the parent mesh
  24442. */
  24443. getMesh(): AbstractMesh;
  24444. /**
  24445. * Returns the rendering mesh of the submesh
  24446. * @returns the rendering mesh (could be different from parent mesh)
  24447. */
  24448. getRenderingMesh(): Mesh;
  24449. /**
  24450. * Returns the replacement mesh of the submesh
  24451. * @returns the replacement mesh (could be different from parent mesh)
  24452. */
  24453. getReplacementMesh(): Nullable<AbstractMesh>;
  24454. /**
  24455. * Returns the effective mesh of the submesh
  24456. * @returns the effective mesh (could be different from parent mesh)
  24457. */
  24458. getEffectiveMesh(): AbstractMesh;
  24459. /**
  24460. * Returns the submesh material
  24461. * @returns null or the current material
  24462. */
  24463. getMaterial(): Nullable<Material>;
  24464. private _IsMultiMaterial;
  24465. /**
  24466. * Sets a new updated BoundingInfo object to the submesh
  24467. * @param data defines an optional position array to use to determine the bounding info
  24468. * @returns the SubMesh
  24469. */
  24470. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  24471. /** @hidden */
  24472. _checkCollision(collider: Collider): boolean;
  24473. /**
  24474. * Updates the submesh BoundingInfo
  24475. * @param world defines the world matrix to use to update the bounding info
  24476. * @returns the submesh
  24477. */
  24478. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  24479. /**
  24480. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  24481. * @param frustumPlanes defines the frustum planes
  24482. * @returns true if the submesh is intersecting with the frustum
  24483. */
  24484. isInFrustum(frustumPlanes: Plane[]): boolean;
  24485. /**
  24486. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  24487. * @param frustumPlanes defines the frustum planes
  24488. * @returns true if the submesh is inside the frustum
  24489. */
  24490. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24491. /**
  24492. * Renders the submesh
  24493. * @param enableAlphaMode defines if alpha needs to be used
  24494. * @returns the submesh
  24495. */
  24496. render(enableAlphaMode: boolean): SubMesh;
  24497. /**
  24498. * @hidden
  24499. */
  24500. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  24501. /**
  24502. * Checks if the submesh intersects with a ray
  24503. * @param ray defines the ray to test
  24504. * @returns true is the passed ray intersects the submesh bounding box
  24505. */
  24506. canIntersects(ray: Ray): boolean;
  24507. /**
  24508. * Intersects current submesh with a ray
  24509. * @param ray defines the ray to test
  24510. * @param positions defines mesh's positions array
  24511. * @param indices defines mesh's indices array
  24512. * @param fastCheck defines if the first intersection will be used (and not the closest)
  24513. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24514. * @returns intersection info or null if no intersection
  24515. */
  24516. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  24517. /** @hidden */
  24518. private _intersectLines;
  24519. /** @hidden */
  24520. private _intersectUnIndexedLines;
  24521. /** @hidden */
  24522. private _intersectTriangles;
  24523. /** @hidden */
  24524. private _intersectUnIndexedTriangles;
  24525. /** @hidden */
  24526. _rebuild(): void;
  24527. /**
  24528. * Creates a new submesh from the passed mesh
  24529. * @param newMesh defines the new hosting mesh
  24530. * @param newRenderingMesh defines an optional rendering mesh
  24531. * @returns the new submesh
  24532. */
  24533. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  24534. /**
  24535. * Release associated resources
  24536. */
  24537. dispose(): void;
  24538. /**
  24539. * Gets the class name
  24540. * @returns the string "SubMesh".
  24541. */
  24542. getClassName(): string;
  24543. /**
  24544. * Creates a new submesh from indices data
  24545. * @param materialIndex the index of the main mesh material
  24546. * @param startIndex the index where to start the copy in the mesh indices array
  24547. * @param indexCount the number of indices to copy then from the startIndex
  24548. * @param mesh the main mesh to create the submesh from
  24549. * @param renderingMesh the optional rendering mesh
  24550. * @returns a new submesh
  24551. */
  24552. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  24553. }
  24554. }
  24555. declare module BABYLON {
  24556. /**
  24557. * Class used to represent data loading progression
  24558. */
  24559. export class SceneLoaderFlags {
  24560. private static _ForceFullSceneLoadingForIncremental;
  24561. private static _ShowLoadingScreen;
  24562. private static _CleanBoneMatrixWeights;
  24563. private static _loggingLevel;
  24564. /**
  24565. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  24566. */
  24567. static get ForceFullSceneLoadingForIncremental(): boolean;
  24568. static set ForceFullSceneLoadingForIncremental(value: boolean);
  24569. /**
  24570. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  24571. */
  24572. static get ShowLoadingScreen(): boolean;
  24573. static set ShowLoadingScreen(value: boolean);
  24574. /**
  24575. * Defines the current logging level (while loading the scene)
  24576. * @ignorenaming
  24577. */
  24578. static get loggingLevel(): number;
  24579. static set loggingLevel(value: number);
  24580. /**
  24581. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  24582. */
  24583. static get CleanBoneMatrixWeights(): boolean;
  24584. static set CleanBoneMatrixWeights(value: boolean);
  24585. }
  24586. }
  24587. declare module BABYLON {
  24588. /**
  24589. * Class used to store geometry data (vertex buffers + index buffer)
  24590. */
  24591. export class Geometry implements IGetSetVerticesData {
  24592. /**
  24593. * Gets or sets the ID of the geometry
  24594. */
  24595. id: string;
  24596. /**
  24597. * Gets or sets the unique ID of the geometry
  24598. */
  24599. uniqueId: number;
  24600. /**
  24601. * Gets the delay loading state of the geometry (none by default which means not delayed)
  24602. */
  24603. delayLoadState: number;
  24604. /**
  24605. * Gets the file containing the data to load when running in delay load state
  24606. */
  24607. delayLoadingFile: Nullable<string>;
  24608. /**
  24609. * Callback called when the geometry is updated
  24610. */
  24611. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  24612. private _scene;
  24613. private _engine;
  24614. private _meshes;
  24615. private _totalVertices;
  24616. /** @hidden */
  24617. _indices: IndicesArray;
  24618. /** @hidden */
  24619. _vertexBuffers: {
  24620. [key: string]: VertexBuffer;
  24621. };
  24622. private _isDisposed;
  24623. private _extend;
  24624. private _boundingBias;
  24625. /** @hidden */
  24626. _delayInfo: Array<string>;
  24627. private _indexBuffer;
  24628. private _indexBufferIsUpdatable;
  24629. /** @hidden */
  24630. _boundingInfo: Nullable<BoundingInfo>;
  24631. /** @hidden */
  24632. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  24633. /** @hidden */
  24634. _softwareSkinningFrameId: number;
  24635. private _vertexArrayObjects;
  24636. private _updatable;
  24637. /** @hidden */
  24638. _positions: Nullable<Vector3[]>;
  24639. /**
  24640. * 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
  24641. */
  24642. get boundingBias(): Vector2;
  24643. /**
  24644. * 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
  24645. */
  24646. set boundingBias(value: Vector2);
  24647. /**
  24648. * Static function used to attach a new empty geometry to a mesh
  24649. * @param mesh defines the mesh to attach the geometry to
  24650. * @returns the new Geometry
  24651. */
  24652. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  24653. /** Get the list of meshes using this geometry */
  24654. get meshes(): Mesh[];
  24655. /**
  24656. * Creates a new geometry
  24657. * @param id defines the unique ID
  24658. * @param scene defines the hosting scene
  24659. * @param vertexData defines the VertexData used to get geometry data
  24660. * @param updatable defines if geometry must be updatable (false by default)
  24661. * @param mesh defines the mesh that will be associated with the geometry
  24662. */
  24663. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  24664. /**
  24665. * Gets the current extend of the geometry
  24666. */
  24667. get extend(): {
  24668. minimum: Vector3;
  24669. maximum: Vector3;
  24670. };
  24671. /**
  24672. * Gets the hosting scene
  24673. * @returns the hosting Scene
  24674. */
  24675. getScene(): Scene;
  24676. /**
  24677. * Gets the hosting engine
  24678. * @returns the hosting Engine
  24679. */
  24680. getEngine(): Engine;
  24681. /**
  24682. * Defines if the geometry is ready to use
  24683. * @returns true if the geometry is ready to be used
  24684. */
  24685. isReady(): boolean;
  24686. /**
  24687. * Gets a value indicating that the geometry should not be serialized
  24688. */
  24689. get doNotSerialize(): boolean;
  24690. /** @hidden */
  24691. _rebuild(): void;
  24692. /**
  24693. * Affects all geometry data in one call
  24694. * @param vertexData defines the geometry data
  24695. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  24696. */
  24697. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  24698. /**
  24699. * Set specific vertex data
  24700. * @param kind defines the data kind (Position, normal, etc...)
  24701. * @param data defines the vertex data to use
  24702. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24703. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24704. */
  24705. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  24706. /**
  24707. * Removes a specific vertex data
  24708. * @param kind defines the data kind (Position, normal, etc...)
  24709. */
  24710. removeVerticesData(kind: string): void;
  24711. /**
  24712. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  24713. * @param buffer defines the vertex buffer to use
  24714. * @param totalVertices defines the total number of vertices for position kind (could be null)
  24715. */
  24716. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  24717. /**
  24718. * Update a specific vertex buffer
  24719. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  24720. * It will do nothing if the buffer is not updatable
  24721. * @param kind defines the data kind (Position, normal, etc...)
  24722. * @param data defines the data to use
  24723. * @param offset defines the offset in the target buffer where to store the data
  24724. * @param useBytes set to true if the offset is in bytes
  24725. */
  24726. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  24727. /**
  24728. * Update a specific vertex buffer
  24729. * This function will create a new buffer if the current one is not updatable
  24730. * @param kind defines the data kind (Position, normal, etc...)
  24731. * @param data defines the data to use
  24732. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  24733. */
  24734. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  24735. private _updateBoundingInfo;
  24736. /** @hidden */
  24737. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  24738. /**
  24739. * Gets total number of vertices
  24740. * @returns the total number of vertices
  24741. */
  24742. getTotalVertices(): number;
  24743. /**
  24744. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24745. * @param kind defines the data kind (Position, normal, etc...)
  24746. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24747. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24748. * @returns a float array containing vertex data
  24749. */
  24750. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24751. /**
  24752. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  24753. * @param kind defines the data kind (Position, normal, etc...)
  24754. * @returns true if the vertex buffer with the specified kind is updatable
  24755. */
  24756. isVertexBufferUpdatable(kind: string): boolean;
  24757. /**
  24758. * Gets a specific vertex buffer
  24759. * @param kind defines the data kind (Position, normal, etc...)
  24760. * @returns a VertexBuffer
  24761. */
  24762. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24763. /**
  24764. * Returns all vertex buffers
  24765. * @return an object holding all vertex buffers indexed by kind
  24766. */
  24767. getVertexBuffers(): Nullable<{
  24768. [key: string]: VertexBuffer;
  24769. }>;
  24770. /**
  24771. * Gets a boolean indicating if specific vertex buffer is present
  24772. * @param kind defines the data kind (Position, normal, etc...)
  24773. * @returns true if data is present
  24774. */
  24775. isVerticesDataPresent(kind: string): boolean;
  24776. /**
  24777. * Gets a list of all attached data kinds (Position, normal, etc...)
  24778. * @returns a list of string containing all kinds
  24779. */
  24780. getVerticesDataKinds(): string[];
  24781. /**
  24782. * Update index buffer
  24783. * @param indices defines the indices to store in the index buffer
  24784. * @param offset defines the offset in the target buffer where to store the data
  24785. * @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)
  24786. */
  24787. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  24788. /**
  24789. * Creates a new index buffer
  24790. * @param indices defines the indices to store in the index buffer
  24791. * @param totalVertices defines the total number of vertices (could be null)
  24792. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  24793. */
  24794. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  24795. /**
  24796. * Return the total number of indices
  24797. * @returns the total number of indices
  24798. */
  24799. getTotalIndices(): number;
  24800. /**
  24801. * Gets the index buffer array
  24802. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24803. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24804. * @returns the index buffer array
  24805. */
  24806. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24807. /**
  24808. * Gets the index buffer
  24809. * @return the index buffer
  24810. */
  24811. getIndexBuffer(): Nullable<DataBuffer>;
  24812. /** @hidden */
  24813. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  24814. /**
  24815. * Release the associated resources for a specific mesh
  24816. * @param mesh defines the source mesh
  24817. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  24818. */
  24819. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  24820. /**
  24821. * Apply current geometry to a given mesh
  24822. * @param mesh defines the mesh to apply geometry to
  24823. */
  24824. applyToMesh(mesh: Mesh): void;
  24825. private _updateExtend;
  24826. private _applyToMesh;
  24827. private notifyUpdate;
  24828. /**
  24829. * Load the geometry if it was flagged as delay loaded
  24830. * @param scene defines the hosting scene
  24831. * @param onLoaded defines a callback called when the geometry is loaded
  24832. */
  24833. load(scene: Scene, onLoaded?: () => void): void;
  24834. private _queueLoad;
  24835. /**
  24836. * Invert the geometry to move from a right handed system to a left handed one.
  24837. */
  24838. toLeftHanded(): void;
  24839. /** @hidden */
  24840. _resetPointsArrayCache(): void;
  24841. /** @hidden */
  24842. _generatePointsArray(): boolean;
  24843. /**
  24844. * Gets a value indicating if the geometry is disposed
  24845. * @returns true if the geometry was disposed
  24846. */
  24847. isDisposed(): boolean;
  24848. private _disposeVertexArrayObjects;
  24849. /**
  24850. * Free all associated resources
  24851. */
  24852. dispose(): void;
  24853. /**
  24854. * Clone the current geometry into a new geometry
  24855. * @param id defines the unique ID of the new geometry
  24856. * @returns a new geometry object
  24857. */
  24858. copy(id: string): Geometry;
  24859. /**
  24860. * Serialize the current geometry info (and not the vertices data) into a JSON object
  24861. * @return a JSON representation of the current geometry data (without the vertices data)
  24862. */
  24863. serialize(): any;
  24864. private toNumberArray;
  24865. /**
  24866. * Serialize all vertices data into a JSON oject
  24867. * @returns a JSON representation of the current geometry data
  24868. */
  24869. serializeVerticeData(): any;
  24870. /**
  24871. * Extracts a clone of a mesh geometry
  24872. * @param mesh defines the source mesh
  24873. * @param id defines the unique ID of the new geometry object
  24874. * @returns the new geometry object
  24875. */
  24876. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  24877. /**
  24878. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  24879. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24880. * Be aware Math.random() could cause collisions, but:
  24881. * "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"
  24882. * @returns a string containing a new GUID
  24883. */
  24884. static RandomId(): string;
  24885. /** @hidden */
  24886. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  24887. private static _CleanMatricesWeights;
  24888. /**
  24889. * Create a new geometry from persisted data (Using .babylon file format)
  24890. * @param parsedVertexData defines the persisted data
  24891. * @param scene defines the hosting scene
  24892. * @param rootUrl defines the root url to use to load assets (like delayed data)
  24893. * @returns the new geometry object
  24894. */
  24895. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  24896. }
  24897. }
  24898. declare module BABYLON {
  24899. /**
  24900. * Define an interface for all classes that will get and set the data on vertices
  24901. */
  24902. export interface IGetSetVerticesData {
  24903. /**
  24904. * Gets a boolean indicating if specific vertex data is present
  24905. * @param kind defines the vertex data kind to use
  24906. * @returns true is data kind is present
  24907. */
  24908. isVerticesDataPresent(kind: string): boolean;
  24909. /**
  24910. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24911. * @param kind defines the data kind (Position, normal, etc...)
  24912. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24913. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24914. * @returns a float array containing vertex data
  24915. */
  24916. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24917. /**
  24918. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24919. * @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.
  24920. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24921. * @returns the indices array or an empty array if the mesh has no geometry
  24922. */
  24923. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24924. /**
  24925. * Set specific vertex data
  24926. * @param kind defines the data kind (Position, normal, etc...)
  24927. * @param data defines the vertex data to use
  24928. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24929. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24930. */
  24931. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  24932. /**
  24933. * Update a specific associated vertex buffer
  24934. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24935. * - VertexBuffer.PositionKind
  24936. * - VertexBuffer.UVKind
  24937. * - VertexBuffer.UV2Kind
  24938. * - VertexBuffer.UV3Kind
  24939. * - VertexBuffer.UV4Kind
  24940. * - VertexBuffer.UV5Kind
  24941. * - VertexBuffer.UV6Kind
  24942. * - VertexBuffer.ColorKind
  24943. * - VertexBuffer.MatricesIndicesKind
  24944. * - VertexBuffer.MatricesIndicesExtraKind
  24945. * - VertexBuffer.MatricesWeightsKind
  24946. * - VertexBuffer.MatricesWeightsExtraKind
  24947. * @param data defines the data source
  24948. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24949. * @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)
  24950. */
  24951. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  24952. /**
  24953. * Creates a new index buffer
  24954. * @param indices defines the indices to store in the index buffer
  24955. * @param totalVertices defines the total number of vertices (could be null)
  24956. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  24957. */
  24958. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  24959. }
  24960. /**
  24961. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  24962. */
  24963. export class VertexData {
  24964. /**
  24965. * Mesh side orientation : usually the external or front surface
  24966. */
  24967. static readonly FRONTSIDE: number;
  24968. /**
  24969. * Mesh side orientation : usually the internal or back surface
  24970. */
  24971. static readonly BACKSIDE: number;
  24972. /**
  24973. * Mesh side orientation : both internal and external or front and back surfaces
  24974. */
  24975. static readonly DOUBLESIDE: number;
  24976. /**
  24977. * Mesh side orientation : by default, `FRONTSIDE`
  24978. */
  24979. static readonly DEFAULTSIDE: number;
  24980. /**
  24981. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  24982. */
  24983. positions: Nullable<FloatArray>;
  24984. /**
  24985. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  24986. */
  24987. normals: Nullable<FloatArray>;
  24988. /**
  24989. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  24990. */
  24991. tangents: Nullable<FloatArray>;
  24992. /**
  24993. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  24994. */
  24995. uvs: Nullable<FloatArray>;
  24996. /**
  24997. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  24998. */
  24999. uvs2: Nullable<FloatArray>;
  25000. /**
  25001. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25002. */
  25003. uvs3: Nullable<FloatArray>;
  25004. /**
  25005. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25006. */
  25007. uvs4: Nullable<FloatArray>;
  25008. /**
  25009. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25010. */
  25011. uvs5: Nullable<FloatArray>;
  25012. /**
  25013. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25014. */
  25015. uvs6: Nullable<FloatArray>;
  25016. /**
  25017. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25018. */
  25019. colors: Nullable<FloatArray>;
  25020. /**
  25021. * 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).
  25022. */
  25023. matricesIndices: Nullable<FloatArray>;
  25024. /**
  25025. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25026. */
  25027. matricesWeights: Nullable<FloatArray>;
  25028. /**
  25029. * An array extending the number of possible indices
  25030. */
  25031. matricesIndicesExtra: Nullable<FloatArray>;
  25032. /**
  25033. * An array extending the number of possible weights when the number of indices is extended
  25034. */
  25035. matricesWeightsExtra: Nullable<FloatArray>;
  25036. /**
  25037. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25038. */
  25039. indices: Nullable<IndicesArray>;
  25040. /**
  25041. * Uses the passed data array to set the set the values for the specified kind of data
  25042. * @param data a linear array of floating numbers
  25043. * @param kind the type of data that is being set, eg positions, colors etc
  25044. */
  25045. set(data: FloatArray, kind: string): void;
  25046. /**
  25047. * Associates the vertexData to the passed Mesh.
  25048. * Sets it as updatable or not (default `false`)
  25049. * @param mesh the mesh the vertexData is applied to
  25050. * @param updatable when used and having the value true allows new data to update the vertexData
  25051. * @returns the VertexData
  25052. */
  25053. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  25054. /**
  25055. * Associates the vertexData to the passed Geometry.
  25056. * Sets it as updatable or not (default `false`)
  25057. * @param geometry the geometry the vertexData is applied to
  25058. * @param updatable when used and having the value true allows new data to update the vertexData
  25059. * @returns VertexData
  25060. */
  25061. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  25062. /**
  25063. * Updates the associated mesh
  25064. * @param mesh the mesh to be updated
  25065. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25066. * @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
  25067. * @returns VertexData
  25068. */
  25069. updateMesh(mesh: Mesh): VertexData;
  25070. /**
  25071. * Updates the associated geometry
  25072. * @param geometry the geometry to be updated
  25073. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25074. * @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
  25075. * @returns VertexData.
  25076. */
  25077. updateGeometry(geometry: Geometry): VertexData;
  25078. private _applyTo;
  25079. private _update;
  25080. /**
  25081. * Transforms each position and each normal of the vertexData according to the passed Matrix
  25082. * @param matrix the transforming matrix
  25083. * @returns the VertexData
  25084. */
  25085. transform(matrix: Matrix): VertexData;
  25086. /**
  25087. * Merges the passed VertexData into the current one
  25088. * @param other the VertexData to be merged into the current one
  25089. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  25090. * @returns the modified VertexData
  25091. */
  25092. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  25093. private _mergeElement;
  25094. private _validate;
  25095. /**
  25096. * Serializes the VertexData
  25097. * @returns a serialized object
  25098. */
  25099. serialize(): any;
  25100. /**
  25101. * Extracts the vertexData from a mesh
  25102. * @param mesh the mesh from which to extract the VertexData
  25103. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  25104. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25105. * @returns the object VertexData associated to the passed mesh
  25106. */
  25107. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25108. /**
  25109. * Extracts the vertexData from the geometry
  25110. * @param geometry the geometry from which to extract the VertexData
  25111. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  25112. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25113. * @returns the object VertexData associated to the passed mesh
  25114. */
  25115. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25116. private static _ExtractFrom;
  25117. /**
  25118. * Creates the VertexData for a Ribbon
  25119. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  25120. * * pathArray array of paths, each of which an array of successive Vector3
  25121. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  25122. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  25123. * * 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
  25124. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25125. * * 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)
  25126. * * 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)
  25127. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  25128. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  25129. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  25130. * @returns the VertexData of the ribbon
  25131. */
  25132. static CreateRibbon(options: {
  25133. pathArray: Vector3[][];
  25134. closeArray?: boolean;
  25135. closePath?: boolean;
  25136. offset?: number;
  25137. sideOrientation?: number;
  25138. frontUVs?: Vector4;
  25139. backUVs?: Vector4;
  25140. invertUV?: boolean;
  25141. uvs?: Vector2[];
  25142. colors?: Color4[];
  25143. }): VertexData;
  25144. /**
  25145. * Creates the VertexData for a box
  25146. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25147. * * size sets the width, height and depth of the box to the value of size, optional default 1
  25148. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  25149. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  25150. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  25151. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25152. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25153. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25154. * * 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)
  25155. * * 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)
  25156. * @returns the VertexData of the box
  25157. */
  25158. static CreateBox(options: {
  25159. size?: number;
  25160. width?: number;
  25161. height?: number;
  25162. depth?: number;
  25163. faceUV?: Vector4[];
  25164. faceColors?: Color4[];
  25165. sideOrientation?: number;
  25166. frontUVs?: Vector4;
  25167. backUVs?: Vector4;
  25168. }): VertexData;
  25169. /**
  25170. * Creates the VertexData for a tiled box
  25171. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25172. * * faceTiles sets the pattern, tile size and number of tiles for a face
  25173. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25174. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25175. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25176. * @returns the VertexData of the box
  25177. */
  25178. static CreateTiledBox(options: {
  25179. pattern?: number;
  25180. width?: number;
  25181. height?: number;
  25182. depth?: number;
  25183. tileSize?: number;
  25184. tileWidth?: number;
  25185. tileHeight?: number;
  25186. alignHorizontal?: number;
  25187. alignVertical?: number;
  25188. faceUV?: Vector4[];
  25189. faceColors?: Color4[];
  25190. sideOrientation?: number;
  25191. }): VertexData;
  25192. /**
  25193. * Creates the VertexData for a tiled plane
  25194. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25195. * * pattern a limited pattern arrangement depending on the number
  25196. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  25197. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  25198. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  25199. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25200. * * 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)
  25201. * * 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)
  25202. * @returns the VertexData of the tiled plane
  25203. */
  25204. static CreateTiledPlane(options: {
  25205. pattern?: number;
  25206. tileSize?: number;
  25207. tileWidth?: number;
  25208. tileHeight?: number;
  25209. size?: number;
  25210. width?: number;
  25211. height?: number;
  25212. alignHorizontal?: number;
  25213. alignVertical?: number;
  25214. sideOrientation?: number;
  25215. frontUVs?: Vector4;
  25216. backUVs?: Vector4;
  25217. }): VertexData;
  25218. /**
  25219. * Creates the VertexData for an ellipsoid, defaults to a sphere
  25220. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25221. * * segments sets the number of horizontal strips optional, default 32
  25222. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  25223. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  25224. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  25225. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  25226. * * 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
  25227. * * 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
  25228. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25229. * * 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)
  25230. * * 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)
  25231. * @returns the VertexData of the ellipsoid
  25232. */
  25233. static CreateSphere(options: {
  25234. segments?: number;
  25235. diameter?: number;
  25236. diameterX?: number;
  25237. diameterY?: number;
  25238. diameterZ?: number;
  25239. arc?: number;
  25240. slice?: number;
  25241. sideOrientation?: number;
  25242. frontUVs?: Vector4;
  25243. backUVs?: Vector4;
  25244. }): VertexData;
  25245. /**
  25246. * Creates the VertexData for a cylinder, cone or prism
  25247. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25248. * * height sets the height (y direction) of the cylinder, optional, default 2
  25249. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  25250. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  25251. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  25252. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25253. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  25254. * * 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
  25255. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25256. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25257. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  25258. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  25259. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25260. * * 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)
  25261. * * 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)
  25262. * @returns the VertexData of the cylinder, cone or prism
  25263. */
  25264. static CreateCylinder(options: {
  25265. height?: number;
  25266. diameterTop?: number;
  25267. diameterBottom?: number;
  25268. diameter?: number;
  25269. tessellation?: number;
  25270. subdivisions?: number;
  25271. arc?: number;
  25272. faceColors?: Color4[];
  25273. faceUV?: Vector4[];
  25274. hasRings?: boolean;
  25275. enclose?: boolean;
  25276. sideOrientation?: number;
  25277. frontUVs?: Vector4;
  25278. backUVs?: Vector4;
  25279. }): VertexData;
  25280. /**
  25281. * Creates the VertexData for a torus
  25282. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25283. * * diameter the diameter of the torus, optional default 1
  25284. * * thickness the diameter of the tube forming the torus, optional default 0.5
  25285. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25286. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25287. * * 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)
  25288. * * 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)
  25289. * @returns the VertexData of the torus
  25290. */
  25291. static CreateTorus(options: {
  25292. diameter?: number;
  25293. thickness?: number;
  25294. tessellation?: number;
  25295. sideOrientation?: number;
  25296. frontUVs?: Vector4;
  25297. backUVs?: Vector4;
  25298. }): VertexData;
  25299. /**
  25300. * Creates the VertexData of the LineSystem
  25301. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  25302. * - lines an array of lines, each line being an array of successive Vector3
  25303. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  25304. * @returns the VertexData of the LineSystem
  25305. */
  25306. static CreateLineSystem(options: {
  25307. lines: Vector3[][];
  25308. colors?: Nullable<Color4[][]>;
  25309. }): VertexData;
  25310. /**
  25311. * Create the VertexData for a DashedLines
  25312. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  25313. * - points an array successive Vector3
  25314. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  25315. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  25316. * - dashNb the intended total number of dashes, optional, default 200
  25317. * @returns the VertexData for the DashedLines
  25318. */
  25319. static CreateDashedLines(options: {
  25320. points: Vector3[];
  25321. dashSize?: number;
  25322. gapSize?: number;
  25323. dashNb?: number;
  25324. }): VertexData;
  25325. /**
  25326. * Creates the VertexData for a Ground
  25327. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25328. * - width the width (x direction) of the ground, optional, default 1
  25329. * - height the height (z direction) of the ground, optional, default 1
  25330. * - subdivisions the number of subdivisions per side, optional, default 1
  25331. * @returns the VertexData of the Ground
  25332. */
  25333. static CreateGround(options: {
  25334. width?: number;
  25335. height?: number;
  25336. subdivisions?: number;
  25337. subdivisionsX?: number;
  25338. subdivisionsY?: number;
  25339. }): VertexData;
  25340. /**
  25341. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  25342. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25343. * * xmin the ground minimum X coordinate, optional, default -1
  25344. * * zmin the ground minimum Z coordinate, optional, default -1
  25345. * * xmax the ground maximum X coordinate, optional, default 1
  25346. * * zmax the ground maximum Z coordinate, optional, default 1
  25347. * * 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}
  25348. * * 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}
  25349. * @returns the VertexData of the TiledGround
  25350. */
  25351. static CreateTiledGround(options: {
  25352. xmin: number;
  25353. zmin: number;
  25354. xmax: number;
  25355. zmax: number;
  25356. subdivisions?: {
  25357. w: number;
  25358. h: number;
  25359. };
  25360. precision?: {
  25361. w: number;
  25362. h: number;
  25363. };
  25364. }): VertexData;
  25365. /**
  25366. * Creates the VertexData of the Ground designed from a heightmap
  25367. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  25368. * * width the width (x direction) of the ground
  25369. * * height the height (z direction) of the ground
  25370. * * subdivisions the number of subdivisions per side
  25371. * * minHeight the minimum altitude on the ground, optional, default 0
  25372. * * maxHeight the maximum altitude on the ground, optional default 1
  25373. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  25374. * * buffer the array holding the image color data
  25375. * * bufferWidth the width of image
  25376. * * bufferHeight the height of image
  25377. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  25378. * @returns the VertexData of the Ground designed from a heightmap
  25379. */
  25380. static CreateGroundFromHeightMap(options: {
  25381. width: number;
  25382. height: number;
  25383. subdivisions: number;
  25384. minHeight: number;
  25385. maxHeight: number;
  25386. colorFilter: Color3;
  25387. buffer: Uint8Array;
  25388. bufferWidth: number;
  25389. bufferHeight: number;
  25390. alphaFilter: number;
  25391. }): VertexData;
  25392. /**
  25393. * Creates the VertexData for a Plane
  25394. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  25395. * * size sets the width and height of the plane to the value of size, optional default 1
  25396. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  25397. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  25398. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25399. * * 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)
  25400. * * 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)
  25401. * @returns the VertexData of the box
  25402. */
  25403. static CreatePlane(options: {
  25404. size?: number;
  25405. width?: number;
  25406. height?: number;
  25407. sideOrientation?: number;
  25408. frontUVs?: Vector4;
  25409. backUVs?: Vector4;
  25410. }): VertexData;
  25411. /**
  25412. * Creates the VertexData of the Disc or regular Polygon
  25413. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  25414. * * radius the radius of the disc, optional default 0.5
  25415. * * tessellation the number of polygon sides, optional, default 64
  25416. * * 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
  25417. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25418. * * 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)
  25419. * * 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)
  25420. * @returns the VertexData of the box
  25421. */
  25422. static CreateDisc(options: {
  25423. radius?: number;
  25424. tessellation?: number;
  25425. arc?: number;
  25426. sideOrientation?: number;
  25427. frontUVs?: Vector4;
  25428. backUVs?: Vector4;
  25429. }): VertexData;
  25430. /**
  25431. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  25432. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  25433. * @param polygon a mesh built from polygonTriangulation.build()
  25434. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25435. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25436. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25437. * @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)
  25438. * @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)
  25439. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  25440. * @returns the VertexData of the Polygon
  25441. */
  25442. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  25443. /**
  25444. * Creates the VertexData of the IcoSphere
  25445. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  25446. * * radius the radius of the IcoSphere, optional default 1
  25447. * * radiusX allows stretching in the x direction, optional, default radius
  25448. * * radiusY allows stretching in the y direction, optional, default radius
  25449. * * radiusZ allows stretching in the z direction, optional, default radius
  25450. * * flat when true creates a flat shaded mesh, optional, default true
  25451. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25452. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25453. * * 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)
  25454. * * 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)
  25455. * @returns the VertexData of the IcoSphere
  25456. */
  25457. static CreateIcoSphere(options: {
  25458. radius?: number;
  25459. radiusX?: number;
  25460. radiusY?: number;
  25461. radiusZ?: number;
  25462. flat?: boolean;
  25463. subdivisions?: number;
  25464. sideOrientation?: number;
  25465. frontUVs?: Vector4;
  25466. backUVs?: Vector4;
  25467. }): VertexData;
  25468. /**
  25469. * Creates the VertexData for a Polyhedron
  25470. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  25471. * * type provided types are:
  25472. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  25473. * * 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)
  25474. * * size the size of the IcoSphere, optional default 1
  25475. * * sizeX allows stretching in the x direction, optional, default size
  25476. * * sizeY allows stretching in the y direction, optional, default size
  25477. * * sizeZ allows stretching in the z direction, optional, default size
  25478. * * 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
  25479. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25480. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25481. * * flat when true creates a flat shaded mesh, optional, default true
  25482. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25483. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25484. * * 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)
  25485. * * 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)
  25486. * @returns the VertexData of the Polyhedron
  25487. */
  25488. static CreatePolyhedron(options: {
  25489. type?: number;
  25490. size?: number;
  25491. sizeX?: number;
  25492. sizeY?: number;
  25493. sizeZ?: number;
  25494. custom?: any;
  25495. faceUV?: Vector4[];
  25496. faceColors?: Color4[];
  25497. flat?: boolean;
  25498. sideOrientation?: number;
  25499. frontUVs?: Vector4;
  25500. backUVs?: Vector4;
  25501. }): VertexData;
  25502. /**
  25503. * Creates the VertexData for a TorusKnot
  25504. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  25505. * * radius the radius of the torus knot, optional, default 2
  25506. * * tube the thickness of the tube, optional, default 0.5
  25507. * * radialSegments the number of sides on each tube segments, optional, default 32
  25508. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  25509. * * p the number of windings around the z axis, optional, default 2
  25510. * * q the number of windings around the x axis, optional, default 3
  25511. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25512. * * 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)
  25513. * * 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)
  25514. * @returns the VertexData of the Torus Knot
  25515. */
  25516. static CreateTorusKnot(options: {
  25517. radius?: number;
  25518. tube?: number;
  25519. radialSegments?: number;
  25520. tubularSegments?: number;
  25521. p?: number;
  25522. q?: number;
  25523. sideOrientation?: number;
  25524. frontUVs?: Vector4;
  25525. backUVs?: Vector4;
  25526. }): VertexData;
  25527. /**
  25528. * Compute normals for given positions and indices
  25529. * @param positions an array of vertex positions, [...., x, y, z, ......]
  25530. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  25531. * @param normals an array of vertex normals, [...., x, y, z, ......]
  25532. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  25533. * * facetNormals : optional array of facet normals (vector3)
  25534. * * facetPositions : optional array of facet positions (vector3)
  25535. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  25536. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  25537. * * bInfo : optional bounding info, required for facetPartitioning computation
  25538. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  25539. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  25540. * * useRightHandedSystem: optional boolean to for right handed system computation
  25541. * * depthSort : optional boolean to enable the facet depth sort computation
  25542. * * distanceTo : optional Vector3 to compute the facet depth from this location
  25543. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  25544. */
  25545. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  25546. facetNormals?: any;
  25547. facetPositions?: any;
  25548. facetPartitioning?: any;
  25549. ratio?: number;
  25550. bInfo?: any;
  25551. bbSize?: Vector3;
  25552. subDiv?: any;
  25553. useRightHandedSystem?: boolean;
  25554. depthSort?: boolean;
  25555. distanceTo?: Vector3;
  25556. depthSortedFacets?: any;
  25557. }): void;
  25558. /** @hidden */
  25559. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  25560. /**
  25561. * Applies VertexData created from the imported parameters to the geometry
  25562. * @param parsedVertexData the parsed data from an imported file
  25563. * @param geometry the geometry to apply the VertexData to
  25564. */
  25565. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  25566. }
  25567. }
  25568. declare module BABYLON {
  25569. /**
  25570. * Defines a target to use with MorphTargetManager
  25571. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25572. */
  25573. export class MorphTarget implements IAnimatable {
  25574. /** defines the name of the target */
  25575. name: string;
  25576. /**
  25577. * Gets or sets the list of animations
  25578. */
  25579. animations: Animation[];
  25580. private _scene;
  25581. private _positions;
  25582. private _normals;
  25583. private _tangents;
  25584. private _uvs;
  25585. private _influence;
  25586. private _uniqueId;
  25587. /**
  25588. * Observable raised when the influence changes
  25589. */
  25590. onInfluenceChanged: Observable<boolean>;
  25591. /** @hidden */
  25592. _onDataLayoutChanged: Observable<void>;
  25593. /**
  25594. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  25595. */
  25596. get influence(): number;
  25597. set influence(influence: number);
  25598. /**
  25599. * Gets or sets the id of the morph Target
  25600. */
  25601. id: string;
  25602. private _animationPropertiesOverride;
  25603. /**
  25604. * Gets or sets the animation properties override
  25605. */
  25606. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25607. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  25608. /**
  25609. * Creates a new MorphTarget
  25610. * @param name defines the name of the target
  25611. * @param influence defines the influence to use
  25612. * @param scene defines the scene the morphtarget belongs to
  25613. */
  25614. constructor(
  25615. /** defines the name of the target */
  25616. name: string, influence?: number, scene?: Nullable<Scene>);
  25617. /**
  25618. * Gets the unique ID of this manager
  25619. */
  25620. get uniqueId(): number;
  25621. /**
  25622. * Gets a boolean defining if the target contains position data
  25623. */
  25624. get hasPositions(): boolean;
  25625. /**
  25626. * Gets a boolean defining if the target contains normal data
  25627. */
  25628. get hasNormals(): boolean;
  25629. /**
  25630. * Gets a boolean defining if the target contains tangent data
  25631. */
  25632. get hasTangents(): boolean;
  25633. /**
  25634. * Gets a boolean defining if the target contains texture coordinates data
  25635. */
  25636. get hasUVs(): boolean;
  25637. /**
  25638. * Affects position data to this target
  25639. * @param data defines the position data to use
  25640. */
  25641. setPositions(data: Nullable<FloatArray>): void;
  25642. /**
  25643. * Gets the position data stored in this target
  25644. * @returns a FloatArray containing the position data (or null if not present)
  25645. */
  25646. getPositions(): Nullable<FloatArray>;
  25647. /**
  25648. * Affects normal data to this target
  25649. * @param data defines the normal data to use
  25650. */
  25651. setNormals(data: Nullable<FloatArray>): void;
  25652. /**
  25653. * Gets the normal data stored in this target
  25654. * @returns a FloatArray containing the normal data (or null if not present)
  25655. */
  25656. getNormals(): Nullable<FloatArray>;
  25657. /**
  25658. * Affects tangent data to this target
  25659. * @param data defines the tangent data to use
  25660. */
  25661. setTangents(data: Nullable<FloatArray>): void;
  25662. /**
  25663. * Gets the tangent data stored in this target
  25664. * @returns a FloatArray containing the tangent data (or null if not present)
  25665. */
  25666. getTangents(): Nullable<FloatArray>;
  25667. /**
  25668. * Affects texture coordinates data to this target
  25669. * @param data defines the texture coordinates data to use
  25670. */
  25671. setUVs(data: Nullable<FloatArray>): void;
  25672. /**
  25673. * Gets the texture coordinates data stored in this target
  25674. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  25675. */
  25676. getUVs(): Nullable<FloatArray>;
  25677. /**
  25678. * Clone the current target
  25679. * @returns a new MorphTarget
  25680. */
  25681. clone(): MorphTarget;
  25682. /**
  25683. * Serializes the current target into a Serialization object
  25684. * @returns the serialized object
  25685. */
  25686. serialize(): any;
  25687. /**
  25688. * Returns the string "MorphTarget"
  25689. * @returns "MorphTarget"
  25690. */
  25691. getClassName(): string;
  25692. /**
  25693. * Creates a new target from serialized data
  25694. * @param serializationObject defines the serialized data to use
  25695. * @returns a new MorphTarget
  25696. */
  25697. static Parse(serializationObject: any): MorphTarget;
  25698. /**
  25699. * Creates a MorphTarget from mesh data
  25700. * @param mesh defines the source mesh
  25701. * @param name defines the name to use for the new target
  25702. * @param influence defines the influence to attach to the target
  25703. * @returns a new MorphTarget
  25704. */
  25705. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  25706. }
  25707. }
  25708. declare module BABYLON {
  25709. /**
  25710. * This class is used to deform meshes using morphing between different targets
  25711. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25712. */
  25713. export class MorphTargetManager {
  25714. private _targets;
  25715. private _targetInfluenceChangedObservers;
  25716. private _targetDataLayoutChangedObservers;
  25717. private _activeTargets;
  25718. private _scene;
  25719. private _influences;
  25720. private _supportsNormals;
  25721. private _supportsTangents;
  25722. private _supportsUVs;
  25723. private _vertexCount;
  25724. private _uniqueId;
  25725. private _tempInfluences;
  25726. /**
  25727. * Gets or sets a boolean indicating if normals must be morphed
  25728. */
  25729. enableNormalMorphing: boolean;
  25730. /**
  25731. * Gets or sets a boolean indicating if tangents must be morphed
  25732. */
  25733. enableTangentMorphing: boolean;
  25734. /**
  25735. * Gets or sets a boolean indicating if UV must be morphed
  25736. */
  25737. enableUVMorphing: boolean;
  25738. /**
  25739. * Creates a new MorphTargetManager
  25740. * @param scene defines the current scene
  25741. */
  25742. constructor(scene?: Nullable<Scene>);
  25743. /**
  25744. * Gets the unique ID of this manager
  25745. */
  25746. get uniqueId(): number;
  25747. /**
  25748. * Gets the number of vertices handled by this manager
  25749. */
  25750. get vertexCount(): number;
  25751. /**
  25752. * Gets a boolean indicating if this manager supports morphing of normals
  25753. */
  25754. get supportsNormals(): boolean;
  25755. /**
  25756. * Gets a boolean indicating if this manager supports morphing of tangents
  25757. */
  25758. get supportsTangents(): boolean;
  25759. /**
  25760. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  25761. */
  25762. get supportsUVs(): boolean;
  25763. /**
  25764. * Gets the number of targets stored in this manager
  25765. */
  25766. get numTargets(): number;
  25767. /**
  25768. * Gets the number of influencers (ie. the number of targets with influences > 0)
  25769. */
  25770. get numInfluencers(): number;
  25771. /**
  25772. * Gets the list of influences (one per target)
  25773. */
  25774. get influences(): Float32Array;
  25775. /**
  25776. * Gets the active target at specified index. An active target is a target with an influence > 0
  25777. * @param index defines the index to check
  25778. * @returns the requested target
  25779. */
  25780. getActiveTarget(index: number): MorphTarget;
  25781. /**
  25782. * Gets the target at specified index
  25783. * @param index defines the index to check
  25784. * @returns the requested target
  25785. */
  25786. getTarget(index: number): MorphTarget;
  25787. /**
  25788. * Add a new target to this manager
  25789. * @param target defines the target to add
  25790. */
  25791. addTarget(target: MorphTarget): void;
  25792. /**
  25793. * Removes a target from the manager
  25794. * @param target defines the target to remove
  25795. */
  25796. removeTarget(target: MorphTarget): void;
  25797. /**
  25798. * Clone the current manager
  25799. * @returns a new MorphTargetManager
  25800. */
  25801. clone(): MorphTargetManager;
  25802. /**
  25803. * Serializes the current manager into a Serialization object
  25804. * @returns the serialized object
  25805. */
  25806. serialize(): any;
  25807. private _syncActiveTargets;
  25808. /**
  25809. * Syncrhonize the targets with all the meshes using this morph target manager
  25810. */
  25811. synchronize(): void;
  25812. /**
  25813. * Creates a new MorphTargetManager from serialized data
  25814. * @param serializationObject defines the serialized data
  25815. * @param scene defines the hosting scene
  25816. * @returns the new MorphTargetManager
  25817. */
  25818. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  25819. }
  25820. }
  25821. declare module BABYLON {
  25822. /**
  25823. * Class used to represent a specific level of detail of a mesh
  25824. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25825. */
  25826. export class MeshLODLevel {
  25827. /** Defines the distance where this level should start being displayed */
  25828. distance: number;
  25829. /** Defines the mesh to use to render this level */
  25830. mesh: Nullable<Mesh>;
  25831. /**
  25832. * Creates a new LOD level
  25833. * @param distance defines the distance where this level should star being displayed
  25834. * @param mesh defines the mesh to use to render this level
  25835. */
  25836. constructor(
  25837. /** Defines the distance where this level should start being displayed */
  25838. distance: number,
  25839. /** Defines the mesh to use to render this level */
  25840. mesh: Nullable<Mesh>);
  25841. }
  25842. }
  25843. declare module BABYLON {
  25844. /**
  25845. * Helper class used to generate a canvas to manipulate images
  25846. */
  25847. export class CanvasGenerator {
  25848. /**
  25849. * Create a new canvas (or offscreen canvas depending on the context)
  25850. * @param width defines the expected width
  25851. * @param height defines the expected height
  25852. * @return a new canvas or offscreen canvas
  25853. */
  25854. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  25855. }
  25856. }
  25857. declare module BABYLON {
  25858. /**
  25859. * Mesh representing the gorund
  25860. */
  25861. export class GroundMesh extends Mesh {
  25862. /** If octree should be generated */
  25863. generateOctree: boolean;
  25864. private _heightQuads;
  25865. /** @hidden */
  25866. _subdivisionsX: number;
  25867. /** @hidden */
  25868. _subdivisionsY: number;
  25869. /** @hidden */
  25870. _width: number;
  25871. /** @hidden */
  25872. _height: number;
  25873. /** @hidden */
  25874. _minX: number;
  25875. /** @hidden */
  25876. _maxX: number;
  25877. /** @hidden */
  25878. _minZ: number;
  25879. /** @hidden */
  25880. _maxZ: number;
  25881. constructor(name: string, scene: Scene);
  25882. /**
  25883. * "GroundMesh"
  25884. * @returns "GroundMesh"
  25885. */
  25886. getClassName(): string;
  25887. /**
  25888. * The minimum of x and y subdivisions
  25889. */
  25890. get subdivisions(): number;
  25891. /**
  25892. * X subdivisions
  25893. */
  25894. get subdivisionsX(): number;
  25895. /**
  25896. * Y subdivisions
  25897. */
  25898. get subdivisionsY(): number;
  25899. /**
  25900. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  25901. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  25902. * @param chunksCount the number of subdivisions for x and y
  25903. * @param octreeBlocksSize (Default: 32)
  25904. */
  25905. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  25906. /**
  25907. * Returns a height (y) value in the Worl system :
  25908. * the ground altitude at the coordinates (x, z) expressed in the World system.
  25909. * @param x x coordinate
  25910. * @param z z coordinate
  25911. * @returns the ground y position if (x, z) are outside the ground surface.
  25912. */
  25913. getHeightAtCoordinates(x: number, z: number): number;
  25914. /**
  25915. * Returns a normalized vector (Vector3) orthogonal to the ground
  25916. * at the ground coordinates (x, z) expressed in the World system.
  25917. * @param x x coordinate
  25918. * @param z z coordinate
  25919. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  25920. */
  25921. getNormalAtCoordinates(x: number, z: number): Vector3;
  25922. /**
  25923. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  25924. * at the ground coordinates (x, z) expressed in the World system.
  25925. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  25926. * @param x x coordinate
  25927. * @param z z coordinate
  25928. * @param ref vector to store the result
  25929. * @returns the GroundMesh.
  25930. */
  25931. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  25932. /**
  25933. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  25934. * if the ground has been updated.
  25935. * This can be used in the render loop.
  25936. * @returns the GroundMesh.
  25937. */
  25938. updateCoordinateHeights(): GroundMesh;
  25939. private _getFacetAt;
  25940. private _initHeightQuads;
  25941. private _computeHeightQuads;
  25942. /**
  25943. * Serializes this ground mesh
  25944. * @param serializationObject object to write serialization to
  25945. */
  25946. serialize(serializationObject: any): void;
  25947. /**
  25948. * Parses a serialized ground mesh
  25949. * @param parsedMesh the serialized mesh
  25950. * @param scene the scene to create the ground mesh in
  25951. * @returns the created ground mesh
  25952. */
  25953. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  25954. }
  25955. }
  25956. declare module BABYLON {
  25957. /**
  25958. * Interface for Physics-Joint data
  25959. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  25960. */
  25961. export interface PhysicsJointData {
  25962. /**
  25963. * The main pivot of the joint
  25964. */
  25965. mainPivot?: Vector3;
  25966. /**
  25967. * The connected pivot of the joint
  25968. */
  25969. connectedPivot?: Vector3;
  25970. /**
  25971. * The main axis of the joint
  25972. */
  25973. mainAxis?: Vector3;
  25974. /**
  25975. * The connected axis of the joint
  25976. */
  25977. connectedAxis?: Vector3;
  25978. /**
  25979. * The collision of the joint
  25980. */
  25981. collision?: boolean;
  25982. /**
  25983. * Native Oimo/Cannon/Energy data
  25984. */
  25985. nativeParams?: any;
  25986. }
  25987. /**
  25988. * This is a holder class for the physics joint created by the physics plugin
  25989. * It holds a set of functions to control the underlying joint
  25990. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  25991. */
  25992. export class PhysicsJoint {
  25993. /**
  25994. * The type of the physics joint
  25995. */
  25996. type: number;
  25997. /**
  25998. * The data for the physics joint
  25999. */
  26000. jointData: PhysicsJointData;
  26001. private _physicsJoint;
  26002. protected _physicsPlugin: IPhysicsEnginePlugin;
  26003. /**
  26004. * Initializes the physics joint
  26005. * @param type The type of the physics joint
  26006. * @param jointData The data for the physics joint
  26007. */
  26008. constructor(
  26009. /**
  26010. * The type of the physics joint
  26011. */
  26012. type: number,
  26013. /**
  26014. * The data for the physics joint
  26015. */
  26016. jointData: PhysicsJointData);
  26017. /**
  26018. * Gets the physics joint
  26019. */
  26020. get physicsJoint(): any;
  26021. /**
  26022. * Sets the physics joint
  26023. */
  26024. set physicsJoint(newJoint: any);
  26025. /**
  26026. * Sets the physics plugin
  26027. */
  26028. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26029. /**
  26030. * Execute a function that is physics-plugin specific.
  26031. * @param {Function} func the function that will be executed.
  26032. * It accepts two parameters: the physics world and the physics joint
  26033. */
  26034. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26035. /**
  26036. * Distance-Joint type
  26037. */
  26038. static DistanceJoint: number;
  26039. /**
  26040. * Hinge-Joint type
  26041. */
  26042. static HingeJoint: number;
  26043. /**
  26044. * Ball-and-Socket joint type
  26045. */
  26046. static BallAndSocketJoint: number;
  26047. /**
  26048. * Wheel-Joint type
  26049. */
  26050. static WheelJoint: number;
  26051. /**
  26052. * Slider-Joint type
  26053. */
  26054. static SliderJoint: number;
  26055. /**
  26056. * Prismatic-Joint type
  26057. */
  26058. static PrismaticJoint: number;
  26059. /**
  26060. * Universal-Joint type
  26061. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  26062. */
  26063. static UniversalJoint: number;
  26064. /**
  26065. * Hinge-Joint 2 type
  26066. */
  26067. static Hinge2Joint: number;
  26068. /**
  26069. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  26070. */
  26071. static PointToPointJoint: number;
  26072. /**
  26073. * Spring-Joint type
  26074. */
  26075. static SpringJoint: number;
  26076. /**
  26077. * Lock-Joint type
  26078. */
  26079. static LockJoint: number;
  26080. }
  26081. /**
  26082. * A class representing a physics distance joint
  26083. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26084. */
  26085. export class DistanceJoint extends PhysicsJoint {
  26086. /**
  26087. *
  26088. * @param jointData The data for the Distance-Joint
  26089. */
  26090. constructor(jointData: DistanceJointData);
  26091. /**
  26092. * Update the predefined distance.
  26093. * @param maxDistance The maximum preferred distance
  26094. * @param minDistance The minimum preferred distance
  26095. */
  26096. updateDistance(maxDistance: number, minDistance?: number): void;
  26097. }
  26098. /**
  26099. * Represents a Motor-Enabled Joint
  26100. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26101. */
  26102. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  26103. /**
  26104. * Initializes the Motor-Enabled Joint
  26105. * @param type The type of the joint
  26106. * @param jointData The physica joint data for the joint
  26107. */
  26108. constructor(type: number, jointData: PhysicsJointData);
  26109. /**
  26110. * Set the motor values.
  26111. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26112. * @param force the force to apply
  26113. * @param maxForce max force for this motor.
  26114. */
  26115. setMotor(force?: number, maxForce?: number): void;
  26116. /**
  26117. * Set the motor's limits.
  26118. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26119. * @param upperLimit The upper limit of the motor
  26120. * @param lowerLimit The lower limit of the motor
  26121. */
  26122. setLimit(upperLimit: number, lowerLimit?: number): void;
  26123. }
  26124. /**
  26125. * This class represents a single physics Hinge-Joint
  26126. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26127. */
  26128. export class HingeJoint extends MotorEnabledJoint {
  26129. /**
  26130. * Initializes the Hinge-Joint
  26131. * @param jointData The joint data for the Hinge-Joint
  26132. */
  26133. constructor(jointData: PhysicsJointData);
  26134. /**
  26135. * Set the motor values.
  26136. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26137. * @param {number} force the force to apply
  26138. * @param {number} maxForce max force for this motor.
  26139. */
  26140. setMotor(force?: number, maxForce?: number): void;
  26141. /**
  26142. * Set the motor's limits.
  26143. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26144. * @param upperLimit The upper limit of the motor
  26145. * @param lowerLimit The lower limit of the motor
  26146. */
  26147. setLimit(upperLimit: number, lowerLimit?: number): void;
  26148. }
  26149. /**
  26150. * This class represents a dual hinge physics joint (same as wheel joint)
  26151. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26152. */
  26153. export class Hinge2Joint extends MotorEnabledJoint {
  26154. /**
  26155. * Initializes the Hinge2-Joint
  26156. * @param jointData The joint data for the Hinge2-Joint
  26157. */
  26158. constructor(jointData: PhysicsJointData);
  26159. /**
  26160. * Set the motor values.
  26161. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26162. * @param {number} targetSpeed the speed the motor is to reach
  26163. * @param {number} maxForce max force for this motor.
  26164. * @param {motorIndex} the motor's index, 0 or 1.
  26165. */
  26166. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  26167. /**
  26168. * Set the motor limits.
  26169. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26170. * @param {number} upperLimit the upper limit
  26171. * @param {number} lowerLimit lower limit
  26172. * @param {motorIndex} the motor's index, 0 or 1.
  26173. */
  26174. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26175. }
  26176. /**
  26177. * Interface for a motor enabled joint
  26178. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26179. */
  26180. export interface IMotorEnabledJoint {
  26181. /**
  26182. * Physics joint
  26183. */
  26184. physicsJoint: any;
  26185. /**
  26186. * Sets the motor of the motor-enabled joint
  26187. * @param force The force of the motor
  26188. * @param maxForce The maximum force of the motor
  26189. * @param motorIndex The index of the motor
  26190. */
  26191. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  26192. /**
  26193. * Sets the limit of the motor
  26194. * @param upperLimit The upper limit of the motor
  26195. * @param lowerLimit The lower limit of the motor
  26196. * @param motorIndex The index of the motor
  26197. */
  26198. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26199. }
  26200. /**
  26201. * Joint data for a Distance-Joint
  26202. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26203. */
  26204. export interface DistanceJointData extends PhysicsJointData {
  26205. /**
  26206. * Max distance the 2 joint objects can be apart
  26207. */
  26208. maxDistance: number;
  26209. }
  26210. /**
  26211. * Joint data from a spring joint
  26212. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26213. */
  26214. export interface SpringJointData extends PhysicsJointData {
  26215. /**
  26216. * Length of the spring
  26217. */
  26218. length: number;
  26219. /**
  26220. * Stiffness of the spring
  26221. */
  26222. stiffness: number;
  26223. /**
  26224. * Damping of the spring
  26225. */
  26226. damping: number;
  26227. /** this callback will be called when applying the force to the impostors. */
  26228. forceApplicationCallback: () => void;
  26229. }
  26230. }
  26231. declare module BABYLON {
  26232. /**
  26233. * Holds the data for the raycast result
  26234. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26235. */
  26236. export class PhysicsRaycastResult {
  26237. private _hasHit;
  26238. private _hitDistance;
  26239. private _hitNormalWorld;
  26240. private _hitPointWorld;
  26241. private _rayFromWorld;
  26242. private _rayToWorld;
  26243. /**
  26244. * Gets if there was a hit
  26245. */
  26246. get hasHit(): boolean;
  26247. /**
  26248. * Gets the distance from the hit
  26249. */
  26250. get hitDistance(): number;
  26251. /**
  26252. * Gets the hit normal/direction in the world
  26253. */
  26254. get hitNormalWorld(): Vector3;
  26255. /**
  26256. * Gets the hit point in the world
  26257. */
  26258. get hitPointWorld(): Vector3;
  26259. /**
  26260. * Gets the ray "start point" of the ray in the world
  26261. */
  26262. get rayFromWorld(): Vector3;
  26263. /**
  26264. * Gets the ray "end point" of the ray in the world
  26265. */
  26266. get rayToWorld(): Vector3;
  26267. /**
  26268. * Sets the hit data (normal & point in world space)
  26269. * @param hitNormalWorld defines the normal in world space
  26270. * @param hitPointWorld defines the point in world space
  26271. */
  26272. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  26273. /**
  26274. * Sets the distance from the start point to the hit point
  26275. * @param distance
  26276. */
  26277. setHitDistance(distance: number): void;
  26278. /**
  26279. * Calculates the distance manually
  26280. */
  26281. calculateHitDistance(): void;
  26282. /**
  26283. * Resets all the values to default
  26284. * @param from The from point on world space
  26285. * @param to The to point on world space
  26286. */
  26287. reset(from?: Vector3, to?: Vector3): void;
  26288. }
  26289. /**
  26290. * Interface for the size containing width and height
  26291. */
  26292. interface IXYZ {
  26293. /**
  26294. * X
  26295. */
  26296. x: number;
  26297. /**
  26298. * Y
  26299. */
  26300. y: number;
  26301. /**
  26302. * Z
  26303. */
  26304. z: number;
  26305. }
  26306. }
  26307. declare module BABYLON {
  26308. /**
  26309. * Interface used to describe a physics joint
  26310. */
  26311. export interface PhysicsImpostorJoint {
  26312. /** Defines the main impostor to which the joint is linked */
  26313. mainImpostor: PhysicsImpostor;
  26314. /** Defines the impostor that is connected to the main impostor using this joint */
  26315. connectedImpostor: PhysicsImpostor;
  26316. /** Defines the joint itself */
  26317. joint: PhysicsJoint;
  26318. }
  26319. /** @hidden */
  26320. export interface IPhysicsEnginePlugin {
  26321. world: any;
  26322. name: string;
  26323. setGravity(gravity: Vector3): void;
  26324. setTimeStep(timeStep: number): void;
  26325. getTimeStep(): number;
  26326. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  26327. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26328. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26329. generatePhysicsBody(impostor: PhysicsImpostor): void;
  26330. removePhysicsBody(impostor: PhysicsImpostor): void;
  26331. generateJoint(joint: PhysicsImpostorJoint): void;
  26332. removeJoint(joint: PhysicsImpostorJoint): void;
  26333. isSupported(): boolean;
  26334. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  26335. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  26336. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26337. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26338. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26339. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26340. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  26341. getBodyMass(impostor: PhysicsImpostor): number;
  26342. getBodyFriction(impostor: PhysicsImpostor): number;
  26343. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  26344. getBodyRestitution(impostor: PhysicsImpostor): number;
  26345. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  26346. getBodyPressure?(impostor: PhysicsImpostor): number;
  26347. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  26348. getBodyStiffness?(impostor: PhysicsImpostor): number;
  26349. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  26350. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  26351. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  26352. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  26353. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  26354. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26355. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26356. sleepBody(impostor: PhysicsImpostor): void;
  26357. wakeUpBody(impostor: PhysicsImpostor): void;
  26358. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26359. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  26360. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  26361. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26362. getRadius(impostor: PhysicsImpostor): number;
  26363. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  26364. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  26365. dispose(): void;
  26366. }
  26367. /**
  26368. * Interface used to define a physics engine
  26369. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  26370. */
  26371. export interface IPhysicsEngine {
  26372. /**
  26373. * Gets the gravity vector used by the simulation
  26374. */
  26375. gravity: Vector3;
  26376. /**
  26377. * Sets the gravity vector used by the simulation
  26378. * @param gravity defines the gravity vector to use
  26379. */
  26380. setGravity(gravity: Vector3): void;
  26381. /**
  26382. * Set the time step of the physics engine.
  26383. * Default is 1/60.
  26384. * To slow it down, enter 1/600 for example.
  26385. * To speed it up, 1/30
  26386. * @param newTimeStep the new timestep to apply to this world.
  26387. */
  26388. setTimeStep(newTimeStep: number): void;
  26389. /**
  26390. * Get the time step of the physics engine.
  26391. * @returns the current time step
  26392. */
  26393. getTimeStep(): number;
  26394. /**
  26395. * Set the sub time step of the physics engine.
  26396. * Default is 0 meaning there is no sub steps
  26397. * To increase physics resolution precision, set a small value (like 1 ms)
  26398. * @param subTimeStep defines the new sub timestep used for physics resolution.
  26399. */
  26400. setSubTimeStep(subTimeStep: number): void;
  26401. /**
  26402. * Get the sub time step of the physics engine.
  26403. * @returns the current sub time step
  26404. */
  26405. getSubTimeStep(): number;
  26406. /**
  26407. * Release all resources
  26408. */
  26409. dispose(): void;
  26410. /**
  26411. * Gets the name of the current physics plugin
  26412. * @returns the name of the plugin
  26413. */
  26414. getPhysicsPluginName(): string;
  26415. /**
  26416. * Adding a new impostor for the impostor tracking.
  26417. * This will be done by the impostor itself.
  26418. * @param impostor the impostor to add
  26419. */
  26420. addImpostor(impostor: PhysicsImpostor): void;
  26421. /**
  26422. * Remove an impostor from the engine.
  26423. * This impostor and its mesh will not longer be updated by the physics engine.
  26424. * @param impostor the impostor to remove
  26425. */
  26426. removeImpostor(impostor: PhysicsImpostor): void;
  26427. /**
  26428. * Add a joint to the physics engine
  26429. * @param mainImpostor defines the main impostor to which the joint is added.
  26430. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  26431. * @param joint defines the joint that will connect both impostors.
  26432. */
  26433. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26434. /**
  26435. * Removes a joint from the simulation
  26436. * @param mainImpostor defines the impostor used with the joint
  26437. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  26438. * @param joint defines the joint to remove
  26439. */
  26440. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26441. /**
  26442. * Gets the current plugin used to run the simulation
  26443. * @returns current plugin
  26444. */
  26445. getPhysicsPlugin(): IPhysicsEnginePlugin;
  26446. /**
  26447. * Gets the list of physic impostors
  26448. * @returns an array of PhysicsImpostor
  26449. */
  26450. getImpostors(): Array<PhysicsImpostor>;
  26451. /**
  26452. * Gets the impostor for a physics enabled object
  26453. * @param object defines the object impersonated by the impostor
  26454. * @returns the PhysicsImpostor or null if not found
  26455. */
  26456. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  26457. /**
  26458. * Gets the impostor for a physics body object
  26459. * @param body defines physics body used by the impostor
  26460. * @returns the PhysicsImpostor or null if not found
  26461. */
  26462. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  26463. /**
  26464. * Does a raycast in the physics world
  26465. * @param from when should the ray start?
  26466. * @param to when should the ray end?
  26467. * @returns PhysicsRaycastResult
  26468. */
  26469. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26470. /**
  26471. * Called by the scene. No need to call it.
  26472. * @param delta defines the timespam between frames
  26473. */
  26474. _step(delta: number): void;
  26475. }
  26476. }
  26477. declare module BABYLON {
  26478. /**
  26479. * The interface for the physics imposter parameters
  26480. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26481. */
  26482. export interface PhysicsImpostorParameters {
  26483. /**
  26484. * The mass of the physics imposter
  26485. */
  26486. mass: number;
  26487. /**
  26488. * The friction of the physics imposter
  26489. */
  26490. friction?: number;
  26491. /**
  26492. * The coefficient of restitution of the physics imposter
  26493. */
  26494. restitution?: number;
  26495. /**
  26496. * The native options of the physics imposter
  26497. */
  26498. nativeOptions?: any;
  26499. /**
  26500. * Specifies if the parent should be ignored
  26501. */
  26502. ignoreParent?: boolean;
  26503. /**
  26504. * Specifies if bi-directional transformations should be disabled
  26505. */
  26506. disableBidirectionalTransformation?: boolean;
  26507. /**
  26508. * The pressure inside the physics imposter, soft object only
  26509. */
  26510. pressure?: number;
  26511. /**
  26512. * The stiffness the physics imposter, soft object only
  26513. */
  26514. stiffness?: number;
  26515. /**
  26516. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  26517. */
  26518. velocityIterations?: number;
  26519. /**
  26520. * The number of iterations used in maintaining consistent vertex positions, soft object only
  26521. */
  26522. positionIterations?: number;
  26523. /**
  26524. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  26525. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  26526. * Add to fix multiple points
  26527. */
  26528. fixedPoints?: number;
  26529. /**
  26530. * The collision margin around a soft object
  26531. */
  26532. margin?: number;
  26533. /**
  26534. * The collision margin around a soft object
  26535. */
  26536. damping?: number;
  26537. /**
  26538. * The path for a rope based on an extrusion
  26539. */
  26540. path?: any;
  26541. /**
  26542. * The shape of an extrusion used for a rope based on an extrusion
  26543. */
  26544. shape?: any;
  26545. }
  26546. /**
  26547. * Interface for a physics-enabled object
  26548. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26549. */
  26550. export interface IPhysicsEnabledObject {
  26551. /**
  26552. * The position of the physics-enabled object
  26553. */
  26554. position: Vector3;
  26555. /**
  26556. * The rotation of the physics-enabled object
  26557. */
  26558. rotationQuaternion: Nullable<Quaternion>;
  26559. /**
  26560. * The scale of the physics-enabled object
  26561. */
  26562. scaling: Vector3;
  26563. /**
  26564. * The rotation of the physics-enabled object
  26565. */
  26566. rotation?: Vector3;
  26567. /**
  26568. * The parent of the physics-enabled object
  26569. */
  26570. parent?: any;
  26571. /**
  26572. * The bounding info of the physics-enabled object
  26573. * @returns The bounding info of the physics-enabled object
  26574. */
  26575. getBoundingInfo(): BoundingInfo;
  26576. /**
  26577. * Computes the world matrix
  26578. * @param force Specifies if the world matrix should be computed by force
  26579. * @returns A world matrix
  26580. */
  26581. computeWorldMatrix(force: boolean): Matrix;
  26582. /**
  26583. * Gets the world matrix
  26584. * @returns A world matrix
  26585. */
  26586. getWorldMatrix?(): Matrix;
  26587. /**
  26588. * Gets the child meshes
  26589. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  26590. * @returns An array of abstract meshes
  26591. */
  26592. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  26593. /**
  26594. * Gets the vertex data
  26595. * @param kind The type of vertex data
  26596. * @returns A nullable array of numbers, or a float32 array
  26597. */
  26598. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  26599. /**
  26600. * Gets the indices from the mesh
  26601. * @returns A nullable array of index arrays
  26602. */
  26603. getIndices?(): Nullable<IndicesArray>;
  26604. /**
  26605. * Gets the scene from the mesh
  26606. * @returns the indices array or null
  26607. */
  26608. getScene?(): Scene;
  26609. /**
  26610. * Gets the absolute position from the mesh
  26611. * @returns the absolute position
  26612. */
  26613. getAbsolutePosition(): Vector3;
  26614. /**
  26615. * Gets the absolute pivot point from the mesh
  26616. * @returns the absolute pivot point
  26617. */
  26618. getAbsolutePivotPoint(): Vector3;
  26619. /**
  26620. * Rotates the mesh
  26621. * @param axis The axis of rotation
  26622. * @param amount The amount of rotation
  26623. * @param space The space of the rotation
  26624. * @returns The rotation transform node
  26625. */
  26626. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26627. /**
  26628. * Translates the mesh
  26629. * @param axis The axis of translation
  26630. * @param distance The distance of translation
  26631. * @param space The space of the translation
  26632. * @returns The transform node
  26633. */
  26634. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26635. /**
  26636. * Sets the absolute position of the mesh
  26637. * @param absolutePosition The absolute position of the mesh
  26638. * @returns The transform node
  26639. */
  26640. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26641. /**
  26642. * Gets the class name of the mesh
  26643. * @returns The class name
  26644. */
  26645. getClassName(): string;
  26646. }
  26647. /**
  26648. * Represents a physics imposter
  26649. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26650. */
  26651. export class PhysicsImpostor {
  26652. /**
  26653. * The physics-enabled object used as the physics imposter
  26654. */
  26655. object: IPhysicsEnabledObject;
  26656. /**
  26657. * The type of the physics imposter
  26658. */
  26659. type: number;
  26660. private _options;
  26661. private _scene?;
  26662. /**
  26663. * The default object size of the imposter
  26664. */
  26665. static DEFAULT_OBJECT_SIZE: Vector3;
  26666. /**
  26667. * The identity quaternion of the imposter
  26668. */
  26669. static IDENTITY_QUATERNION: Quaternion;
  26670. /** @hidden */
  26671. _pluginData: any;
  26672. private _physicsEngine;
  26673. private _physicsBody;
  26674. private _bodyUpdateRequired;
  26675. private _onBeforePhysicsStepCallbacks;
  26676. private _onAfterPhysicsStepCallbacks;
  26677. /** @hidden */
  26678. _onPhysicsCollideCallbacks: Array<{
  26679. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  26680. otherImpostors: Array<PhysicsImpostor>;
  26681. }>;
  26682. private _deltaPosition;
  26683. private _deltaRotation;
  26684. private _deltaRotationConjugated;
  26685. /** @hidden */
  26686. _isFromLine: boolean;
  26687. private _parent;
  26688. private _isDisposed;
  26689. private static _tmpVecs;
  26690. private static _tmpQuat;
  26691. /**
  26692. * Specifies if the physics imposter is disposed
  26693. */
  26694. get isDisposed(): boolean;
  26695. /**
  26696. * Gets the mass of the physics imposter
  26697. */
  26698. get mass(): number;
  26699. set mass(value: number);
  26700. /**
  26701. * Gets the coefficient of friction
  26702. */
  26703. get friction(): number;
  26704. /**
  26705. * Sets the coefficient of friction
  26706. */
  26707. set friction(value: number);
  26708. /**
  26709. * Gets the coefficient of restitution
  26710. */
  26711. get restitution(): number;
  26712. /**
  26713. * Sets the coefficient of restitution
  26714. */
  26715. set restitution(value: number);
  26716. /**
  26717. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  26718. */
  26719. get pressure(): number;
  26720. /**
  26721. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  26722. */
  26723. set pressure(value: number);
  26724. /**
  26725. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26726. */
  26727. get stiffness(): number;
  26728. /**
  26729. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26730. */
  26731. set stiffness(value: number);
  26732. /**
  26733. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26734. */
  26735. get velocityIterations(): number;
  26736. /**
  26737. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26738. */
  26739. set velocityIterations(value: number);
  26740. /**
  26741. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26742. */
  26743. get positionIterations(): number;
  26744. /**
  26745. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26746. */
  26747. set positionIterations(value: number);
  26748. /**
  26749. * The unique id of the physics imposter
  26750. * set by the physics engine when adding this impostor to the array
  26751. */
  26752. uniqueId: number;
  26753. /**
  26754. * @hidden
  26755. */
  26756. soft: boolean;
  26757. /**
  26758. * @hidden
  26759. */
  26760. segments: number;
  26761. private _joints;
  26762. /**
  26763. * Initializes the physics imposter
  26764. * @param object The physics-enabled object used as the physics imposter
  26765. * @param type The type of the physics imposter
  26766. * @param _options The options for the physics imposter
  26767. * @param _scene The Babylon scene
  26768. */
  26769. constructor(
  26770. /**
  26771. * The physics-enabled object used as the physics imposter
  26772. */
  26773. object: IPhysicsEnabledObject,
  26774. /**
  26775. * The type of the physics imposter
  26776. */
  26777. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  26778. /**
  26779. * This function will completly initialize this impostor.
  26780. * It will create a new body - but only if this mesh has no parent.
  26781. * If it has, this impostor will not be used other than to define the impostor
  26782. * of the child mesh.
  26783. * @hidden
  26784. */
  26785. _init(): void;
  26786. private _getPhysicsParent;
  26787. /**
  26788. * Should a new body be generated.
  26789. * @returns boolean specifying if body initialization is required
  26790. */
  26791. isBodyInitRequired(): boolean;
  26792. /**
  26793. * Sets the updated scaling
  26794. * @param updated Specifies if the scaling is updated
  26795. */
  26796. setScalingUpdated(): void;
  26797. /**
  26798. * Force a regeneration of this or the parent's impostor's body.
  26799. * Use under cautious - This will remove all joints already implemented.
  26800. */
  26801. forceUpdate(): void;
  26802. /**
  26803. * Gets the body that holds this impostor. Either its own, or its parent.
  26804. */
  26805. get physicsBody(): any;
  26806. /**
  26807. * Get the parent of the physics imposter
  26808. * @returns Physics imposter or null
  26809. */
  26810. get parent(): Nullable<PhysicsImpostor>;
  26811. /**
  26812. * Sets the parent of the physics imposter
  26813. */
  26814. set parent(value: Nullable<PhysicsImpostor>);
  26815. /**
  26816. * Set the physics body. Used mainly by the physics engine/plugin
  26817. */
  26818. set physicsBody(physicsBody: any);
  26819. /**
  26820. * Resets the update flags
  26821. */
  26822. resetUpdateFlags(): void;
  26823. /**
  26824. * Gets the object extend size
  26825. * @returns the object extend size
  26826. */
  26827. getObjectExtendSize(): Vector3;
  26828. /**
  26829. * Gets the object center
  26830. * @returns The object center
  26831. */
  26832. getObjectCenter(): Vector3;
  26833. /**
  26834. * Get a specific parameter from the options parameters
  26835. * @param paramName The object parameter name
  26836. * @returns The object parameter
  26837. */
  26838. getParam(paramName: string): any;
  26839. /**
  26840. * Sets a specific parameter in the options given to the physics plugin
  26841. * @param paramName The parameter name
  26842. * @param value The value of the parameter
  26843. */
  26844. setParam(paramName: string, value: number): void;
  26845. /**
  26846. * Specifically change the body's mass option. Won't recreate the physics body object
  26847. * @param mass The mass of the physics imposter
  26848. */
  26849. setMass(mass: number): void;
  26850. /**
  26851. * Gets the linear velocity
  26852. * @returns linear velocity or null
  26853. */
  26854. getLinearVelocity(): Nullable<Vector3>;
  26855. /**
  26856. * Sets the linear velocity
  26857. * @param velocity linear velocity or null
  26858. */
  26859. setLinearVelocity(velocity: Nullable<Vector3>): void;
  26860. /**
  26861. * Gets the angular velocity
  26862. * @returns angular velocity or null
  26863. */
  26864. getAngularVelocity(): Nullable<Vector3>;
  26865. /**
  26866. * Sets the angular velocity
  26867. * @param velocity The velocity or null
  26868. */
  26869. setAngularVelocity(velocity: Nullable<Vector3>): void;
  26870. /**
  26871. * Execute a function with the physics plugin native code
  26872. * Provide a function the will have two variables - the world object and the physics body object
  26873. * @param func The function to execute with the physics plugin native code
  26874. */
  26875. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  26876. /**
  26877. * Register a function that will be executed before the physics world is stepping forward
  26878. * @param func The function to execute before the physics world is stepped forward
  26879. */
  26880. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26881. /**
  26882. * Unregister a function that will be executed before the physics world is stepping forward
  26883. * @param func The function to execute before the physics world is stepped forward
  26884. */
  26885. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26886. /**
  26887. * Register a function that will be executed after the physics step
  26888. * @param func The function to execute after physics step
  26889. */
  26890. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26891. /**
  26892. * Unregisters a function that will be executed after the physics step
  26893. * @param func The function to execute after physics step
  26894. */
  26895. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26896. /**
  26897. * register a function that will be executed when this impostor collides against a different body
  26898. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  26899. * @param func Callback that is executed on collision
  26900. */
  26901. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  26902. /**
  26903. * Unregisters the physics imposter on contact
  26904. * @param collideAgainst The physics object to collide against
  26905. * @param func Callback to execute on collision
  26906. */
  26907. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  26908. private _tmpQuat;
  26909. private _tmpQuat2;
  26910. /**
  26911. * Get the parent rotation
  26912. * @returns The parent rotation
  26913. */
  26914. getParentsRotation(): Quaternion;
  26915. /**
  26916. * this function is executed by the physics engine.
  26917. */
  26918. beforeStep: () => void;
  26919. /**
  26920. * this function is executed by the physics engine
  26921. */
  26922. afterStep: () => void;
  26923. /**
  26924. * Legacy collision detection event support
  26925. */
  26926. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  26927. /**
  26928. * event and body object due to cannon's event-based architecture.
  26929. */
  26930. onCollide: (e: {
  26931. body: any;
  26932. }) => void;
  26933. /**
  26934. * Apply a force
  26935. * @param force The force to apply
  26936. * @param contactPoint The contact point for the force
  26937. * @returns The physics imposter
  26938. */
  26939. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26940. /**
  26941. * Apply an impulse
  26942. * @param force The impulse force
  26943. * @param contactPoint The contact point for the impulse force
  26944. * @returns The physics imposter
  26945. */
  26946. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26947. /**
  26948. * A help function to create a joint
  26949. * @param otherImpostor A physics imposter used to create a joint
  26950. * @param jointType The type of joint
  26951. * @param jointData The data for the joint
  26952. * @returns The physics imposter
  26953. */
  26954. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  26955. /**
  26956. * Add a joint to this impostor with a different impostor
  26957. * @param otherImpostor A physics imposter used to add a joint
  26958. * @param joint The joint to add
  26959. * @returns The physics imposter
  26960. */
  26961. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  26962. /**
  26963. * Add an anchor to a cloth impostor
  26964. * @param otherImpostor rigid impostor to anchor to
  26965. * @param width ratio across width from 0 to 1
  26966. * @param height ratio up height from 0 to 1
  26967. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  26968. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  26969. * @returns impostor the soft imposter
  26970. */
  26971. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  26972. /**
  26973. * Add a hook to a rope impostor
  26974. * @param otherImpostor rigid impostor to anchor to
  26975. * @param length ratio across rope from 0 to 1
  26976. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  26977. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  26978. * @returns impostor the rope imposter
  26979. */
  26980. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  26981. /**
  26982. * Will keep this body still, in a sleep mode.
  26983. * @returns the physics imposter
  26984. */
  26985. sleep(): PhysicsImpostor;
  26986. /**
  26987. * Wake the body up.
  26988. * @returns The physics imposter
  26989. */
  26990. wakeUp(): PhysicsImpostor;
  26991. /**
  26992. * Clones the physics imposter
  26993. * @param newObject The physics imposter clones to this physics-enabled object
  26994. * @returns A nullable physics imposter
  26995. */
  26996. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  26997. /**
  26998. * Disposes the physics imposter
  26999. */
  27000. dispose(): void;
  27001. /**
  27002. * Sets the delta position
  27003. * @param position The delta position amount
  27004. */
  27005. setDeltaPosition(position: Vector3): void;
  27006. /**
  27007. * Sets the delta rotation
  27008. * @param rotation The delta rotation amount
  27009. */
  27010. setDeltaRotation(rotation: Quaternion): void;
  27011. /**
  27012. * Gets the box size of the physics imposter and stores the result in the input parameter
  27013. * @param result Stores the box size
  27014. * @returns The physics imposter
  27015. */
  27016. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27017. /**
  27018. * Gets the radius of the physics imposter
  27019. * @returns Radius of the physics imposter
  27020. */
  27021. getRadius(): number;
  27022. /**
  27023. * Sync a bone with this impostor
  27024. * @param bone The bone to sync to the impostor.
  27025. * @param boneMesh The mesh that the bone is influencing.
  27026. * @param jointPivot The pivot of the joint / bone in local space.
  27027. * @param distToJoint Optional distance from the impostor to the joint.
  27028. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27029. */
  27030. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27031. /**
  27032. * Sync impostor to a bone
  27033. * @param bone The bone that the impostor will be synced to.
  27034. * @param boneMesh The mesh that the bone is influencing.
  27035. * @param jointPivot The pivot of the joint / bone in local space.
  27036. * @param distToJoint Optional distance from the impostor to the joint.
  27037. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27038. * @param boneAxis Optional vector3 axis the bone is aligned with
  27039. */
  27040. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27041. /**
  27042. * No-Imposter type
  27043. */
  27044. static NoImpostor: number;
  27045. /**
  27046. * Sphere-Imposter type
  27047. */
  27048. static SphereImpostor: number;
  27049. /**
  27050. * Box-Imposter type
  27051. */
  27052. static BoxImpostor: number;
  27053. /**
  27054. * Plane-Imposter type
  27055. */
  27056. static PlaneImpostor: number;
  27057. /**
  27058. * Mesh-imposter type
  27059. */
  27060. static MeshImpostor: number;
  27061. /**
  27062. * Capsule-Impostor type (Ammo.js plugin only)
  27063. */
  27064. static CapsuleImpostor: number;
  27065. /**
  27066. * Cylinder-Imposter type
  27067. */
  27068. static CylinderImpostor: number;
  27069. /**
  27070. * Particle-Imposter type
  27071. */
  27072. static ParticleImpostor: number;
  27073. /**
  27074. * Heightmap-Imposter type
  27075. */
  27076. static HeightmapImpostor: number;
  27077. /**
  27078. * ConvexHull-Impostor type (Ammo.js plugin only)
  27079. */
  27080. static ConvexHullImpostor: number;
  27081. /**
  27082. * Custom-Imposter type (Ammo.js plugin only)
  27083. */
  27084. static CustomImpostor: number;
  27085. /**
  27086. * Rope-Imposter type
  27087. */
  27088. static RopeImpostor: number;
  27089. /**
  27090. * Cloth-Imposter type
  27091. */
  27092. static ClothImpostor: number;
  27093. /**
  27094. * Softbody-Imposter type
  27095. */
  27096. static SoftbodyImpostor: number;
  27097. }
  27098. }
  27099. declare module BABYLON {
  27100. /**
  27101. * @hidden
  27102. **/
  27103. export class _CreationDataStorage {
  27104. closePath?: boolean;
  27105. closeArray?: boolean;
  27106. idx: number[];
  27107. dashSize: number;
  27108. gapSize: number;
  27109. path3D: Path3D;
  27110. pathArray: Vector3[][];
  27111. arc: number;
  27112. radius: number;
  27113. cap: number;
  27114. tessellation: number;
  27115. }
  27116. /**
  27117. * @hidden
  27118. **/
  27119. class _InstanceDataStorage {
  27120. visibleInstances: any;
  27121. batchCache: _InstancesBatch;
  27122. instancesBufferSize: number;
  27123. instancesBuffer: Nullable<Buffer>;
  27124. instancesData: Float32Array;
  27125. overridenInstanceCount: number;
  27126. isFrozen: boolean;
  27127. previousBatch: Nullable<_InstancesBatch>;
  27128. hardwareInstancedRendering: boolean;
  27129. sideOrientation: number;
  27130. manualUpdate: boolean;
  27131. }
  27132. /**
  27133. * @hidden
  27134. **/
  27135. export class _InstancesBatch {
  27136. mustReturn: boolean;
  27137. visibleInstances: Nullable<InstancedMesh[]>[];
  27138. renderSelf: boolean[];
  27139. hardwareInstancedRendering: boolean[];
  27140. }
  27141. /**
  27142. * @hidden
  27143. **/
  27144. class _ThinInstanceDataStorage {
  27145. instancesCount: number;
  27146. matrixBuffer: Nullable<Buffer>;
  27147. matrixBufferSize: number;
  27148. matrixData: Nullable<Float32Array>;
  27149. boundingVectors: Array<Vector3>;
  27150. }
  27151. /**
  27152. * Class used to represent renderable models
  27153. */
  27154. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  27155. /**
  27156. * Mesh side orientation : usually the external or front surface
  27157. */
  27158. static readonly FRONTSIDE: number;
  27159. /**
  27160. * Mesh side orientation : usually the internal or back surface
  27161. */
  27162. static readonly BACKSIDE: number;
  27163. /**
  27164. * Mesh side orientation : both internal and external or front and back surfaces
  27165. */
  27166. static readonly DOUBLESIDE: number;
  27167. /**
  27168. * Mesh side orientation : by default, `FRONTSIDE`
  27169. */
  27170. static readonly DEFAULTSIDE: number;
  27171. /**
  27172. * Mesh cap setting : no cap
  27173. */
  27174. static readonly NO_CAP: number;
  27175. /**
  27176. * Mesh cap setting : one cap at the beginning of the mesh
  27177. */
  27178. static readonly CAP_START: number;
  27179. /**
  27180. * Mesh cap setting : one cap at the end of the mesh
  27181. */
  27182. static readonly CAP_END: number;
  27183. /**
  27184. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  27185. */
  27186. static readonly CAP_ALL: number;
  27187. /**
  27188. * Mesh pattern setting : no flip or rotate
  27189. */
  27190. static readonly NO_FLIP: number;
  27191. /**
  27192. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  27193. */
  27194. static readonly FLIP_TILE: number;
  27195. /**
  27196. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  27197. */
  27198. static readonly ROTATE_TILE: number;
  27199. /**
  27200. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  27201. */
  27202. static readonly FLIP_ROW: number;
  27203. /**
  27204. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  27205. */
  27206. static readonly ROTATE_ROW: number;
  27207. /**
  27208. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  27209. */
  27210. static readonly FLIP_N_ROTATE_TILE: number;
  27211. /**
  27212. * Mesh pattern setting : rotate pattern and rotate
  27213. */
  27214. static readonly FLIP_N_ROTATE_ROW: number;
  27215. /**
  27216. * Mesh tile positioning : part tiles same on left/right or top/bottom
  27217. */
  27218. static readonly CENTER: number;
  27219. /**
  27220. * Mesh tile positioning : part tiles on left
  27221. */
  27222. static readonly LEFT: number;
  27223. /**
  27224. * Mesh tile positioning : part tiles on right
  27225. */
  27226. static readonly RIGHT: number;
  27227. /**
  27228. * Mesh tile positioning : part tiles on top
  27229. */
  27230. static readonly TOP: number;
  27231. /**
  27232. * Mesh tile positioning : part tiles on bottom
  27233. */
  27234. static readonly BOTTOM: number;
  27235. /**
  27236. * Gets the default side orientation.
  27237. * @param orientation the orientation to value to attempt to get
  27238. * @returns the default orientation
  27239. * @hidden
  27240. */
  27241. static _GetDefaultSideOrientation(orientation?: number): number;
  27242. private _internalMeshDataInfo;
  27243. /**
  27244. * An event triggered before rendering the mesh
  27245. */
  27246. get onBeforeRenderObservable(): Observable<Mesh>;
  27247. /**
  27248. * An event triggered before binding the mesh
  27249. */
  27250. get onBeforeBindObservable(): Observable<Mesh>;
  27251. /**
  27252. * An event triggered after rendering the mesh
  27253. */
  27254. get onAfterRenderObservable(): Observable<Mesh>;
  27255. /**
  27256. * An event triggered before drawing the mesh
  27257. */
  27258. get onBeforeDrawObservable(): Observable<Mesh>;
  27259. private _onBeforeDrawObserver;
  27260. /**
  27261. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  27262. */
  27263. set onBeforeDraw(callback: () => void);
  27264. get hasInstances(): boolean;
  27265. get hasThinInstances(): boolean;
  27266. /**
  27267. * Gets the delay loading state of the mesh (when delay loading is turned on)
  27268. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  27269. */
  27270. delayLoadState: number;
  27271. /**
  27272. * Gets the list of instances created from this mesh
  27273. * it is not supposed to be modified manually.
  27274. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  27275. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27276. */
  27277. instances: InstancedMesh[];
  27278. /**
  27279. * Gets the file containing delay loading data for this mesh
  27280. */
  27281. delayLoadingFile: string;
  27282. /** @hidden */
  27283. _binaryInfo: any;
  27284. /**
  27285. * User defined function used to change how LOD level selection is done
  27286. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  27287. */
  27288. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  27289. /**
  27290. * Gets or sets the morph target manager
  27291. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27292. */
  27293. get morphTargetManager(): Nullable<MorphTargetManager>;
  27294. set morphTargetManager(value: Nullable<MorphTargetManager>);
  27295. /** @hidden */
  27296. _creationDataStorage: Nullable<_CreationDataStorage>;
  27297. /** @hidden */
  27298. _geometry: Nullable<Geometry>;
  27299. /** @hidden */
  27300. _delayInfo: Array<string>;
  27301. /** @hidden */
  27302. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  27303. /** @hidden */
  27304. _instanceDataStorage: _InstanceDataStorage;
  27305. /** @hidden */
  27306. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  27307. private _effectiveMaterial;
  27308. /** @hidden */
  27309. _shouldGenerateFlatShading: boolean;
  27310. /** @hidden */
  27311. _originalBuilderSideOrientation: number;
  27312. /**
  27313. * Use this property to change the original side orientation defined at construction time
  27314. */
  27315. overrideMaterialSideOrientation: Nullable<number>;
  27316. /**
  27317. * Gets the source mesh (the one used to clone this one from)
  27318. */
  27319. get source(): Nullable<Mesh>;
  27320. /**
  27321. * Gets or sets a boolean indicating that this mesh does not use index buffer
  27322. */
  27323. get isUnIndexed(): boolean;
  27324. set isUnIndexed(value: boolean);
  27325. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  27326. get worldMatrixInstancedBuffer(): Float32Array;
  27327. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  27328. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  27329. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  27330. /**
  27331. * @constructor
  27332. * @param name The value used by scene.getMeshByName() to do a lookup.
  27333. * @param scene The scene to add this mesh to.
  27334. * @param parent The parent of this mesh, if it has one
  27335. * @param source An optional Mesh from which geometry is shared, cloned.
  27336. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  27337. * When false, achieved by calling a clone(), also passing False.
  27338. * This will make creation of children, recursive.
  27339. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  27340. */
  27341. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  27342. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  27343. doNotInstantiate: boolean;
  27344. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  27345. /**
  27346. * Gets the class name
  27347. * @returns the string "Mesh".
  27348. */
  27349. getClassName(): string;
  27350. /** @hidden */
  27351. get _isMesh(): boolean;
  27352. /**
  27353. * Returns a description of this mesh
  27354. * @param fullDetails define if full details about this mesh must be used
  27355. * @returns a descriptive string representing this mesh
  27356. */
  27357. toString(fullDetails?: boolean): string;
  27358. /** @hidden */
  27359. _unBindEffect(): void;
  27360. /**
  27361. * Gets a boolean indicating if this mesh has LOD
  27362. */
  27363. get hasLODLevels(): boolean;
  27364. /**
  27365. * Gets the list of MeshLODLevel associated with the current mesh
  27366. * @returns an array of MeshLODLevel
  27367. */
  27368. getLODLevels(): MeshLODLevel[];
  27369. private _sortLODLevels;
  27370. /**
  27371. * Add a mesh as LOD level triggered at the given distance.
  27372. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27373. * @param distance The distance from the center of the object to show this level
  27374. * @param mesh The mesh to be added as LOD level (can be null)
  27375. * @return This mesh (for chaining)
  27376. */
  27377. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  27378. /**
  27379. * Returns the LOD level mesh at the passed distance or null if not found.
  27380. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27381. * @param distance The distance from the center of the object to show this level
  27382. * @returns a Mesh or `null`
  27383. */
  27384. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  27385. /**
  27386. * Remove a mesh from the LOD array
  27387. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27388. * @param mesh defines the mesh to be removed
  27389. * @return This mesh (for chaining)
  27390. */
  27391. removeLODLevel(mesh: Mesh): Mesh;
  27392. /**
  27393. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  27394. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27395. * @param camera defines the camera to use to compute distance
  27396. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  27397. * @return This mesh (for chaining)
  27398. */
  27399. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  27400. /**
  27401. * Gets the mesh internal Geometry object
  27402. */
  27403. get geometry(): Nullable<Geometry>;
  27404. /**
  27405. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  27406. * @returns the total number of vertices
  27407. */
  27408. getTotalVertices(): number;
  27409. /**
  27410. * Returns the content of an associated vertex buffer
  27411. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27412. * - VertexBuffer.PositionKind
  27413. * - VertexBuffer.UVKind
  27414. * - VertexBuffer.UV2Kind
  27415. * - VertexBuffer.UV3Kind
  27416. * - VertexBuffer.UV4Kind
  27417. * - VertexBuffer.UV5Kind
  27418. * - VertexBuffer.UV6Kind
  27419. * - VertexBuffer.ColorKind
  27420. * - VertexBuffer.MatricesIndicesKind
  27421. * - VertexBuffer.MatricesIndicesExtraKind
  27422. * - VertexBuffer.MatricesWeightsKind
  27423. * - VertexBuffer.MatricesWeightsExtraKind
  27424. * @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
  27425. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  27426. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  27427. */
  27428. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27429. /**
  27430. * Returns the mesh VertexBuffer object from the requested `kind`
  27431. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27432. * - VertexBuffer.PositionKind
  27433. * - VertexBuffer.NormalKind
  27434. * - VertexBuffer.UVKind
  27435. * - VertexBuffer.UV2Kind
  27436. * - VertexBuffer.UV3Kind
  27437. * - VertexBuffer.UV4Kind
  27438. * - VertexBuffer.UV5Kind
  27439. * - VertexBuffer.UV6Kind
  27440. * - VertexBuffer.ColorKind
  27441. * - VertexBuffer.MatricesIndicesKind
  27442. * - VertexBuffer.MatricesIndicesExtraKind
  27443. * - VertexBuffer.MatricesWeightsKind
  27444. * - VertexBuffer.MatricesWeightsExtraKind
  27445. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  27446. */
  27447. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  27448. /**
  27449. * Tests if a specific vertex buffer is associated with this mesh
  27450. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27451. * - VertexBuffer.PositionKind
  27452. * - VertexBuffer.NormalKind
  27453. * - VertexBuffer.UVKind
  27454. * - VertexBuffer.UV2Kind
  27455. * - VertexBuffer.UV3Kind
  27456. * - VertexBuffer.UV4Kind
  27457. * - VertexBuffer.UV5Kind
  27458. * - VertexBuffer.UV6Kind
  27459. * - VertexBuffer.ColorKind
  27460. * - VertexBuffer.MatricesIndicesKind
  27461. * - VertexBuffer.MatricesIndicesExtraKind
  27462. * - VertexBuffer.MatricesWeightsKind
  27463. * - VertexBuffer.MatricesWeightsExtraKind
  27464. * @returns a boolean
  27465. */
  27466. isVerticesDataPresent(kind: string): boolean;
  27467. /**
  27468. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  27469. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27470. * - VertexBuffer.PositionKind
  27471. * - VertexBuffer.UVKind
  27472. * - VertexBuffer.UV2Kind
  27473. * - VertexBuffer.UV3Kind
  27474. * - VertexBuffer.UV4Kind
  27475. * - VertexBuffer.UV5Kind
  27476. * - VertexBuffer.UV6Kind
  27477. * - VertexBuffer.ColorKind
  27478. * - VertexBuffer.MatricesIndicesKind
  27479. * - VertexBuffer.MatricesIndicesExtraKind
  27480. * - VertexBuffer.MatricesWeightsKind
  27481. * - VertexBuffer.MatricesWeightsExtraKind
  27482. * @returns a boolean
  27483. */
  27484. isVertexBufferUpdatable(kind: string): boolean;
  27485. /**
  27486. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  27487. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27488. * - VertexBuffer.PositionKind
  27489. * - VertexBuffer.NormalKind
  27490. * - VertexBuffer.UVKind
  27491. * - VertexBuffer.UV2Kind
  27492. * - VertexBuffer.UV3Kind
  27493. * - VertexBuffer.UV4Kind
  27494. * - VertexBuffer.UV5Kind
  27495. * - VertexBuffer.UV6Kind
  27496. * - VertexBuffer.ColorKind
  27497. * - VertexBuffer.MatricesIndicesKind
  27498. * - VertexBuffer.MatricesIndicesExtraKind
  27499. * - VertexBuffer.MatricesWeightsKind
  27500. * - VertexBuffer.MatricesWeightsExtraKind
  27501. * @returns an array of strings
  27502. */
  27503. getVerticesDataKinds(): string[];
  27504. /**
  27505. * Returns a positive integer : the total number of indices in this mesh geometry.
  27506. * @returns the numner of indices or zero if the mesh has no geometry.
  27507. */
  27508. getTotalIndices(): number;
  27509. /**
  27510. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27511. * @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.
  27512. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27513. * @returns the indices array or an empty array if the mesh has no geometry
  27514. */
  27515. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27516. get isBlocked(): boolean;
  27517. /**
  27518. * Determine if the current mesh is ready to be rendered
  27519. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27520. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  27521. * @returns true if all associated assets are ready (material, textures, shaders)
  27522. */
  27523. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  27524. /**
  27525. * 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.
  27526. */
  27527. get areNormalsFrozen(): boolean;
  27528. /**
  27529. * 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.
  27530. * @returns the current mesh
  27531. */
  27532. freezeNormals(): Mesh;
  27533. /**
  27534. * 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
  27535. * @returns the current mesh
  27536. */
  27537. unfreezeNormals(): Mesh;
  27538. /**
  27539. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  27540. */
  27541. set overridenInstanceCount(count: number);
  27542. /** @hidden */
  27543. _preActivate(): Mesh;
  27544. /** @hidden */
  27545. _preActivateForIntermediateRendering(renderId: number): Mesh;
  27546. /** @hidden */
  27547. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  27548. protected _afterComputeWorldMatrix(): void;
  27549. /** @hidden */
  27550. _postActivate(): void;
  27551. /**
  27552. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27553. * This means the mesh underlying bounding box and sphere are recomputed.
  27554. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27555. * @returns the current mesh
  27556. */
  27557. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  27558. /** @hidden */
  27559. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  27560. /**
  27561. * This function will subdivide the mesh into multiple submeshes
  27562. * @param count defines the expected number of submeshes
  27563. */
  27564. subdivide(count: number): void;
  27565. /**
  27566. * Copy a FloatArray into a specific associated vertex buffer
  27567. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27568. * - VertexBuffer.PositionKind
  27569. * - VertexBuffer.UVKind
  27570. * - VertexBuffer.UV2Kind
  27571. * - VertexBuffer.UV3Kind
  27572. * - VertexBuffer.UV4Kind
  27573. * - VertexBuffer.UV5Kind
  27574. * - VertexBuffer.UV6Kind
  27575. * - VertexBuffer.ColorKind
  27576. * - VertexBuffer.MatricesIndicesKind
  27577. * - VertexBuffer.MatricesIndicesExtraKind
  27578. * - VertexBuffer.MatricesWeightsKind
  27579. * - VertexBuffer.MatricesWeightsExtraKind
  27580. * @param data defines the data source
  27581. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27582. * @param stride defines the data stride size (can be null)
  27583. * @returns the current mesh
  27584. */
  27585. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27586. /**
  27587. * Delete a vertex buffer associated with this mesh
  27588. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  27589. * - VertexBuffer.PositionKind
  27590. * - VertexBuffer.UVKind
  27591. * - VertexBuffer.UV2Kind
  27592. * - VertexBuffer.UV3Kind
  27593. * - VertexBuffer.UV4Kind
  27594. * - VertexBuffer.UV5Kind
  27595. * - VertexBuffer.UV6Kind
  27596. * - VertexBuffer.ColorKind
  27597. * - VertexBuffer.MatricesIndicesKind
  27598. * - VertexBuffer.MatricesIndicesExtraKind
  27599. * - VertexBuffer.MatricesWeightsKind
  27600. * - VertexBuffer.MatricesWeightsExtraKind
  27601. */
  27602. removeVerticesData(kind: string): void;
  27603. /**
  27604. * Flags an associated vertex buffer as updatable
  27605. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  27606. * - VertexBuffer.PositionKind
  27607. * - VertexBuffer.UVKind
  27608. * - VertexBuffer.UV2Kind
  27609. * - VertexBuffer.UV3Kind
  27610. * - VertexBuffer.UV4Kind
  27611. * - VertexBuffer.UV5Kind
  27612. * - VertexBuffer.UV6Kind
  27613. * - VertexBuffer.ColorKind
  27614. * - VertexBuffer.MatricesIndicesKind
  27615. * - VertexBuffer.MatricesIndicesExtraKind
  27616. * - VertexBuffer.MatricesWeightsKind
  27617. * - VertexBuffer.MatricesWeightsExtraKind
  27618. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27619. */
  27620. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  27621. /**
  27622. * Sets the mesh global Vertex Buffer
  27623. * @param buffer defines the buffer to use
  27624. * @returns the current mesh
  27625. */
  27626. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  27627. /**
  27628. * Update a specific associated vertex buffer
  27629. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27630. * - VertexBuffer.PositionKind
  27631. * - VertexBuffer.UVKind
  27632. * - VertexBuffer.UV2Kind
  27633. * - VertexBuffer.UV3Kind
  27634. * - VertexBuffer.UV4Kind
  27635. * - VertexBuffer.UV5Kind
  27636. * - VertexBuffer.UV6Kind
  27637. * - VertexBuffer.ColorKind
  27638. * - VertexBuffer.MatricesIndicesKind
  27639. * - VertexBuffer.MatricesIndicesExtraKind
  27640. * - VertexBuffer.MatricesWeightsKind
  27641. * - VertexBuffer.MatricesWeightsExtraKind
  27642. * @param data defines the data source
  27643. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27644. * @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)
  27645. * @returns the current mesh
  27646. */
  27647. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27648. /**
  27649. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  27650. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  27651. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  27652. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  27653. * @returns the current mesh
  27654. */
  27655. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  27656. /**
  27657. * Creates a un-shared specific occurence of the geometry for the mesh.
  27658. * @returns the current mesh
  27659. */
  27660. makeGeometryUnique(): Mesh;
  27661. /**
  27662. * Set the index buffer of this mesh
  27663. * @param indices defines the source data
  27664. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  27665. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  27666. * @returns the current mesh
  27667. */
  27668. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  27669. /**
  27670. * Update the current index buffer
  27671. * @param indices defines the source data
  27672. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27673. * @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)
  27674. * @returns the current mesh
  27675. */
  27676. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27677. /**
  27678. * Invert the geometry to move from a right handed system to a left handed one.
  27679. * @returns the current mesh
  27680. */
  27681. toLeftHanded(): Mesh;
  27682. /** @hidden */
  27683. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  27684. /** @hidden */
  27685. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  27686. /**
  27687. * Registers for this mesh a javascript function called just before the rendering process
  27688. * @param func defines the function to call before rendering this mesh
  27689. * @returns the current mesh
  27690. */
  27691. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27692. /**
  27693. * Disposes a previously registered javascript function called before the rendering
  27694. * @param func defines the function to remove
  27695. * @returns the current mesh
  27696. */
  27697. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27698. /**
  27699. * Registers for this mesh a javascript function called just after the rendering is complete
  27700. * @param func defines the function to call after rendering this mesh
  27701. * @returns the current mesh
  27702. */
  27703. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27704. /**
  27705. * Disposes a previously registered javascript function called after the rendering.
  27706. * @param func defines the function to remove
  27707. * @returns the current mesh
  27708. */
  27709. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27710. /** @hidden */
  27711. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  27712. /** @hidden */
  27713. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  27714. /** @hidden */
  27715. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  27716. /** @hidden */
  27717. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  27718. /** @hidden */
  27719. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  27720. /** @hidden */
  27721. _rebuild(): void;
  27722. /** @hidden */
  27723. _freeze(): void;
  27724. /** @hidden */
  27725. _unFreeze(): void;
  27726. /**
  27727. * 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
  27728. * @param subMesh defines the subMesh to render
  27729. * @param enableAlphaMode defines if alpha mode can be changed
  27730. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  27731. * @returns the current mesh
  27732. */
  27733. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  27734. private _onBeforeDraw;
  27735. /**
  27736. * Renormalize the mesh and patch it up if there are no weights
  27737. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  27738. * However in the case of zero weights then we set just a single influence to 1.
  27739. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  27740. */
  27741. cleanMatrixWeights(): void;
  27742. private normalizeSkinFourWeights;
  27743. private normalizeSkinWeightsAndExtra;
  27744. /**
  27745. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  27746. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  27747. * the user know there was an issue with importing the mesh
  27748. * @returns a validation object with skinned, valid and report string
  27749. */
  27750. validateSkinning(): {
  27751. skinned: boolean;
  27752. valid: boolean;
  27753. report: string;
  27754. };
  27755. /** @hidden */
  27756. _checkDelayState(): Mesh;
  27757. private _queueLoad;
  27758. /**
  27759. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27760. * A mesh is in the frustum if its bounding box intersects the frustum
  27761. * @param frustumPlanes defines the frustum to test
  27762. * @returns true if the mesh is in the frustum planes
  27763. */
  27764. isInFrustum(frustumPlanes: Plane[]): boolean;
  27765. /**
  27766. * Sets the mesh material by the material or multiMaterial `id` property
  27767. * @param id is a string identifying the material or the multiMaterial
  27768. * @returns the current mesh
  27769. */
  27770. setMaterialByID(id: string): Mesh;
  27771. /**
  27772. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  27773. * @returns an array of IAnimatable
  27774. */
  27775. getAnimatables(): IAnimatable[];
  27776. /**
  27777. * Modifies the mesh geometry according to the passed transformation matrix.
  27778. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  27779. * The mesh normals are modified using the same transformation.
  27780. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27781. * @param transform defines the transform matrix to use
  27782. * @see http://doc.babylonjs.com/resources/baking_transformations
  27783. * @returns the current mesh
  27784. */
  27785. bakeTransformIntoVertices(transform: Matrix): Mesh;
  27786. /**
  27787. * Modifies the mesh geometry according to its own current World Matrix.
  27788. * The mesh World Matrix is then reset.
  27789. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  27790. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27791. * @see http://doc.babylonjs.com/resources/baking_transformations
  27792. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  27793. * @returns the current mesh
  27794. */
  27795. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  27796. /** @hidden */
  27797. get _positions(): Nullable<Vector3[]>;
  27798. /** @hidden */
  27799. _resetPointsArrayCache(): Mesh;
  27800. /** @hidden */
  27801. _generatePointsArray(): boolean;
  27802. /**
  27803. * Returns a new Mesh object generated from the current mesh properties.
  27804. * This method must not get confused with createInstance()
  27805. * @param name is a string, the name given to the new mesh
  27806. * @param newParent can be any Node object (default `null`)
  27807. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  27808. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  27809. * @returns a new mesh
  27810. */
  27811. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  27812. /**
  27813. * Releases resources associated with this mesh.
  27814. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27815. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27816. */
  27817. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27818. /** @hidden */
  27819. _disposeInstanceSpecificData(): void;
  27820. /** @hidden */
  27821. _disposeThinInstanceSpecificData(): void;
  27822. /**
  27823. * Modifies the mesh geometry according to a displacement map.
  27824. * 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.
  27825. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27826. * @param url is a string, the URL from the image file is to be downloaded.
  27827. * @param minHeight is the lower limit of the displacement.
  27828. * @param maxHeight is the upper limit of the displacement.
  27829. * @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.
  27830. * @param uvOffset is an optional vector2 used to offset UV.
  27831. * @param uvScale is an optional vector2 used to scale UV.
  27832. * @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.
  27833. * @returns the Mesh.
  27834. */
  27835. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27836. /**
  27837. * Modifies the mesh geometry according to a displacementMap buffer.
  27838. * 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.
  27839. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27840. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  27841. * @param heightMapWidth is the width of the buffer image.
  27842. * @param heightMapHeight is the height of the buffer image.
  27843. * @param minHeight is the lower limit of the displacement.
  27844. * @param maxHeight is the upper limit of the displacement.
  27845. * @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.
  27846. * @param uvOffset is an optional vector2 used to offset UV.
  27847. * @param uvScale is an optional vector2 used to scale UV.
  27848. * @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.
  27849. * @returns the Mesh.
  27850. */
  27851. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27852. /**
  27853. * Modify the mesh to get a flat shading rendering.
  27854. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  27855. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  27856. * @returns current mesh
  27857. */
  27858. convertToFlatShadedMesh(): Mesh;
  27859. /**
  27860. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  27861. * In other words, more vertices, no more indices and a single bigger VBO.
  27862. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  27863. * @returns current mesh
  27864. */
  27865. convertToUnIndexedMesh(): Mesh;
  27866. /**
  27867. * Inverses facet orientations.
  27868. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27869. * @param flipNormals will also inverts the normals
  27870. * @returns current mesh
  27871. */
  27872. flipFaces(flipNormals?: boolean): Mesh;
  27873. /**
  27874. * Increase the number of facets and hence vertices in a mesh
  27875. * Vertex normals are interpolated from existing vertex normals
  27876. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27877. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  27878. */
  27879. increaseVertices(numberPerEdge: number): void;
  27880. /**
  27881. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  27882. * This will undo any application of covertToFlatShadedMesh
  27883. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27884. */
  27885. forceSharedVertices(): void;
  27886. /** @hidden */
  27887. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  27888. /** @hidden */
  27889. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  27890. /**
  27891. * Creates a new InstancedMesh object from the mesh model.
  27892. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27893. * @param name defines the name of the new instance
  27894. * @returns a new InstancedMesh
  27895. */
  27896. createInstance(name: string): InstancedMesh;
  27897. /**
  27898. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  27899. * After this call, all the mesh instances have the same submeshes than the current mesh.
  27900. * @returns the current mesh
  27901. */
  27902. synchronizeInstances(): Mesh;
  27903. /**
  27904. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  27905. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  27906. * This should be used together with the simplification to avoid disappearing triangles.
  27907. * @param successCallback an optional success callback to be called after the optimization finished.
  27908. * @returns the current mesh
  27909. */
  27910. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  27911. /**
  27912. * Serialize current mesh
  27913. * @param serializationObject defines the object which will receive the serialization data
  27914. */
  27915. serialize(serializationObject: any): void;
  27916. /** @hidden */
  27917. _syncGeometryWithMorphTargetManager(): void;
  27918. /** @hidden */
  27919. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  27920. /**
  27921. * Returns a new Mesh object parsed from the source provided.
  27922. * @param parsedMesh is the source
  27923. * @param scene defines the hosting scene
  27924. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  27925. * @returns a new Mesh
  27926. */
  27927. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  27928. /**
  27929. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  27930. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27931. * @param name defines the name of the mesh to create
  27932. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  27933. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  27934. * @param closePath creates a seam between the first and the last points of each path of the path array
  27935. * @param offset is taken in account only if the `pathArray` is containing a single path
  27936. * @param scene defines the hosting scene
  27937. * @param updatable defines if the mesh must be flagged as updatable
  27938. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27939. * @param instance defines an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#ribbon)
  27940. * @returns a new Mesh
  27941. */
  27942. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27943. /**
  27944. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  27945. * @param name defines the name of the mesh to create
  27946. * @param radius sets the radius size (float) of the polygon (default 0.5)
  27947. * @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
  27948. * @param scene defines the hosting scene
  27949. * @param updatable defines if the mesh must be flagged as updatable
  27950. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27951. * @returns a new Mesh
  27952. */
  27953. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27954. /**
  27955. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  27956. * @param name defines the name of the mesh to create
  27957. * @param size sets the size (float) of each box side (default 1)
  27958. * @param scene defines the hosting scene
  27959. * @param updatable defines if the mesh must be flagged as updatable
  27960. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27961. * @returns a new Mesh
  27962. */
  27963. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27964. /**
  27965. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  27966. * @param name defines the name of the mesh to create
  27967. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  27968. * @param diameter sets the diameter size (float) of the sphere (default 1)
  27969. * @param scene defines the hosting scene
  27970. * @param updatable defines if the mesh must be flagged as updatable
  27971. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27972. * @returns a new Mesh
  27973. */
  27974. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27975. /**
  27976. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  27977. * @param name defines the name of the mesh to create
  27978. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  27979. * @param diameter sets the diameter size (float) of the sphere (default 1)
  27980. * @param scene defines the hosting scene
  27981. * @returns a new Mesh
  27982. */
  27983. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  27984. /**
  27985. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  27986. * @param name defines the name of the mesh to create
  27987. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  27988. * @param diameterTop set the top cap diameter (floats, default 1)
  27989. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  27990. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  27991. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  27992. * @param scene defines the hosting scene
  27993. * @param updatable defines if the mesh must be flagged as updatable
  27994. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27995. * @returns a new Mesh
  27996. */
  27997. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  27998. /**
  27999. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  28000. * @param name defines the name of the mesh to create
  28001. * @param diameter sets the diameter size (float) of the torus (default 1)
  28002. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  28003. * @param tessellation sets the number of torus sides (postive integer, default 16)
  28004. * @param scene defines the hosting scene
  28005. * @param updatable defines if the mesh must be flagged as updatable
  28006. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28007. * @returns a new Mesh
  28008. */
  28009. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28010. /**
  28011. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28012. * @param name defines the name of the mesh to create
  28013. * @param radius sets the global radius size (float) of the torus knot (default 2)
  28014. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28015. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28016. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28017. * @param p the number of windings on X axis (positive integers, default 2)
  28018. * @param q the number of windings on Y axis (positive integers, default 3)
  28019. * @param scene defines the hosting scene
  28020. * @param updatable defines if the mesh must be flagged as updatable
  28021. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28022. * @returns a new Mesh
  28023. */
  28024. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28025. /**
  28026. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  28027. * @param name defines the name of the mesh to create
  28028. * @param points is an array successive Vector3
  28029. * @param scene defines the hosting scene
  28030. * @param updatable defines if the mesh must be flagged as updatable
  28031. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines).
  28032. * @returns a new Mesh
  28033. */
  28034. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  28035. /**
  28036. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  28037. * @param name defines the name of the mesh to create
  28038. * @param points is an array successive Vector3
  28039. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  28040. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28041. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  28042. * @param scene defines the hosting scene
  28043. * @param updatable defines if the mesh must be flagged as updatable
  28044. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines)
  28045. * @returns a new Mesh
  28046. */
  28047. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  28048. /**
  28049. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  28050. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  28051. * 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.
  28052. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28053. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28054. * Remember you can only change the shape positions, not their number when updating a polygon.
  28055. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  28056. * @param name defines the name of the mesh to create
  28057. * @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
  28058. * @param scene defines the hosting scene
  28059. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28060. * @param updatable defines if the mesh must be flagged as updatable
  28061. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28062. * @param earcutInjection can be used to inject your own earcut reference
  28063. * @returns a new Mesh
  28064. */
  28065. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28066. /**
  28067. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  28068. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  28069. * @param name defines the name of the mesh to create
  28070. * @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
  28071. * @param depth defines the height of extrusion
  28072. * @param scene defines the hosting scene
  28073. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28074. * @param updatable defines if the mesh must be flagged as updatable
  28075. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28076. * @param earcutInjection can be used to inject your own earcut reference
  28077. * @returns a new Mesh
  28078. */
  28079. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28080. /**
  28081. * Creates an extruded shape mesh.
  28082. * 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
  28083. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28084. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28085. * @param name defines the name of the mesh to create
  28086. * @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
  28087. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28088. * @param scale is the value to scale the shape
  28089. * @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
  28090. * @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
  28091. * @param scene defines the hosting scene
  28092. * @param updatable defines if the mesh must be flagged as updatable
  28093. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28094. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#extruded-shape)
  28095. * @returns a new Mesh
  28096. */
  28097. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28098. /**
  28099. * Creates an custom extruded shape mesh.
  28100. * The custom extrusion is a parametric shape.
  28101. * It has no predefined shape. Its final shape will depend on the input parameters.
  28102. * Please consider using the same method from the MeshBuilder class instead
  28103. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28104. * @param name defines the name of the mesh to create
  28105. * @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
  28106. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28107. * @param scaleFunction is a custom Javascript function called on each path point
  28108. * @param rotationFunction is a custom Javascript function called on each path point
  28109. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28110. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  28111. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  28112. * @param scene defines the hosting scene
  28113. * @param updatable defines if the mesh must be flagged as updatable
  28114. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28115. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape)
  28116. * @returns a new Mesh
  28117. */
  28118. 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;
  28119. /**
  28120. * Creates lathe mesh.
  28121. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  28122. * Please consider using the same method from the MeshBuilder class instead
  28123. * @param name defines the name of the mesh to create
  28124. * @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
  28125. * @param radius is the radius value of the lathe
  28126. * @param tessellation is the side number of the lathe.
  28127. * @param scene defines the hosting scene
  28128. * @param updatable defines if the mesh must be flagged as updatable
  28129. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28130. * @returns a new Mesh
  28131. */
  28132. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28133. /**
  28134. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  28135. * @param name defines the name of the mesh to create
  28136. * @param size sets the size (float) of both sides of the plane at once (default 1)
  28137. * @param scene defines the hosting scene
  28138. * @param updatable defines if the mesh must be flagged as updatable
  28139. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28140. * @returns a new Mesh
  28141. */
  28142. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28143. /**
  28144. * Creates a ground mesh.
  28145. * Please consider using the same method from the MeshBuilder class instead
  28146. * @param name defines the name of the mesh to create
  28147. * @param width set the width of the ground
  28148. * @param height set the height of the ground
  28149. * @param subdivisions sets the number of subdivisions per side
  28150. * @param scene defines the hosting scene
  28151. * @param updatable defines if the mesh must be flagged as updatable
  28152. * @returns a new Mesh
  28153. */
  28154. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  28155. /**
  28156. * Creates a tiled ground mesh.
  28157. * Please consider using the same method from the MeshBuilder class instead
  28158. * @param name defines the name of the mesh to create
  28159. * @param xmin set the ground minimum X coordinate
  28160. * @param zmin set the ground minimum Y coordinate
  28161. * @param xmax set the ground maximum X coordinate
  28162. * @param zmax set the ground maximum Z coordinate
  28163. * @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
  28164. * @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
  28165. * @param scene defines the hosting scene
  28166. * @param updatable defines if the mesh must be flagged as updatable
  28167. * @returns a new Mesh
  28168. */
  28169. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  28170. w: number;
  28171. h: number;
  28172. }, precision: {
  28173. w: number;
  28174. h: number;
  28175. }, scene: Scene, updatable?: boolean): Mesh;
  28176. /**
  28177. * Creates a ground mesh from a height map.
  28178. * Please consider using the same method from the MeshBuilder class instead
  28179. * @see http://doc.babylonjs.com/babylon101/height_map
  28180. * @param name defines the name of the mesh to create
  28181. * @param url sets the URL of the height map image resource
  28182. * @param width set the ground width size
  28183. * @param height set the ground height size
  28184. * @param subdivisions sets the number of subdivision per side
  28185. * @param minHeight is the minimum altitude on the ground
  28186. * @param maxHeight is the maximum altitude on the ground
  28187. * @param scene defines the hosting scene
  28188. * @param updatable defines if the mesh must be flagged as updatable
  28189. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  28190. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28191. * @returns a new Mesh
  28192. */
  28193. 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;
  28194. /**
  28195. * Creates a tube mesh.
  28196. * The tube is a parametric shape.
  28197. * It has no predefined shape. Its final shape will depend on the input parameters.
  28198. * Please consider using the same method from the MeshBuilder class instead
  28199. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28200. * @param name defines the name of the mesh to create
  28201. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  28202. * @param radius sets the tube radius size
  28203. * @param tessellation is the number of sides on the tubular surface
  28204. * @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
  28205. * @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
  28206. * @param scene defines the hosting scene
  28207. * @param updatable defines if the mesh must be flagged as updatable
  28208. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28209. * @param instance is an instance of an existing Tube object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#tube)
  28210. * @returns a new Mesh
  28211. */
  28212. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  28213. (i: number, distance: number): number;
  28214. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28215. /**
  28216. * Creates a polyhedron mesh.
  28217. * Please consider using the same method from the MeshBuilder class instead.
  28218. * * 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
  28219. * * The parameter `size` (positive float, default 1) sets the polygon size
  28220. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28221. * * 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`
  28222. * * 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
  28223. * * 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)`)
  28224. * * 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
  28225. * * 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
  28226. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28227. * * 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 : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  28228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28229. * @param name defines the name of the mesh to create
  28230. * @param options defines the options used to create the mesh
  28231. * @param scene defines the hosting scene
  28232. * @returns a new Mesh
  28233. */
  28234. static CreatePolyhedron(name: string, options: {
  28235. type?: number;
  28236. size?: number;
  28237. sizeX?: number;
  28238. sizeY?: number;
  28239. sizeZ?: number;
  28240. custom?: any;
  28241. faceUV?: Vector4[];
  28242. faceColors?: Color4[];
  28243. updatable?: boolean;
  28244. sideOrientation?: number;
  28245. }, scene: Scene): Mesh;
  28246. /**
  28247. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  28248. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  28249. * * 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`)
  28250. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  28251. * * 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
  28252. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28253. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  28254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28255. * @param name defines the name of the mesh
  28256. * @param options defines the options used to create the mesh
  28257. * @param scene defines the hosting scene
  28258. * @returns a new Mesh
  28259. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  28260. */
  28261. static CreateIcoSphere(name: string, options: {
  28262. radius?: number;
  28263. flat?: boolean;
  28264. subdivisions?: number;
  28265. sideOrientation?: number;
  28266. updatable?: boolean;
  28267. }, scene: Scene): Mesh;
  28268. /**
  28269. * Creates a decal mesh.
  28270. * Please consider using the same method from the MeshBuilder class instead.
  28271. * A decal is a mesh usually applied as a model onto the surface of another mesh
  28272. * @param name defines the name of the mesh
  28273. * @param sourceMesh defines the mesh receiving the decal
  28274. * @param position sets the position of the decal in world coordinates
  28275. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  28276. * @param size sets the decal scaling
  28277. * @param angle sets the angle to rotate the decal
  28278. * @returns a new Mesh
  28279. */
  28280. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  28281. /**
  28282. * Prepare internal position array for software CPU skinning
  28283. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  28284. */
  28285. setPositionsForCPUSkinning(): Float32Array;
  28286. /**
  28287. * Prepare internal normal array for software CPU skinning
  28288. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  28289. */
  28290. setNormalsForCPUSkinning(): Float32Array;
  28291. /**
  28292. * Updates the vertex buffer by applying transformation from the bones
  28293. * @param skeleton defines the skeleton to apply to current mesh
  28294. * @returns the current mesh
  28295. */
  28296. applySkeleton(skeleton: Skeleton): Mesh;
  28297. /**
  28298. * 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
  28299. * @param meshes defines the list of meshes to scan
  28300. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  28301. */
  28302. static MinMax(meshes: AbstractMesh[]): {
  28303. min: Vector3;
  28304. max: Vector3;
  28305. };
  28306. /**
  28307. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  28308. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  28309. * @returns a vector3
  28310. */
  28311. static Center(meshesOrMinMaxVector: {
  28312. min: Vector3;
  28313. max: Vector3;
  28314. } | AbstractMesh[]): Vector3;
  28315. /**
  28316. * Merge the array of meshes into a single mesh for performance reasons.
  28317. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  28318. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  28319. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  28320. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  28321. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  28322. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  28323. * @returns a new mesh
  28324. */
  28325. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  28326. /** @hidden */
  28327. addInstance(instance: InstancedMesh): void;
  28328. /** @hidden */
  28329. removeInstance(instance: InstancedMesh): void;
  28330. }
  28331. }
  28332. declare module BABYLON {
  28333. /**
  28334. * This is the base class of all the camera used in the application.
  28335. * @see http://doc.babylonjs.com/features/cameras
  28336. */
  28337. export class Camera extends Node {
  28338. /** @hidden */
  28339. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  28340. /**
  28341. * This is the default projection mode used by the cameras.
  28342. * It helps recreating a feeling of perspective and better appreciate depth.
  28343. * This is the best way to simulate real life cameras.
  28344. */
  28345. static readonly PERSPECTIVE_CAMERA: number;
  28346. /**
  28347. * This helps creating camera with an orthographic mode.
  28348. * 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.
  28349. */
  28350. static readonly ORTHOGRAPHIC_CAMERA: number;
  28351. /**
  28352. * This is the default FOV mode for perspective cameras.
  28353. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  28354. */
  28355. static readonly FOVMODE_VERTICAL_FIXED: number;
  28356. /**
  28357. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  28358. */
  28359. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  28360. /**
  28361. * This specifies ther is no need for a camera rig.
  28362. * Basically only one eye is rendered corresponding to the camera.
  28363. */
  28364. static readonly RIG_MODE_NONE: number;
  28365. /**
  28366. * Simulates a camera Rig with one blue eye and one red eye.
  28367. * This can be use with 3d blue and red glasses.
  28368. */
  28369. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  28370. /**
  28371. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  28372. */
  28373. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  28374. /**
  28375. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  28376. */
  28377. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  28378. /**
  28379. * Defines that both eyes of the camera will be rendered over under each other.
  28380. */
  28381. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  28382. /**
  28383. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  28384. */
  28385. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  28386. /**
  28387. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  28388. */
  28389. static readonly RIG_MODE_VR: number;
  28390. /**
  28391. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  28392. */
  28393. static readonly RIG_MODE_WEBVR: number;
  28394. /**
  28395. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  28396. */
  28397. static readonly RIG_MODE_CUSTOM: number;
  28398. /**
  28399. * Defines if by default attaching controls should prevent the default javascript event to continue.
  28400. */
  28401. static ForceAttachControlToAlwaysPreventDefault: boolean;
  28402. /**
  28403. * Define the input manager associated with the camera.
  28404. */
  28405. inputs: CameraInputsManager<Camera>;
  28406. /** @hidden */
  28407. _position: Vector3;
  28408. /**
  28409. * Define the current local position of the camera in the scene
  28410. */
  28411. get position(): Vector3;
  28412. set position(newPosition: Vector3);
  28413. /**
  28414. * The vector the camera should consider as up.
  28415. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  28416. */
  28417. upVector: Vector3;
  28418. /**
  28419. * Define the current limit on the left side for an orthographic camera
  28420. * In scene unit
  28421. */
  28422. orthoLeft: Nullable<number>;
  28423. /**
  28424. * Define the current limit on the right side for an orthographic camera
  28425. * In scene unit
  28426. */
  28427. orthoRight: Nullable<number>;
  28428. /**
  28429. * Define the current limit on the bottom side for an orthographic camera
  28430. * In scene unit
  28431. */
  28432. orthoBottom: Nullable<number>;
  28433. /**
  28434. * Define the current limit on the top side for an orthographic camera
  28435. * In scene unit
  28436. */
  28437. orthoTop: Nullable<number>;
  28438. /**
  28439. * Field Of View is set in Radians. (default is 0.8)
  28440. */
  28441. fov: number;
  28442. /**
  28443. * Define the minimum distance the camera can see from.
  28444. * This is important to note that the depth buffer are not infinite and the closer it starts
  28445. * the more your scene might encounter depth fighting issue.
  28446. */
  28447. minZ: number;
  28448. /**
  28449. * Define the maximum distance the camera can see to.
  28450. * This is important to note that the depth buffer are not infinite and the further it end
  28451. * the more your scene might encounter depth fighting issue.
  28452. */
  28453. maxZ: number;
  28454. /**
  28455. * Define the default inertia of the camera.
  28456. * This helps giving a smooth feeling to the camera movement.
  28457. */
  28458. inertia: number;
  28459. /**
  28460. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  28461. */
  28462. mode: number;
  28463. /**
  28464. * Define whether the camera is intermediate.
  28465. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  28466. */
  28467. isIntermediate: boolean;
  28468. /**
  28469. * Define the viewport of the camera.
  28470. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  28471. */
  28472. viewport: Viewport;
  28473. /**
  28474. * Restricts the camera to viewing objects with the same layerMask.
  28475. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  28476. */
  28477. layerMask: number;
  28478. /**
  28479. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  28480. */
  28481. fovMode: number;
  28482. /**
  28483. * Rig mode of the camera.
  28484. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  28485. * This is normally controlled byt the camera themselves as internal use.
  28486. */
  28487. cameraRigMode: number;
  28488. /**
  28489. * Defines the distance between both "eyes" in case of a RIG
  28490. */
  28491. interaxialDistance: number;
  28492. /**
  28493. * Defines if stereoscopic rendering is done side by side or over under.
  28494. */
  28495. isStereoscopicSideBySide: boolean;
  28496. /**
  28497. * 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
  28498. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  28499. * else in the scene. (Eg. security camera)
  28500. *
  28501. * 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)
  28502. */
  28503. customRenderTargets: RenderTargetTexture[];
  28504. /**
  28505. * When set, the camera will render to this render target instead of the default canvas
  28506. *
  28507. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  28508. */
  28509. outputRenderTarget: Nullable<RenderTargetTexture>;
  28510. /**
  28511. * Observable triggered when the camera view matrix has changed.
  28512. */
  28513. onViewMatrixChangedObservable: Observable<Camera>;
  28514. /**
  28515. * Observable triggered when the camera Projection matrix has changed.
  28516. */
  28517. onProjectionMatrixChangedObservable: Observable<Camera>;
  28518. /**
  28519. * Observable triggered when the inputs have been processed.
  28520. */
  28521. onAfterCheckInputsObservable: Observable<Camera>;
  28522. /**
  28523. * Observable triggered when reset has been called and applied to the camera.
  28524. */
  28525. onRestoreStateObservable: Observable<Camera>;
  28526. /**
  28527. * Is this camera a part of a rig system?
  28528. */
  28529. isRigCamera: boolean;
  28530. /**
  28531. * If isRigCamera set to true this will be set with the parent camera.
  28532. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  28533. */
  28534. rigParent?: Camera;
  28535. /** @hidden */
  28536. _cameraRigParams: any;
  28537. /** @hidden */
  28538. _rigCameras: Camera[];
  28539. /** @hidden */
  28540. _rigPostProcess: Nullable<PostProcess>;
  28541. protected _webvrViewMatrix: Matrix;
  28542. /** @hidden */
  28543. _skipRendering: boolean;
  28544. /** @hidden */
  28545. _projectionMatrix: Matrix;
  28546. /** @hidden */
  28547. _postProcesses: Nullable<PostProcess>[];
  28548. /** @hidden */
  28549. _activeMeshes: SmartArray<AbstractMesh>;
  28550. protected _globalPosition: Vector3;
  28551. /** @hidden */
  28552. _computedViewMatrix: Matrix;
  28553. private _doNotComputeProjectionMatrix;
  28554. private _transformMatrix;
  28555. private _frustumPlanes;
  28556. private _refreshFrustumPlanes;
  28557. private _storedFov;
  28558. private _stateStored;
  28559. /**
  28560. * Instantiates a new camera object.
  28561. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  28562. * @see http://doc.babylonjs.com/features/cameras
  28563. * @param name Defines the name of the camera in the scene
  28564. * @param position Defines the position of the camera
  28565. * @param scene Defines the scene the camera belongs too
  28566. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  28567. */
  28568. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  28569. /**
  28570. * Store current camera state (fov, position, etc..)
  28571. * @returns the camera
  28572. */
  28573. storeState(): Camera;
  28574. /**
  28575. * Restores the camera state values if it has been stored. You must call storeState() first
  28576. */
  28577. protected _restoreStateValues(): boolean;
  28578. /**
  28579. * Restored camera state. You must call storeState() first.
  28580. * @returns true if restored and false otherwise
  28581. */
  28582. restoreState(): boolean;
  28583. /**
  28584. * Gets the class name of the camera.
  28585. * @returns the class name
  28586. */
  28587. getClassName(): string;
  28588. /** @hidden */
  28589. readonly _isCamera: boolean;
  28590. /**
  28591. * Gets a string representation of the camera useful for debug purpose.
  28592. * @param fullDetails Defines that a more verboe level of logging is required
  28593. * @returns the string representation
  28594. */
  28595. toString(fullDetails?: boolean): string;
  28596. /**
  28597. * Gets the current world space position of the camera.
  28598. */
  28599. get globalPosition(): Vector3;
  28600. /**
  28601. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  28602. * @returns the active meshe list
  28603. */
  28604. getActiveMeshes(): SmartArray<AbstractMesh>;
  28605. /**
  28606. * Check whether a mesh is part of the current active mesh list of the camera
  28607. * @param mesh Defines the mesh to check
  28608. * @returns true if active, false otherwise
  28609. */
  28610. isActiveMesh(mesh: Mesh): boolean;
  28611. /**
  28612. * Is this camera ready to be used/rendered
  28613. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  28614. * @return true if the camera is ready
  28615. */
  28616. isReady(completeCheck?: boolean): boolean;
  28617. /** @hidden */
  28618. _initCache(): void;
  28619. /** @hidden */
  28620. _updateCache(ignoreParentClass?: boolean): void;
  28621. /** @hidden */
  28622. _isSynchronized(): boolean;
  28623. /** @hidden */
  28624. _isSynchronizedViewMatrix(): boolean;
  28625. /** @hidden */
  28626. _isSynchronizedProjectionMatrix(): boolean;
  28627. /**
  28628. * Attach the input controls to a specific dom element to get the input from.
  28629. * @param element Defines the element the controls should be listened from
  28630. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  28631. */
  28632. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  28633. /**
  28634. * Detach the current controls from the specified dom element.
  28635. * @param element Defines the element to stop listening the inputs from
  28636. */
  28637. detachControl(element: HTMLElement): void;
  28638. /**
  28639. * Update the camera state according to the different inputs gathered during the frame.
  28640. */
  28641. update(): void;
  28642. /** @hidden */
  28643. _checkInputs(): void;
  28644. /** @hidden */
  28645. get rigCameras(): Camera[];
  28646. /**
  28647. * Gets the post process used by the rig cameras
  28648. */
  28649. get rigPostProcess(): Nullable<PostProcess>;
  28650. /**
  28651. * Internal, gets the first post proces.
  28652. * @returns the first post process to be run on this camera.
  28653. */
  28654. _getFirstPostProcess(): Nullable<PostProcess>;
  28655. private _cascadePostProcessesToRigCams;
  28656. /**
  28657. * Attach a post process to the camera.
  28658. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28659. * @param postProcess The post process to attach to the camera
  28660. * @param insertAt The position of the post process in case several of them are in use in the scene
  28661. * @returns the position the post process has been inserted at
  28662. */
  28663. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  28664. /**
  28665. * Detach a post process to the camera.
  28666. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28667. * @param postProcess The post process to detach from the camera
  28668. */
  28669. detachPostProcess(postProcess: PostProcess): void;
  28670. /**
  28671. * Gets the current world matrix of the camera
  28672. */
  28673. getWorldMatrix(): Matrix;
  28674. /** @hidden */
  28675. _getViewMatrix(): Matrix;
  28676. /**
  28677. * Gets the current view matrix of the camera.
  28678. * @param force forces the camera to recompute the matrix without looking at the cached state
  28679. * @returns the view matrix
  28680. */
  28681. getViewMatrix(force?: boolean): Matrix;
  28682. /**
  28683. * Freeze the projection matrix.
  28684. * It will prevent the cache check of the camera projection compute and can speed up perf
  28685. * if no parameter of the camera are meant to change
  28686. * @param projection Defines manually a projection if necessary
  28687. */
  28688. freezeProjectionMatrix(projection?: Matrix): void;
  28689. /**
  28690. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  28691. */
  28692. unfreezeProjectionMatrix(): void;
  28693. /**
  28694. * Gets the current projection matrix of the camera.
  28695. * @param force forces the camera to recompute the matrix without looking at the cached state
  28696. * @returns the projection matrix
  28697. */
  28698. getProjectionMatrix(force?: boolean): Matrix;
  28699. /**
  28700. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  28701. * @returns a Matrix
  28702. */
  28703. getTransformationMatrix(): Matrix;
  28704. private _updateFrustumPlanes;
  28705. /**
  28706. * Checks if a cullable object (mesh...) is in the camera frustum
  28707. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  28708. * @param target The object to check
  28709. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  28710. * @returns true if the object is in frustum otherwise false
  28711. */
  28712. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  28713. /**
  28714. * Checks if a cullable object (mesh...) is in the camera frustum
  28715. * Unlike isInFrustum this cheks the full bounding box
  28716. * @param target The object to check
  28717. * @returns true if the object is in frustum otherwise false
  28718. */
  28719. isCompletelyInFrustum(target: ICullable): boolean;
  28720. /**
  28721. * Gets a ray in the forward direction from the camera.
  28722. * @param length Defines the length of the ray to create
  28723. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  28724. * @param origin Defines the start point of the ray which defaults to the camera position
  28725. * @returns the forward ray
  28726. */
  28727. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  28728. /**
  28729. * Releases resources associated with this node.
  28730. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28731. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28732. */
  28733. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28734. /** @hidden */
  28735. _isLeftCamera: boolean;
  28736. /**
  28737. * Gets the left camera of a rig setup in case of Rigged Camera
  28738. */
  28739. get isLeftCamera(): boolean;
  28740. /** @hidden */
  28741. _isRightCamera: boolean;
  28742. /**
  28743. * Gets the right camera of a rig setup in case of Rigged Camera
  28744. */
  28745. get isRightCamera(): boolean;
  28746. /**
  28747. * Gets the left camera of a rig setup in case of Rigged Camera
  28748. */
  28749. get leftCamera(): Nullable<FreeCamera>;
  28750. /**
  28751. * Gets the right camera of a rig setup in case of Rigged Camera
  28752. */
  28753. get rightCamera(): Nullable<FreeCamera>;
  28754. /**
  28755. * Gets the left camera target of a rig setup in case of Rigged Camera
  28756. * @returns the target position
  28757. */
  28758. getLeftTarget(): Nullable<Vector3>;
  28759. /**
  28760. * Gets the right camera target of a rig setup in case of Rigged Camera
  28761. * @returns the target position
  28762. */
  28763. getRightTarget(): Nullable<Vector3>;
  28764. /**
  28765. * @hidden
  28766. */
  28767. setCameraRigMode(mode: number, rigParams: any): void;
  28768. /** @hidden */
  28769. static _setStereoscopicRigMode(camera: Camera): void;
  28770. /** @hidden */
  28771. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  28772. /** @hidden */
  28773. static _setVRRigMode(camera: Camera, rigParams: any): void;
  28774. /** @hidden */
  28775. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  28776. /** @hidden */
  28777. _getVRProjectionMatrix(): Matrix;
  28778. protected _updateCameraRotationMatrix(): void;
  28779. protected _updateWebVRCameraRotationMatrix(): void;
  28780. /**
  28781. * This function MUST be overwritten by the different WebVR cameras available.
  28782. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28783. * @hidden
  28784. */
  28785. _getWebVRProjectionMatrix(): Matrix;
  28786. /**
  28787. * This function MUST be overwritten by the different WebVR cameras available.
  28788. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28789. * @hidden
  28790. */
  28791. _getWebVRViewMatrix(): Matrix;
  28792. /** @hidden */
  28793. setCameraRigParameter(name: string, value: any): void;
  28794. /**
  28795. * needs to be overridden by children so sub has required properties to be copied
  28796. * @hidden
  28797. */
  28798. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  28799. /**
  28800. * May need to be overridden by children
  28801. * @hidden
  28802. */
  28803. _updateRigCameras(): void;
  28804. /** @hidden */
  28805. _setupInputs(): void;
  28806. /**
  28807. * Serialiaze the camera setup to a json represention
  28808. * @returns the JSON representation
  28809. */
  28810. serialize(): any;
  28811. /**
  28812. * Clones the current camera.
  28813. * @param name The cloned camera name
  28814. * @returns the cloned camera
  28815. */
  28816. clone(name: string): Camera;
  28817. /**
  28818. * Gets the direction of the camera relative to a given local axis.
  28819. * @param localAxis Defines the reference axis to provide a relative direction.
  28820. * @return the direction
  28821. */
  28822. getDirection(localAxis: Vector3): Vector3;
  28823. /**
  28824. * Returns the current camera absolute rotation
  28825. */
  28826. get absoluteRotation(): Quaternion;
  28827. /**
  28828. * Gets the direction of the camera relative to a given local axis into a passed vector.
  28829. * @param localAxis Defines the reference axis to provide a relative direction.
  28830. * @param result Defines the vector to store the result in
  28831. */
  28832. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  28833. /**
  28834. * Gets a camera constructor for a given camera type
  28835. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  28836. * @param name The name of the camera the result will be able to instantiate
  28837. * @param scene The scene the result will construct the camera in
  28838. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  28839. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  28840. * @returns a factory method to construc the camera
  28841. */
  28842. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  28843. /**
  28844. * Compute the world matrix of the camera.
  28845. * @returns the camera world matrix
  28846. */
  28847. computeWorldMatrix(): Matrix;
  28848. /**
  28849. * Parse a JSON and creates the camera from the parsed information
  28850. * @param parsedCamera The JSON to parse
  28851. * @param scene The scene to instantiate the camera in
  28852. * @returns the newly constructed camera
  28853. */
  28854. static Parse(parsedCamera: any, scene: Scene): Camera;
  28855. }
  28856. }
  28857. declare module BABYLON {
  28858. /**
  28859. * Class containing static functions to help procedurally build meshes
  28860. */
  28861. export class DiscBuilder {
  28862. /**
  28863. * Creates a plane polygonal mesh. By default, this is a disc
  28864. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  28865. * * 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
  28866. * * 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
  28867. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28868. * * 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
  28869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28870. * @param name defines the name of the mesh
  28871. * @param options defines the options used to create the mesh
  28872. * @param scene defines the hosting scene
  28873. * @returns the plane polygonal mesh
  28874. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  28875. */
  28876. static CreateDisc(name: string, options: {
  28877. radius?: number;
  28878. tessellation?: number;
  28879. arc?: number;
  28880. updatable?: boolean;
  28881. sideOrientation?: number;
  28882. frontUVs?: Vector4;
  28883. backUVs?: Vector4;
  28884. }, scene?: Nullable<Scene>): Mesh;
  28885. }
  28886. }
  28887. declare module BABYLON {
  28888. /**
  28889. * Options to be used when creating a FresnelParameters.
  28890. */
  28891. export type IFresnelParametersCreationOptions = {
  28892. /**
  28893. * Define the color used on edges (grazing angle)
  28894. */
  28895. leftColor?: Color3;
  28896. /**
  28897. * Define the color used on center
  28898. */
  28899. rightColor?: Color3;
  28900. /**
  28901. * Define bias applied to computed fresnel term
  28902. */
  28903. bias?: number;
  28904. /**
  28905. * Defined the power exponent applied to fresnel term
  28906. */
  28907. power?: number;
  28908. /**
  28909. * Define if the fresnel effect is enable or not.
  28910. */
  28911. isEnabled?: boolean;
  28912. };
  28913. /**
  28914. * Serialized format for FresnelParameters.
  28915. */
  28916. export type IFresnelParametersSerialized = {
  28917. /**
  28918. * Define the color used on edges (grazing angle) [as an array]
  28919. */
  28920. leftColor: number[];
  28921. /**
  28922. * Define the color used on center [as an array]
  28923. */
  28924. rightColor: number[];
  28925. /**
  28926. * Define bias applied to computed fresnel term
  28927. */
  28928. bias: number;
  28929. /**
  28930. * Defined the power exponent applied to fresnel term
  28931. */
  28932. power?: number;
  28933. /**
  28934. * Define if the fresnel effect is enable or not.
  28935. */
  28936. isEnabled: boolean;
  28937. };
  28938. /**
  28939. * This represents all the required information to add a fresnel effect on a material:
  28940. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28941. */
  28942. export class FresnelParameters {
  28943. private _isEnabled;
  28944. /**
  28945. * Define if the fresnel effect is enable or not.
  28946. */
  28947. get isEnabled(): boolean;
  28948. set isEnabled(value: boolean);
  28949. /**
  28950. * Define the color used on edges (grazing angle)
  28951. */
  28952. leftColor: Color3;
  28953. /**
  28954. * Define the color used on center
  28955. */
  28956. rightColor: Color3;
  28957. /**
  28958. * Define bias applied to computed fresnel term
  28959. */
  28960. bias: number;
  28961. /**
  28962. * Defined the power exponent applied to fresnel term
  28963. */
  28964. power: number;
  28965. /**
  28966. * Creates a new FresnelParameters object.
  28967. *
  28968. * @param options provide your own settings to optionally to override defaults
  28969. */
  28970. constructor(options?: IFresnelParametersCreationOptions);
  28971. /**
  28972. * Clones the current fresnel and its valuues
  28973. * @returns a clone fresnel configuration
  28974. */
  28975. clone(): FresnelParameters;
  28976. /**
  28977. * Determines equality between FresnelParameters objects
  28978. * @param otherFresnelParameters defines the second operand
  28979. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  28980. */
  28981. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  28982. /**
  28983. * Serializes the current fresnel parameters to a JSON representation.
  28984. * @return the JSON serialization
  28985. */
  28986. serialize(): IFresnelParametersSerialized;
  28987. /**
  28988. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28989. * @param parsedFresnelParameters Define the JSON representation
  28990. * @returns the parsed parameters
  28991. */
  28992. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  28993. }
  28994. }
  28995. declare module BABYLON {
  28996. /**
  28997. * This groups all the flags used to control the materials channel.
  28998. */
  28999. export class MaterialFlags {
  29000. private static _DiffuseTextureEnabled;
  29001. /**
  29002. * Are diffuse textures enabled in the application.
  29003. */
  29004. static get DiffuseTextureEnabled(): boolean;
  29005. static set DiffuseTextureEnabled(value: boolean);
  29006. private static _DetailTextureEnabled;
  29007. /**
  29008. * Are detail textures enabled in the application.
  29009. */
  29010. static get DetailTextureEnabled(): boolean;
  29011. static set DetailTextureEnabled(value: boolean);
  29012. private static _AmbientTextureEnabled;
  29013. /**
  29014. * Are ambient textures enabled in the application.
  29015. */
  29016. static get AmbientTextureEnabled(): boolean;
  29017. static set AmbientTextureEnabled(value: boolean);
  29018. private static _OpacityTextureEnabled;
  29019. /**
  29020. * Are opacity textures enabled in the application.
  29021. */
  29022. static get OpacityTextureEnabled(): boolean;
  29023. static set OpacityTextureEnabled(value: boolean);
  29024. private static _ReflectionTextureEnabled;
  29025. /**
  29026. * Are reflection textures enabled in the application.
  29027. */
  29028. static get ReflectionTextureEnabled(): boolean;
  29029. static set ReflectionTextureEnabled(value: boolean);
  29030. private static _EmissiveTextureEnabled;
  29031. /**
  29032. * Are emissive textures enabled in the application.
  29033. */
  29034. static get EmissiveTextureEnabled(): boolean;
  29035. static set EmissiveTextureEnabled(value: boolean);
  29036. private static _SpecularTextureEnabled;
  29037. /**
  29038. * Are specular textures enabled in the application.
  29039. */
  29040. static get SpecularTextureEnabled(): boolean;
  29041. static set SpecularTextureEnabled(value: boolean);
  29042. private static _BumpTextureEnabled;
  29043. /**
  29044. * Are bump textures enabled in the application.
  29045. */
  29046. static get BumpTextureEnabled(): boolean;
  29047. static set BumpTextureEnabled(value: boolean);
  29048. private static _LightmapTextureEnabled;
  29049. /**
  29050. * Are lightmap textures enabled in the application.
  29051. */
  29052. static get LightmapTextureEnabled(): boolean;
  29053. static set LightmapTextureEnabled(value: boolean);
  29054. private static _RefractionTextureEnabled;
  29055. /**
  29056. * Are refraction textures enabled in the application.
  29057. */
  29058. static get RefractionTextureEnabled(): boolean;
  29059. static set RefractionTextureEnabled(value: boolean);
  29060. private static _ColorGradingTextureEnabled;
  29061. /**
  29062. * Are color grading textures enabled in the application.
  29063. */
  29064. static get ColorGradingTextureEnabled(): boolean;
  29065. static set ColorGradingTextureEnabled(value: boolean);
  29066. private static _FresnelEnabled;
  29067. /**
  29068. * Are fresnels enabled in the application.
  29069. */
  29070. static get FresnelEnabled(): boolean;
  29071. static set FresnelEnabled(value: boolean);
  29072. private static _ClearCoatTextureEnabled;
  29073. /**
  29074. * Are clear coat textures enabled in the application.
  29075. */
  29076. static get ClearCoatTextureEnabled(): boolean;
  29077. static set ClearCoatTextureEnabled(value: boolean);
  29078. private static _ClearCoatBumpTextureEnabled;
  29079. /**
  29080. * Are clear coat bump textures enabled in the application.
  29081. */
  29082. static get ClearCoatBumpTextureEnabled(): boolean;
  29083. static set ClearCoatBumpTextureEnabled(value: boolean);
  29084. private static _ClearCoatTintTextureEnabled;
  29085. /**
  29086. * Are clear coat tint textures enabled in the application.
  29087. */
  29088. static get ClearCoatTintTextureEnabled(): boolean;
  29089. static set ClearCoatTintTextureEnabled(value: boolean);
  29090. private static _SheenTextureEnabled;
  29091. /**
  29092. * Are sheen textures enabled in the application.
  29093. */
  29094. static get SheenTextureEnabled(): boolean;
  29095. static set SheenTextureEnabled(value: boolean);
  29096. private static _AnisotropicTextureEnabled;
  29097. /**
  29098. * Are anisotropic textures enabled in the application.
  29099. */
  29100. static get AnisotropicTextureEnabled(): boolean;
  29101. static set AnisotropicTextureEnabled(value: boolean);
  29102. private static _ThicknessTextureEnabled;
  29103. /**
  29104. * Are thickness textures enabled in the application.
  29105. */
  29106. static get ThicknessTextureEnabled(): boolean;
  29107. static set ThicknessTextureEnabled(value: boolean);
  29108. }
  29109. }
  29110. declare module BABYLON {
  29111. /** @hidden */
  29112. export var defaultFragmentDeclaration: {
  29113. name: string;
  29114. shader: string;
  29115. };
  29116. }
  29117. declare module BABYLON {
  29118. /** @hidden */
  29119. export var defaultUboDeclaration: {
  29120. name: string;
  29121. shader: string;
  29122. };
  29123. }
  29124. declare module BABYLON {
  29125. /** @hidden */
  29126. export var lightFragmentDeclaration: {
  29127. name: string;
  29128. shader: string;
  29129. };
  29130. }
  29131. declare module BABYLON {
  29132. /** @hidden */
  29133. export var lightUboDeclaration: {
  29134. name: string;
  29135. shader: string;
  29136. };
  29137. }
  29138. declare module BABYLON {
  29139. /** @hidden */
  29140. export var lightsFragmentFunctions: {
  29141. name: string;
  29142. shader: string;
  29143. };
  29144. }
  29145. declare module BABYLON {
  29146. /** @hidden */
  29147. export var shadowsFragmentFunctions: {
  29148. name: string;
  29149. shader: string;
  29150. };
  29151. }
  29152. declare module BABYLON {
  29153. /** @hidden */
  29154. export var fresnelFunction: {
  29155. name: string;
  29156. shader: string;
  29157. };
  29158. }
  29159. declare module BABYLON {
  29160. /** @hidden */
  29161. export var bumpFragmentMainFunctions: {
  29162. name: string;
  29163. shader: string;
  29164. };
  29165. }
  29166. declare module BABYLON {
  29167. /** @hidden */
  29168. export var bumpFragmentFunctions: {
  29169. name: string;
  29170. shader: string;
  29171. };
  29172. }
  29173. declare module BABYLON {
  29174. /** @hidden */
  29175. export var logDepthDeclaration: {
  29176. name: string;
  29177. shader: string;
  29178. };
  29179. }
  29180. declare module BABYLON {
  29181. /** @hidden */
  29182. export var bumpFragment: {
  29183. name: string;
  29184. shader: string;
  29185. };
  29186. }
  29187. declare module BABYLON {
  29188. /** @hidden */
  29189. export var depthPrePass: {
  29190. name: string;
  29191. shader: string;
  29192. };
  29193. }
  29194. declare module BABYLON {
  29195. /** @hidden */
  29196. export var lightFragment: {
  29197. name: string;
  29198. shader: string;
  29199. };
  29200. }
  29201. declare module BABYLON {
  29202. /** @hidden */
  29203. export var logDepthFragment: {
  29204. name: string;
  29205. shader: string;
  29206. };
  29207. }
  29208. declare module BABYLON {
  29209. /** @hidden */
  29210. export var defaultPixelShader: {
  29211. name: string;
  29212. shader: string;
  29213. };
  29214. }
  29215. declare module BABYLON {
  29216. /** @hidden */
  29217. export var defaultVertexDeclaration: {
  29218. name: string;
  29219. shader: string;
  29220. };
  29221. }
  29222. declare module BABYLON {
  29223. /** @hidden */
  29224. export var bumpVertexDeclaration: {
  29225. name: string;
  29226. shader: string;
  29227. };
  29228. }
  29229. declare module BABYLON {
  29230. /** @hidden */
  29231. export var bumpVertex: {
  29232. name: string;
  29233. shader: string;
  29234. };
  29235. }
  29236. declare module BABYLON {
  29237. /** @hidden */
  29238. export var fogVertex: {
  29239. name: string;
  29240. shader: string;
  29241. };
  29242. }
  29243. declare module BABYLON {
  29244. /** @hidden */
  29245. export var shadowsVertex: {
  29246. name: string;
  29247. shader: string;
  29248. };
  29249. }
  29250. declare module BABYLON {
  29251. /** @hidden */
  29252. export var pointCloudVertex: {
  29253. name: string;
  29254. shader: string;
  29255. };
  29256. }
  29257. declare module BABYLON {
  29258. /** @hidden */
  29259. export var logDepthVertex: {
  29260. name: string;
  29261. shader: string;
  29262. };
  29263. }
  29264. declare module BABYLON {
  29265. /** @hidden */
  29266. export var defaultVertexShader: {
  29267. name: string;
  29268. shader: string;
  29269. };
  29270. }
  29271. declare module BABYLON {
  29272. /**
  29273. * @hidden
  29274. */
  29275. export interface IMaterialDetailMapDefines {
  29276. DETAIL: boolean;
  29277. DETAILDIRECTUV: number;
  29278. DETAIL_NORMALBLENDMETHOD: number;
  29279. /** @hidden */
  29280. _areTexturesDirty: boolean;
  29281. }
  29282. /**
  29283. * Define the code related to the detail map parameters of a material
  29284. *
  29285. * Inspired from:
  29286. * 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
  29287. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  29288. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  29289. */
  29290. export class DetailMapConfiguration {
  29291. private _texture;
  29292. /**
  29293. * The detail texture of the material.
  29294. */
  29295. texture: Nullable<BaseTexture>;
  29296. /**
  29297. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  29298. * Bigger values mean stronger blending
  29299. */
  29300. diffuseBlendLevel: number;
  29301. /**
  29302. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  29303. * Bigger values mean stronger blending. Only used with PBR materials
  29304. */
  29305. roughnessBlendLevel: number;
  29306. /**
  29307. * Defines how strong the bump effect from the detail map is
  29308. * Bigger values mean stronger effect
  29309. */
  29310. bumpLevel: number;
  29311. private _normalBlendMethod;
  29312. /**
  29313. * The method used to blend the bump and detail normals together
  29314. */
  29315. normalBlendMethod: number;
  29316. private _isEnabled;
  29317. /**
  29318. * Enable or disable the detail map on this material
  29319. */
  29320. isEnabled: boolean;
  29321. /** @hidden */
  29322. private _internalMarkAllSubMeshesAsTexturesDirty;
  29323. /** @hidden */
  29324. _markAllSubMeshesAsTexturesDirty(): void;
  29325. /**
  29326. * Instantiate a new detail map
  29327. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  29328. */
  29329. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  29330. /**
  29331. * Gets whether the submesh is ready to be used or not.
  29332. * @param defines the list of "defines" to update.
  29333. * @param scene defines the scene the material belongs to.
  29334. * @returns - boolean indicating that the submesh is ready or not.
  29335. */
  29336. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  29337. /**
  29338. * Update the defines for detail map usage
  29339. * @param defines the list of "defines" to update.
  29340. * @param scene defines the scene the material belongs to.
  29341. */
  29342. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  29343. /**
  29344. * Binds the material data.
  29345. * @param uniformBuffer defines the Uniform buffer to fill in.
  29346. * @param scene defines the scene the material belongs to.
  29347. * @param isFrozen defines whether the material is frozen or not.
  29348. */
  29349. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  29350. /**
  29351. * Checks to see if a texture is used in the material.
  29352. * @param texture - Base texture to use.
  29353. * @returns - Boolean specifying if a texture is used in the material.
  29354. */
  29355. hasTexture(texture: BaseTexture): boolean;
  29356. /**
  29357. * Returns an array of the actively used textures.
  29358. * @param activeTextures Array of BaseTextures
  29359. */
  29360. getActiveTextures(activeTextures: BaseTexture[]): void;
  29361. /**
  29362. * Returns the animatable textures.
  29363. * @param animatables Array of animatable textures.
  29364. */
  29365. getAnimatables(animatables: IAnimatable[]): void;
  29366. /**
  29367. * Disposes the resources of the material.
  29368. * @param forceDisposeTextures - Forces the disposal of all textures.
  29369. */
  29370. dispose(forceDisposeTextures?: boolean): void;
  29371. /**
  29372. * Get the current class name useful for serialization or dynamic coding.
  29373. * @returns "DetailMap"
  29374. */
  29375. getClassName(): string;
  29376. /**
  29377. * Add the required uniforms to the current list.
  29378. * @param uniforms defines the current uniform list.
  29379. */
  29380. static AddUniforms(uniforms: string[]): void;
  29381. /**
  29382. * Add the required samplers to the current list.
  29383. * @param samplers defines the current sampler list.
  29384. */
  29385. static AddSamplers(samplers: string[]): void;
  29386. /**
  29387. * Add the required uniforms to the current buffer.
  29388. * @param uniformBuffer defines the current uniform buffer.
  29389. */
  29390. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  29391. /**
  29392. * Makes a duplicate of the current instance into another one.
  29393. * @param detailMap define the instance where to copy the info
  29394. */
  29395. copyTo(detailMap: DetailMapConfiguration): void;
  29396. /**
  29397. * Serializes this detail map instance
  29398. * @returns - An object with the serialized instance.
  29399. */
  29400. serialize(): any;
  29401. /**
  29402. * Parses a detail map setting from a serialized object.
  29403. * @param source - Serialized object.
  29404. * @param scene Defines the scene we are parsing for
  29405. * @param rootUrl Defines the rootUrl to load from
  29406. */
  29407. parse(source: any, scene: Scene, rootUrl: string): void;
  29408. }
  29409. }
  29410. declare module BABYLON {
  29411. /** @hidden */
  29412. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  29413. MAINUV1: boolean;
  29414. MAINUV2: boolean;
  29415. DIFFUSE: boolean;
  29416. DIFFUSEDIRECTUV: number;
  29417. DETAIL: boolean;
  29418. DETAILDIRECTUV: number;
  29419. DETAIL_NORMALBLENDMETHOD: number;
  29420. AMBIENT: boolean;
  29421. AMBIENTDIRECTUV: number;
  29422. OPACITY: boolean;
  29423. OPACITYDIRECTUV: number;
  29424. OPACITYRGB: boolean;
  29425. REFLECTION: boolean;
  29426. EMISSIVE: boolean;
  29427. EMISSIVEDIRECTUV: number;
  29428. SPECULAR: boolean;
  29429. SPECULARDIRECTUV: number;
  29430. BUMP: boolean;
  29431. BUMPDIRECTUV: number;
  29432. PARALLAX: boolean;
  29433. PARALLAXOCCLUSION: boolean;
  29434. SPECULAROVERALPHA: boolean;
  29435. CLIPPLANE: boolean;
  29436. CLIPPLANE2: boolean;
  29437. CLIPPLANE3: boolean;
  29438. CLIPPLANE4: boolean;
  29439. CLIPPLANE5: boolean;
  29440. CLIPPLANE6: boolean;
  29441. ALPHATEST: boolean;
  29442. DEPTHPREPASS: boolean;
  29443. ALPHAFROMDIFFUSE: boolean;
  29444. POINTSIZE: boolean;
  29445. FOG: boolean;
  29446. SPECULARTERM: boolean;
  29447. DIFFUSEFRESNEL: boolean;
  29448. OPACITYFRESNEL: boolean;
  29449. REFLECTIONFRESNEL: boolean;
  29450. REFRACTIONFRESNEL: boolean;
  29451. EMISSIVEFRESNEL: boolean;
  29452. FRESNEL: boolean;
  29453. NORMAL: boolean;
  29454. UV1: boolean;
  29455. UV2: boolean;
  29456. VERTEXCOLOR: boolean;
  29457. VERTEXALPHA: boolean;
  29458. NUM_BONE_INFLUENCERS: number;
  29459. BonesPerMesh: number;
  29460. BONETEXTURE: boolean;
  29461. INSTANCES: boolean;
  29462. THIN_INSTANCES: boolean;
  29463. GLOSSINESS: boolean;
  29464. ROUGHNESS: boolean;
  29465. EMISSIVEASILLUMINATION: boolean;
  29466. LINKEMISSIVEWITHDIFFUSE: boolean;
  29467. REFLECTIONFRESNELFROMSPECULAR: boolean;
  29468. LIGHTMAP: boolean;
  29469. LIGHTMAPDIRECTUV: number;
  29470. OBJECTSPACE_NORMALMAP: boolean;
  29471. USELIGHTMAPASSHADOWMAP: boolean;
  29472. REFLECTIONMAP_3D: boolean;
  29473. REFLECTIONMAP_SPHERICAL: boolean;
  29474. REFLECTIONMAP_PLANAR: boolean;
  29475. REFLECTIONMAP_CUBIC: boolean;
  29476. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  29477. REFLECTIONMAP_PROJECTION: boolean;
  29478. REFLECTIONMAP_SKYBOX: boolean;
  29479. REFLECTIONMAP_EXPLICIT: boolean;
  29480. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  29481. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  29482. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  29483. INVERTCUBICMAP: boolean;
  29484. LOGARITHMICDEPTH: boolean;
  29485. REFRACTION: boolean;
  29486. REFRACTIONMAP_3D: boolean;
  29487. REFLECTIONOVERALPHA: boolean;
  29488. TWOSIDEDLIGHTING: boolean;
  29489. SHADOWFLOAT: boolean;
  29490. MORPHTARGETS: boolean;
  29491. MORPHTARGETS_NORMAL: boolean;
  29492. MORPHTARGETS_TANGENT: boolean;
  29493. MORPHTARGETS_UV: boolean;
  29494. NUM_MORPH_INFLUENCERS: number;
  29495. NONUNIFORMSCALING: boolean;
  29496. PREMULTIPLYALPHA: boolean;
  29497. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  29498. ALPHABLEND: boolean;
  29499. RGBDLIGHTMAP: boolean;
  29500. RGBDREFLECTION: boolean;
  29501. RGBDREFRACTION: boolean;
  29502. IMAGEPROCESSING: boolean;
  29503. VIGNETTE: boolean;
  29504. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29505. VIGNETTEBLENDMODEOPAQUE: boolean;
  29506. TONEMAPPING: boolean;
  29507. TONEMAPPING_ACES: boolean;
  29508. CONTRAST: boolean;
  29509. COLORCURVES: boolean;
  29510. COLORGRADING: boolean;
  29511. COLORGRADING3D: boolean;
  29512. SAMPLER3DGREENDEPTH: boolean;
  29513. SAMPLER3DBGRMAP: boolean;
  29514. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29515. MULTIVIEW: boolean;
  29516. /**
  29517. * If the reflection texture on this material is in linear color space
  29518. * @hidden
  29519. */
  29520. IS_REFLECTION_LINEAR: boolean;
  29521. /**
  29522. * If the refraction texture on this material is in linear color space
  29523. * @hidden
  29524. */
  29525. IS_REFRACTION_LINEAR: boolean;
  29526. EXPOSURE: boolean;
  29527. constructor();
  29528. setReflectionMode(modeToEnable: string): void;
  29529. }
  29530. /**
  29531. * This is the default material used in Babylon. It is the best trade off between quality
  29532. * and performances.
  29533. * @see http://doc.babylonjs.com/babylon101/materials
  29534. */
  29535. export class StandardMaterial extends PushMaterial {
  29536. private _diffuseTexture;
  29537. /**
  29538. * The basic texture of the material as viewed under a light.
  29539. */
  29540. diffuseTexture: Nullable<BaseTexture>;
  29541. private _ambientTexture;
  29542. /**
  29543. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  29544. */
  29545. ambientTexture: Nullable<BaseTexture>;
  29546. private _opacityTexture;
  29547. /**
  29548. * Define the transparency of the material from a texture.
  29549. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  29550. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  29551. */
  29552. opacityTexture: Nullable<BaseTexture>;
  29553. private _reflectionTexture;
  29554. /**
  29555. * Define the texture used to display the reflection.
  29556. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29557. */
  29558. reflectionTexture: Nullable<BaseTexture>;
  29559. private _emissiveTexture;
  29560. /**
  29561. * Define texture of the material as if self lit.
  29562. * This will be mixed in the final result even in the absence of light.
  29563. */
  29564. emissiveTexture: Nullable<BaseTexture>;
  29565. private _specularTexture;
  29566. /**
  29567. * Define how the color and intensity of the highlight given by the light in the material.
  29568. */
  29569. specularTexture: Nullable<BaseTexture>;
  29570. private _bumpTexture;
  29571. /**
  29572. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  29573. * 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.
  29574. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  29575. */
  29576. bumpTexture: Nullable<BaseTexture>;
  29577. private _lightmapTexture;
  29578. /**
  29579. * Complex lighting can be computationally expensive to compute at runtime.
  29580. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  29581. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  29582. */
  29583. lightmapTexture: Nullable<BaseTexture>;
  29584. private _refractionTexture;
  29585. /**
  29586. * Define the texture used to display the refraction.
  29587. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29588. */
  29589. refractionTexture: Nullable<BaseTexture>;
  29590. /**
  29591. * The color of the material lit by the environmental background lighting.
  29592. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  29593. */
  29594. ambientColor: Color3;
  29595. /**
  29596. * The basic color of the material as viewed under a light.
  29597. */
  29598. diffuseColor: Color3;
  29599. /**
  29600. * Define how the color and intensity of the highlight given by the light in the material.
  29601. */
  29602. specularColor: Color3;
  29603. /**
  29604. * Define the color of the material as if self lit.
  29605. * This will be mixed in the final result even in the absence of light.
  29606. */
  29607. emissiveColor: Color3;
  29608. /**
  29609. * Defines how sharp are the highlights in the material.
  29610. * The bigger the value the sharper giving a more glossy feeling to the result.
  29611. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  29612. */
  29613. specularPower: number;
  29614. private _useAlphaFromDiffuseTexture;
  29615. /**
  29616. * Does the transparency come from the diffuse texture alpha channel.
  29617. */
  29618. useAlphaFromDiffuseTexture: boolean;
  29619. private _useEmissiveAsIllumination;
  29620. /**
  29621. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  29622. */
  29623. useEmissiveAsIllumination: boolean;
  29624. private _linkEmissiveWithDiffuse;
  29625. /**
  29626. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  29627. * the emissive level when the final color is close to one.
  29628. */
  29629. linkEmissiveWithDiffuse: boolean;
  29630. private _useSpecularOverAlpha;
  29631. /**
  29632. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  29633. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  29634. */
  29635. useSpecularOverAlpha: boolean;
  29636. private _useReflectionOverAlpha;
  29637. /**
  29638. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  29639. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  29640. */
  29641. useReflectionOverAlpha: boolean;
  29642. private _disableLighting;
  29643. /**
  29644. * Does lights from the scene impacts this material.
  29645. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  29646. */
  29647. disableLighting: boolean;
  29648. private _useObjectSpaceNormalMap;
  29649. /**
  29650. * Allows using an object space normal map (instead of tangent space).
  29651. */
  29652. useObjectSpaceNormalMap: boolean;
  29653. private _useParallax;
  29654. /**
  29655. * Is parallax enabled or not.
  29656. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  29657. */
  29658. useParallax: boolean;
  29659. private _useParallaxOcclusion;
  29660. /**
  29661. * Is parallax occlusion enabled or not.
  29662. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  29663. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  29664. */
  29665. useParallaxOcclusion: boolean;
  29666. /**
  29667. * 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.
  29668. */
  29669. parallaxScaleBias: number;
  29670. private _roughness;
  29671. /**
  29672. * Helps to define how blurry the reflections should appears in the material.
  29673. */
  29674. roughness: number;
  29675. /**
  29676. * In case of refraction, define the value of the index of refraction.
  29677. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29678. */
  29679. indexOfRefraction: number;
  29680. /**
  29681. * Invert the refraction texture alongside the y axis.
  29682. * It can be useful with procedural textures or probe for instance.
  29683. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29684. */
  29685. invertRefractionY: boolean;
  29686. /**
  29687. * Defines the alpha limits in alpha test mode.
  29688. */
  29689. alphaCutOff: number;
  29690. private _useLightmapAsShadowmap;
  29691. /**
  29692. * In case of light mapping, define whether the map contains light or shadow informations.
  29693. */
  29694. useLightmapAsShadowmap: boolean;
  29695. private _diffuseFresnelParameters;
  29696. /**
  29697. * Define the diffuse fresnel parameters of the material.
  29698. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29699. */
  29700. diffuseFresnelParameters: FresnelParameters;
  29701. private _opacityFresnelParameters;
  29702. /**
  29703. * Define the opacity fresnel parameters of the material.
  29704. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29705. */
  29706. opacityFresnelParameters: FresnelParameters;
  29707. private _reflectionFresnelParameters;
  29708. /**
  29709. * Define the reflection fresnel parameters of the material.
  29710. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29711. */
  29712. reflectionFresnelParameters: FresnelParameters;
  29713. private _refractionFresnelParameters;
  29714. /**
  29715. * Define the refraction fresnel parameters of the material.
  29716. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29717. */
  29718. refractionFresnelParameters: FresnelParameters;
  29719. private _emissiveFresnelParameters;
  29720. /**
  29721. * Define the emissive fresnel parameters of the material.
  29722. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29723. */
  29724. emissiveFresnelParameters: FresnelParameters;
  29725. private _useReflectionFresnelFromSpecular;
  29726. /**
  29727. * If true automatically deducts the fresnels values from the material specularity.
  29728. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29729. */
  29730. useReflectionFresnelFromSpecular: boolean;
  29731. private _useGlossinessFromSpecularMapAlpha;
  29732. /**
  29733. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  29734. */
  29735. useGlossinessFromSpecularMapAlpha: boolean;
  29736. private _maxSimultaneousLights;
  29737. /**
  29738. * Defines the maximum number of lights that can be used in the material
  29739. */
  29740. maxSimultaneousLights: number;
  29741. private _invertNormalMapX;
  29742. /**
  29743. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  29744. */
  29745. invertNormalMapX: boolean;
  29746. private _invertNormalMapY;
  29747. /**
  29748. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  29749. */
  29750. invertNormalMapY: boolean;
  29751. private _twoSidedLighting;
  29752. /**
  29753. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  29754. */
  29755. twoSidedLighting: boolean;
  29756. /**
  29757. * Default configuration related to image processing available in the standard Material.
  29758. */
  29759. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  29760. /**
  29761. * Gets the image processing configuration used either in this material.
  29762. */
  29763. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  29764. /**
  29765. * Sets the Default image processing configuration used either in the this material.
  29766. *
  29767. * If sets to null, the scene one is in use.
  29768. */
  29769. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  29770. /**
  29771. * Keep track of the image processing observer to allow dispose and replace.
  29772. */
  29773. private _imageProcessingObserver;
  29774. /**
  29775. * Attaches a new image processing configuration to the Standard Material.
  29776. * @param configuration
  29777. */
  29778. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  29779. /**
  29780. * Gets wether the color curves effect is enabled.
  29781. */
  29782. get cameraColorCurvesEnabled(): boolean;
  29783. /**
  29784. * Sets wether the color curves effect is enabled.
  29785. */
  29786. set cameraColorCurvesEnabled(value: boolean);
  29787. /**
  29788. * Gets wether the color grading effect is enabled.
  29789. */
  29790. get cameraColorGradingEnabled(): boolean;
  29791. /**
  29792. * Gets wether the color grading effect is enabled.
  29793. */
  29794. set cameraColorGradingEnabled(value: boolean);
  29795. /**
  29796. * Gets wether tonemapping is enabled or not.
  29797. */
  29798. get cameraToneMappingEnabled(): boolean;
  29799. /**
  29800. * Sets wether tonemapping is enabled or not
  29801. */
  29802. set cameraToneMappingEnabled(value: boolean);
  29803. /**
  29804. * The camera exposure used on this material.
  29805. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29806. * This corresponds to a photographic exposure.
  29807. */
  29808. get cameraExposure(): number;
  29809. /**
  29810. * The camera exposure used on this material.
  29811. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29812. * This corresponds to a photographic exposure.
  29813. */
  29814. set cameraExposure(value: number);
  29815. /**
  29816. * Gets The camera contrast used on this material.
  29817. */
  29818. get cameraContrast(): number;
  29819. /**
  29820. * Sets The camera contrast used on this material.
  29821. */
  29822. set cameraContrast(value: number);
  29823. /**
  29824. * Gets the Color Grading 2D Lookup Texture.
  29825. */
  29826. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  29827. /**
  29828. * Sets the Color Grading 2D Lookup Texture.
  29829. */
  29830. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  29831. /**
  29832. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29833. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29834. * 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;
  29835. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29836. */
  29837. get cameraColorCurves(): Nullable<ColorCurves>;
  29838. /**
  29839. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29840. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29841. * 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;
  29842. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29843. */
  29844. set cameraColorCurves(value: Nullable<ColorCurves>);
  29845. /**
  29846. * Defines the detail map parameters for the material.
  29847. */
  29848. readonly detailMap: DetailMapConfiguration;
  29849. protected _renderTargets: SmartArray<RenderTargetTexture>;
  29850. protected _worldViewProjectionMatrix: Matrix;
  29851. protected _globalAmbientColor: Color3;
  29852. protected _useLogarithmicDepth: boolean;
  29853. protected _rebuildInParallel: boolean;
  29854. /**
  29855. * Instantiates a new standard material.
  29856. * This is the default material used in Babylon. It is the best trade off between quality
  29857. * and performances.
  29858. * @see http://doc.babylonjs.com/babylon101/materials
  29859. * @param name Define the name of the material in the scene
  29860. * @param scene Define the scene the material belong to
  29861. */
  29862. constructor(name: string, scene: Scene);
  29863. /**
  29864. * Gets a boolean indicating that current material needs to register RTT
  29865. */
  29866. get hasRenderTargetTextures(): boolean;
  29867. /**
  29868. * Gets the current class name of the material e.g. "StandardMaterial"
  29869. * Mainly use in serialization.
  29870. * @returns the class name
  29871. */
  29872. getClassName(): string;
  29873. /**
  29874. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  29875. * You can try switching to logarithmic depth.
  29876. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  29877. */
  29878. get useLogarithmicDepth(): boolean;
  29879. set useLogarithmicDepth(value: boolean);
  29880. /**
  29881. * Specifies if the material will require alpha blending
  29882. * @returns a boolean specifying if alpha blending is needed
  29883. */
  29884. needAlphaBlending(): boolean;
  29885. /**
  29886. * Specifies if this material should be rendered in alpha test mode
  29887. * @returns a boolean specifying if an alpha test is needed.
  29888. */
  29889. needAlphaTesting(): boolean;
  29890. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  29891. /**
  29892. * Get the texture used for alpha test purpose.
  29893. * @returns the diffuse texture in case of the standard material.
  29894. */
  29895. getAlphaTestTexture(): Nullable<BaseTexture>;
  29896. /**
  29897. * Get if the submesh is ready to be used and all its information available.
  29898. * Child classes can use it to update shaders
  29899. * @param mesh defines the mesh to check
  29900. * @param subMesh defines which submesh to check
  29901. * @param useInstances specifies that instances should be used
  29902. * @returns a boolean indicating that the submesh is ready or not
  29903. */
  29904. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29905. /**
  29906. * Builds the material UBO layouts.
  29907. * Used internally during the effect preparation.
  29908. */
  29909. buildUniformLayout(): void;
  29910. /**
  29911. * Unbinds the material from the mesh
  29912. */
  29913. unbind(): void;
  29914. /**
  29915. * Binds the submesh to this material by preparing the effect and shader to draw
  29916. * @param world defines the world transformation matrix
  29917. * @param mesh defines the mesh containing the submesh
  29918. * @param subMesh defines the submesh to bind the material to
  29919. */
  29920. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29921. /**
  29922. * Get the list of animatables in the material.
  29923. * @returns the list of animatables object used in the material
  29924. */
  29925. getAnimatables(): IAnimatable[];
  29926. /**
  29927. * Gets the active textures from the material
  29928. * @returns an array of textures
  29929. */
  29930. getActiveTextures(): BaseTexture[];
  29931. /**
  29932. * Specifies if the material uses a texture
  29933. * @param texture defines the texture to check against the material
  29934. * @returns a boolean specifying if the material uses the texture
  29935. */
  29936. hasTexture(texture: BaseTexture): boolean;
  29937. /**
  29938. * Disposes the material
  29939. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29940. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29941. */
  29942. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  29943. /**
  29944. * Makes a duplicate of the material, and gives it a new name
  29945. * @param name defines the new name for the duplicated material
  29946. * @returns the cloned material
  29947. */
  29948. clone(name: string): StandardMaterial;
  29949. /**
  29950. * Serializes this material in a JSON representation
  29951. * @returns the serialized material object
  29952. */
  29953. serialize(): any;
  29954. /**
  29955. * Creates a standard material from parsed material data
  29956. * @param source defines the JSON representation of the material
  29957. * @param scene defines the hosting scene
  29958. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29959. * @returns a new standard material
  29960. */
  29961. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  29962. /**
  29963. * Are diffuse textures enabled in the application.
  29964. */
  29965. static get DiffuseTextureEnabled(): boolean;
  29966. static set DiffuseTextureEnabled(value: boolean);
  29967. /**
  29968. * Are detail textures enabled in the application.
  29969. */
  29970. static get DetailTextureEnabled(): boolean;
  29971. static set DetailTextureEnabled(value: boolean);
  29972. /**
  29973. * Are ambient textures enabled in the application.
  29974. */
  29975. static get AmbientTextureEnabled(): boolean;
  29976. static set AmbientTextureEnabled(value: boolean);
  29977. /**
  29978. * Are opacity textures enabled in the application.
  29979. */
  29980. static get OpacityTextureEnabled(): boolean;
  29981. static set OpacityTextureEnabled(value: boolean);
  29982. /**
  29983. * Are reflection textures enabled in the application.
  29984. */
  29985. static get ReflectionTextureEnabled(): boolean;
  29986. static set ReflectionTextureEnabled(value: boolean);
  29987. /**
  29988. * Are emissive textures enabled in the application.
  29989. */
  29990. static get EmissiveTextureEnabled(): boolean;
  29991. static set EmissiveTextureEnabled(value: boolean);
  29992. /**
  29993. * Are specular textures enabled in the application.
  29994. */
  29995. static get SpecularTextureEnabled(): boolean;
  29996. static set SpecularTextureEnabled(value: boolean);
  29997. /**
  29998. * Are bump textures enabled in the application.
  29999. */
  30000. static get BumpTextureEnabled(): boolean;
  30001. static set BumpTextureEnabled(value: boolean);
  30002. /**
  30003. * Are lightmap textures enabled in the application.
  30004. */
  30005. static get LightmapTextureEnabled(): boolean;
  30006. static set LightmapTextureEnabled(value: boolean);
  30007. /**
  30008. * Are refraction textures enabled in the application.
  30009. */
  30010. static get RefractionTextureEnabled(): boolean;
  30011. static set RefractionTextureEnabled(value: boolean);
  30012. /**
  30013. * Are color grading textures enabled in the application.
  30014. */
  30015. static get ColorGradingTextureEnabled(): boolean;
  30016. static set ColorGradingTextureEnabled(value: boolean);
  30017. /**
  30018. * Are fresnels enabled in the application.
  30019. */
  30020. static get FresnelEnabled(): boolean;
  30021. static set FresnelEnabled(value: boolean);
  30022. }
  30023. }
  30024. declare module BABYLON {
  30025. /**
  30026. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  30027. *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.
  30028. * The SPS is also a particle system. It provides some methods to manage the particles.
  30029. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  30030. *
  30031. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  30032. */
  30033. export class SolidParticleSystem implements IDisposable {
  30034. /**
  30035. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  30036. * Example : var p = SPS.particles[i];
  30037. */
  30038. particles: SolidParticle[];
  30039. /**
  30040. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  30041. */
  30042. nbParticles: number;
  30043. /**
  30044. * If the particles must ever face the camera (default false). Useful for planar particles.
  30045. */
  30046. billboard: boolean;
  30047. /**
  30048. * Recompute normals when adding a shape
  30049. */
  30050. recomputeNormals: boolean;
  30051. /**
  30052. * This a counter ofr your own usage. It's not set by any SPS functions.
  30053. */
  30054. counter: number;
  30055. /**
  30056. * The SPS name. This name is also given to the underlying mesh.
  30057. */
  30058. name: string;
  30059. /**
  30060. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  30061. */
  30062. mesh: Mesh;
  30063. /**
  30064. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  30065. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  30066. */
  30067. vars: any;
  30068. /**
  30069. * This array is populated when the SPS is set as 'pickable'.
  30070. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  30071. * Each element of this array is an object `{idx: int, faceId: int}`.
  30072. * `idx` is the picked particle index in the `SPS.particles` array
  30073. * `faceId` is the picked face index counted within this particle.
  30074. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  30075. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  30076. * Use the method SPS.pickedParticle(pickingInfo) instead.
  30077. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30078. */
  30079. pickedParticles: {
  30080. idx: number;
  30081. faceId: number;
  30082. }[];
  30083. /**
  30084. * This array is populated when the SPS is set as 'pickable'
  30085. * Each key of this array is a submesh index.
  30086. * Each element of this array is a second array defined like this :
  30087. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  30088. * Each element of this second array is an object `{idx: int, faceId: int}`.
  30089. * `idx` is the picked particle index in the `SPS.particles` array
  30090. * `faceId` is the picked face index counted within this particle.
  30091. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  30092. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30093. */
  30094. pickedBySubMesh: {
  30095. idx: number;
  30096. faceId: number;
  30097. }[][];
  30098. /**
  30099. * This array is populated when `enableDepthSort` is set to true.
  30100. * Each element of this array is an instance of the class DepthSortedParticle.
  30101. */
  30102. depthSortedParticles: DepthSortedParticle[];
  30103. /**
  30104. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  30105. * @hidden
  30106. */
  30107. _bSphereOnly: boolean;
  30108. /**
  30109. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  30110. * @hidden
  30111. */
  30112. _bSphereRadiusFactor: number;
  30113. private _scene;
  30114. private _positions;
  30115. private _indices;
  30116. private _normals;
  30117. private _colors;
  30118. private _uvs;
  30119. private _indices32;
  30120. private _positions32;
  30121. private _normals32;
  30122. private _fixedNormal32;
  30123. private _colors32;
  30124. private _uvs32;
  30125. private _index;
  30126. private _updatable;
  30127. private _pickable;
  30128. private _isVisibilityBoxLocked;
  30129. private _alwaysVisible;
  30130. private _depthSort;
  30131. private _expandable;
  30132. private _shapeCounter;
  30133. private _copy;
  30134. private _color;
  30135. private _computeParticleColor;
  30136. private _computeParticleTexture;
  30137. private _computeParticleRotation;
  30138. private _computeParticleVertex;
  30139. private _computeBoundingBox;
  30140. private _depthSortParticles;
  30141. private _camera;
  30142. private _mustUnrotateFixedNormals;
  30143. private _particlesIntersect;
  30144. private _needs32Bits;
  30145. private _isNotBuilt;
  30146. private _lastParticleId;
  30147. private _idxOfId;
  30148. private _multimaterialEnabled;
  30149. private _useModelMaterial;
  30150. private _indicesByMaterial;
  30151. private _materialIndexes;
  30152. private _depthSortFunction;
  30153. private _materialSortFunction;
  30154. private _materials;
  30155. private _multimaterial;
  30156. private _materialIndexesById;
  30157. private _defaultMaterial;
  30158. private _autoUpdateSubMeshes;
  30159. private _tmpVertex;
  30160. /**
  30161. * Creates a SPS (Solid Particle System) object.
  30162. * @param name (String) is the SPS name, this will be the underlying mesh name.
  30163. * @param scene (Scene) is the scene in which the SPS is added.
  30164. * @param options defines the options of the sps e.g.
  30165. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  30166. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  30167. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  30168. * * 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.
  30169. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  30170. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  30171. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  30172. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  30173. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  30174. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  30175. */
  30176. constructor(name: string, scene: Scene, options?: {
  30177. updatable?: boolean;
  30178. isPickable?: boolean;
  30179. enableDepthSort?: boolean;
  30180. particleIntersection?: boolean;
  30181. boundingSphereOnly?: boolean;
  30182. bSphereRadiusFactor?: number;
  30183. expandable?: boolean;
  30184. useModelMaterial?: boolean;
  30185. enableMultiMaterial?: boolean;
  30186. });
  30187. /**
  30188. * Builds the SPS underlying mesh. Returns a standard Mesh.
  30189. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  30190. * @returns the created mesh
  30191. */
  30192. buildMesh(): Mesh;
  30193. /**
  30194. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  30195. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  30196. * Thus the particles generated from `digest()` have their property `position` set yet.
  30197. * @param mesh ( Mesh ) is the mesh to be digested
  30198. * @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
  30199. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  30200. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  30201. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30202. * @returns the current SPS
  30203. */
  30204. digest(mesh: Mesh, options?: {
  30205. facetNb?: number;
  30206. number?: number;
  30207. delta?: number;
  30208. storage?: [];
  30209. }): SolidParticleSystem;
  30210. /**
  30211. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  30212. * @hidden
  30213. */
  30214. private _unrotateFixedNormals;
  30215. /**
  30216. * Resets the temporary working copy particle
  30217. * @hidden
  30218. */
  30219. private _resetCopy;
  30220. /**
  30221. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  30222. * @param p the current index in the positions array to be updated
  30223. * @param ind the current index in the indices array
  30224. * @param shape a Vector3 array, the shape geometry
  30225. * @param positions the positions array to be updated
  30226. * @param meshInd the shape indices array
  30227. * @param indices the indices array to be updated
  30228. * @param meshUV the shape uv array
  30229. * @param uvs the uv array to be updated
  30230. * @param meshCol the shape color array
  30231. * @param colors the color array to be updated
  30232. * @param meshNor the shape normals array
  30233. * @param normals the normals array to be updated
  30234. * @param idx the particle index
  30235. * @param idxInShape the particle index in its shape
  30236. * @param options the addShape() method passed options
  30237. * @model the particle model
  30238. * @hidden
  30239. */
  30240. private _meshBuilder;
  30241. /**
  30242. * Returns a shape Vector3 array from positions float array
  30243. * @param positions float array
  30244. * @returns a vector3 array
  30245. * @hidden
  30246. */
  30247. private _posToShape;
  30248. /**
  30249. * Returns a shapeUV array from a float uvs (array deep copy)
  30250. * @param uvs as a float array
  30251. * @returns a shapeUV array
  30252. * @hidden
  30253. */
  30254. private _uvsToShapeUV;
  30255. /**
  30256. * Adds a new particle object in the particles array
  30257. * @param idx particle index in particles array
  30258. * @param id particle id
  30259. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  30260. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  30261. * @param model particle ModelShape object
  30262. * @param shapeId model shape identifier
  30263. * @param idxInShape index of the particle in the current model
  30264. * @param bInfo model bounding info object
  30265. * @param storage target storage array, if any
  30266. * @hidden
  30267. */
  30268. private _addParticle;
  30269. /**
  30270. * Adds some particles to the SPS from the model shape. Returns the shape id.
  30271. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  30272. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  30273. * @param nb (positive integer) the number of particles to be created from this model
  30274. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  30275. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  30276. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30277. * @returns the number of shapes in the system
  30278. */
  30279. addShape(mesh: Mesh, nb: number, options?: {
  30280. positionFunction?: any;
  30281. vertexFunction?: any;
  30282. storage?: [];
  30283. }): number;
  30284. /**
  30285. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  30286. * @hidden
  30287. */
  30288. private _rebuildParticle;
  30289. /**
  30290. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  30291. * @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.
  30292. * @returns the SPS.
  30293. */
  30294. rebuildMesh(reset?: boolean): SolidParticleSystem;
  30295. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  30296. * Returns an array with the removed particles.
  30297. * 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.
  30298. * The SPS can't be empty so at least one particle needs to remain in place.
  30299. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  30300. * @param start index of the first particle to remove
  30301. * @param end index of the last particle to remove (included)
  30302. * @returns an array populated with the removed particles
  30303. */
  30304. removeParticles(start: number, end: number): SolidParticle[];
  30305. /**
  30306. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  30307. * @param solidParticleArray an array populated with Solid Particles objects
  30308. * @returns the SPS
  30309. */
  30310. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  30311. /**
  30312. * Creates a new particle and modifies the SPS mesh geometry :
  30313. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  30314. * - calls _addParticle() to populate the particle array
  30315. * factorized code from addShape() and insertParticlesFromArray()
  30316. * @param idx particle index in the particles array
  30317. * @param i particle index in its shape
  30318. * @param modelShape particle ModelShape object
  30319. * @param shape shape vertex array
  30320. * @param meshInd shape indices array
  30321. * @param meshUV shape uv array
  30322. * @param meshCol shape color array
  30323. * @param meshNor shape normals array
  30324. * @param bbInfo shape bounding info
  30325. * @param storage target particle storage
  30326. * @options addShape() passed options
  30327. * @hidden
  30328. */
  30329. private _insertNewParticle;
  30330. /**
  30331. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  30332. * This method calls `updateParticle()` for each particle of the SPS.
  30333. * For an animated SPS, it is usually called within the render loop.
  30334. * 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.
  30335. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  30336. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  30337. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  30338. * @returns the SPS.
  30339. */
  30340. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  30341. /**
  30342. * Disposes the SPS.
  30343. */
  30344. dispose(): void;
  30345. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  30346. * idx is the particle index in the SPS
  30347. * faceId is the picked face index counted within this particle.
  30348. * Returns null if the pickInfo can't identify a picked particle.
  30349. * @param pickingInfo (PickingInfo object)
  30350. * @returns {idx: number, faceId: number} or null
  30351. */
  30352. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  30353. idx: number;
  30354. faceId: number;
  30355. }>;
  30356. /**
  30357. * Returns a SolidParticle object from its identifier : particle.id
  30358. * @param id (integer) the particle Id
  30359. * @returns the searched particle or null if not found in the SPS.
  30360. */
  30361. getParticleById(id: number): Nullable<SolidParticle>;
  30362. /**
  30363. * Returns a new array populated with the particles having the passed shapeId.
  30364. * @param shapeId (integer) the shape identifier
  30365. * @returns a new solid particle array
  30366. */
  30367. getParticlesByShapeId(shapeId: number): SolidParticle[];
  30368. /**
  30369. * Populates the passed array "ref" with the particles having the passed shapeId.
  30370. * @param shapeId the shape identifier
  30371. * @returns the SPS
  30372. * @param ref
  30373. */
  30374. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  30375. /**
  30376. * Computes the required SubMeshes according the materials assigned to the particles.
  30377. * @returns the solid particle system.
  30378. * Does nothing if called before the SPS mesh is built.
  30379. */
  30380. computeSubMeshes(): SolidParticleSystem;
  30381. /**
  30382. * Sorts the solid particles by material when MultiMaterial is enabled.
  30383. * Updates the indices32 array.
  30384. * Updates the indicesByMaterial array.
  30385. * Updates the mesh indices array.
  30386. * @returns the SPS
  30387. * @hidden
  30388. */
  30389. private _sortParticlesByMaterial;
  30390. /**
  30391. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  30392. * @hidden
  30393. */
  30394. private _setMaterialIndexesById;
  30395. /**
  30396. * Returns an array with unique values of Materials from the passed array
  30397. * @param array the material array to be checked and filtered
  30398. * @hidden
  30399. */
  30400. private _filterUniqueMaterialId;
  30401. /**
  30402. * Sets a new Standard Material as _defaultMaterial if not already set.
  30403. * @hidden
  30404. */
  30405. private _setDefaultMaterial;
  30406. /**
  30407. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  30408. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30409. * @returns the SPS.
  30410. */
  30411. refreshVisibleSize(): SolidParticleSystem;
  30412. /**
  30413. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  30414. * @param size the size (float) of the visibility box
  30415. * note : this doesn't lock the SPS mesh bounding box.
  30416. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30417. */
  30418. setVisibilityBox(size: number): void;
  30419. /**
  30420. * Gets whether the SPS as always visible or not
  30421. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30422. */
  30423. get isAlwaysVisible(): boolean;
  30424. /**
  30425. * Sets the SPS as always visible or not
  30426. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30427. */
  30428. set isAlwaysVisible(val: boolean);
  30429. /**
  30430. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30431. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30432. */
  30433. set isVisibilityBoxLocked(val: boolean);
  30434. /**
  30435. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30436. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30437. */
  30438. get isVisibilityBoxLocked(): boolean;
  30439. /**
  30440. * Tells to `setParticles()` to compute the particle rotations or not.
  30441. * Default value : true. The SPS is faster when it's set to false.
  30442. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30443. */
  30444. set computeParticleRotation(val: boolean);
  30445. /**
  30446. * Tells to `setParticles()` to compute the particle colors or not.
  30447. * Default value : true. The SPS is faster when it's set to false.
  30448. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30449. */
  30450. set computeParticleColor(val: boolean);
  30451. set computeParticleTexture(val: boolean);
  30452. /**
  30453. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  30454. * Default value : false. The SPS is faster when it's set to false.
  30455. * Note : the particle custom vertex positions aren't stored values.
  30456. */
  30457. set computeParticleVertex(val: boolean);
  30458. /**
  30459. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  30460. */
  30461. set computeBoundingBox(val: boolean);
  30462. /**
  30463. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  30464. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30465. * Default : `true`
  30466. */
  30467. set depthSortParticles(val: boolean);
  30468. /**
  30469. * Gets if `setParticles()` computes the particle rotations or not.
  30470. * Default value : true. The SPS is faster when it's set to false.
  30471. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30472. */
  30473. get computeParticleRotation(): boolean;
  30474. /**
  30475. * Gets if `setParticles()` computes the particle colors or not.
  30476. * Default value : true. The SPS is faster when it's set to false.
  30477. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30478. */
  30479. get computeParticleColor(): boolean;
  30480. /**
  30481. * Gets if `setParticles()` computes the particle textures or not.
  30482. * Default value : true. The SPS is faster when it's set to false.
  30483. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  30484. */
  30485. get computeParticleTexture(): boolean;
  30486. /**
  30487. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  30488. * Default value : false. The SPS is faster when it's set to false.
  30489. * Note : the particle custom vertex positions aren't stored values.
  30490. */
  30491. get computeParticleVertex(): boolean;
  30492. /**
  30493. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  30494. */
  30495. get computeBoundingBox(): boolean;
  30496. /**
  30497. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  30498. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30499. * Default : `true`
  30500. */
  30501. get depthSortParticles(): boolean;
  30502. /**
  30503. * Gets if the SPS is created as expandable at construction time.
  30504. * Default : `false`
  30505. */
  30506. get expandable(): boolean;
  30507. /**
  30508. * Gets if the SPS supports the Multi Materials
  30509. */
  30510. get multimaterialEnabled(): boolean;
  30511. /**
  30512. * Gets if the SPS uses the model materials for its own multimaterial.
  30513. */
  30514. get useModelMaterial(): boolean;
  30515. /**
  30516. * The SPS used material array.
  30517. */
  30518. get materials(): Material[];
  30519. /**
  30520. * Sets the SPS MultiMaterial from the passed materials.
  30521. * Note : the passed array is internally copied and not used then by reference.
  30522. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  30523. */
  30524. setMultiMaterial(materials: Material[]): void;
  30525. /**
  30526. * The SPS computed multimaterial object
  30527. */
  30528. get multimaterial(): MultiMaterial;
  30529. set multimaterial(mm: MultiMaterial);
  30530. /**
  30531. * If the subMeshes must be updated on the next call to setParticles()
  30532. */
  30533. get autoUpdateSubMeshes(): boolean;
  30534. set autoUpdateSubMeshes(val: boolean);
  30535. /**
  30536. * This function does nothing. It may be overwritten to set all the particle first values.
  30537. * The SPS doesn't call this function, you may have to call it by your own.
  30538. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30539. */
  30540. initParticles(): void;
  30541. /**
  30542. * This function does nothing. It may be overwritten to recycle a particle.
  30543. * The SPS doesn't call this function, you may have to call it by your own.
  30544. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30545. * @param particle The particle to recycle
  30546. * @returns the recycled particle
  30547. */
  30548. recycleParticle(particle: SolidParticle): SolidParticle;
  30549. /**
  30550. * Updates a particle : this function should be overwritten by the user.
  30551. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  30552. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30553. * @example : just set a particle position or velocity and recycle conditions
  30554. * @param particle The particle to update
  30555. * @returns the updated particle
  30556. */
  30557. updateParticle(particle: SolidParticle): SolidParticle;
  30558. /**
  30559. * Updates a vertex of a particle : it can be overwritten by the user.
  30560. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  30561. * @param particle the current particle
  30562. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  30563. * @param pt the index of the current vertex in the particle shape
  30564. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  30565. * @example : just set a vertex particle position or color
  30566. * @returns the sps
  30567. */
  30568. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  30569. /**
  30570. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  30571. * This does nothing and may be overwritten by the user.
  30572. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30573. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30574. * @param update the boolean update value actually passed to setParticles()
  30575. */
  30576. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30577. /**
  30578. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  30579. * This will be passed three parameters.
  30580. * This does nothing and may be overwritten by the user.
  30581. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30582. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30583. * @param update the boolean update value actually passed to setParticles()
  30584. */
  30585. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30586. }
  30587. }
  30588. declare module BABYLON {
  30589. /**
  30590. * Represents one particle of a solid particle system.
  30591. */
  30592. export class SolidParticle {
  30593. /**
  30594. * particle global index
  30595. */
  30596. idx: number;
  30597. /**
  30598. * particle identifier
  30599. */
  30600. id: number;
  30601. /**
  30602. * The color of the particle
  30603. */
  30604. color: Nullable<Color4>;
  30605. /**
  30606. * The world space position of the particle.
  30607. */
  30608. position: Vector3;
  30609. /**
  30610. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  30611. */
  30612. rotation: Vector3;
  30613. /**
  30614. * The world space rotation quaternion of the particle.
  30615. */
  30616. rotationQuaternion: Nullable<Quaternion>;
  30617. /**
  30618. * The scaling of the particle.
  30619. */
  30620. scaling: Vector3;
  30621. /**
  30622. * The uvs of the particle.
  30623. */
  30624. uvs: Vector4;
  30625. /**
  30626. * The current speed of the particle.
  30627. */
  30628. velocity: Vector3;
  30629. /**
  30630. * The pivot point in the particle local space.
  30631. */
  30632. pivot: Vector3;
  30633. /**
  30634. * Must the particle be translated from its pivot point in its local space ?
  30635. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  30636. * Default : false
  30637. */
  30638. translateFromPivot: boolean;
  30639. /**
  30640. * Is the particle active or not ?
  30641. */
  30642. alive: boolean;
  30643. /**
  30644. * Is the particle visible or not ?
  30645. */
  30646. isVisible: boolean;
  30647. /**
  30648. * Index of this particle in the global "positions" array (Internal use)
  30649. * @hidden
  30650. */
  30651. _pos: number;
  30652. /**
  30653. * @hidden Index of this particle in the global "indices" array (Internal use)
  30654. */
  30655. _ind: number;
  30656. /**
  30657. * @hidden ModelShape of this particle (Internal use)
  30658. */
  30659. _model: ModelShape;
  30660. /**
  30661. * ModelShape id of this particle
  30662. */
  30663. shapeId: number;
  30664. /**
  30665. * Index of the particle in its shape id
  30666. */
  30667. idxInShape: number;
  30668. /**
  30669. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  30670. */
  30671. _modelBoundingInfo: BoundingInfo;
  30672. /**
  30673. * @hidden Particle BoundingInfo object (Internal use)
  30674. */
  30675. _boundingInfo: BoundingInfo;
  30676. /**
  30677. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  30678. */
  30679. _sps: SolidParticleSystem;
  30680. /**
  30681. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  30682. */
  30683. _stillInvisible: boolean;
  30684. /**
  30685. * @hidden Last computed particle rotation matrix
  30686. */
  30687. _rotationMatrix: number[];
  30688. /**
  30689. * Parent particle Id, if any.
  30690. * Default null.
  30691. */
  30692. parentId: Nullable<number>;
  30693. /**
  30694. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  30695. */
  30696. materialIndex: Nullable<number>;
  30697. /**
  30698. * Custom object or properties.
  30699. */
  30700. props: Nullable<any>;
  30701. /**
  30702. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  30703. * The possible values are :
  30704. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  30705. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30706. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  30707. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  30708. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30709. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  30710. * */
  30711. cullingStrategy: number;
  30712. /**
  30713. * @hidden Internal global position in the SPS.
  30714. */
  30715. _globalPosition: Vector3;
  30716. /**
  30717. * Creates a Solid Particle object.
  30718. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  30719. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  30720. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  30721. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  30722. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  30723. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  30724. * @param shapeId (integer) is the model shape identifier in the SPS.
  30725. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  30726. * @param sps defines the sps it is associated to
  30727. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  30728. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  30729. */
  30730. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  30731. /**
  30732. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  30733. * @param target the particle target
  30734. * @returns the current particle
  30735. */
  30736. copyToRef(target: SolidParticle): SolidParticle;
  30737. /**
  30738. * Legacy support, changed scale to scaling
  30739. */
  30740. get scale(): Vector3;
  30741. /**
  30742. * Legacy support, changed scale to scaling
  30743. */
  30744. set scale(scale: Vector3);
  30745. /**
  30746. * Legacy support, changed quaternion to rotationQuaternion
  30747. */
  30748. get quaternion(): Nullable<Quaternion>;
  30749. /**
  30750. * Legacy support, changed quaternion to rotationQuaternion
  30751. */
  30752. set quaternion(q: Nullable<Quaternion>);
  30753. /**
  30754. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  30755. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  30756. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  30757. * @returns true if it intersects
  30758. */
  30759. intersectsMesh(target: Mesh | SolidParticle): boolean;
  30760. /**
  30761. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  30762. * A particle is in the frustum if its bounding box intersects the frustum
  30763. * @param frustumPlanes defines the frustum to test
  30764. * @returns true if the particle is in the frustum planes
  30765. */
  30766. isInFrustum(frustumPlanes: Plane[]): boolean;
  30767. /**
  30768. * get the rotation matrix of the particle
  30769. * @hidden
  30770. */
  30771. getRotationMatrix(m: Matrix): void;
  30772. }
  30773. /**
  30774. * Represents the shape of the model used by one particle of a solid particle system.
  30775. * SPS internal tool, don't use it manually.
  30776. */
  30777. export class ModelShape {
  30778. /**
  30779. * The shape id
  30780. * @hidden
  30781. */
  30782. shapeID: number;
  30783. /**
  30784. * flat array of model positions (internal use)
  30785. * @hidden
  30786. */
  30787. _shape: Vector3[];
  30788. /**
  30789. * flat array of model UVs (internal use)
  30790. * @hidden
  30791. */
  30792. _shapeUV: number[];
  30793. /**
  30794. * color array of the model
  30795. * @hidden
  30796. */
  30797. _shapeColors: number[];
  30798. /**
  30799. * indices array of the model
  30800. * @hidden
  30801. */
  30802. _indices: number[];
  30803. /**
  30804. * normals array of the model
  30805. * @hidden
  30806. */
  30807. _normals: number[];
  30808. /**
  30809. * length of the shape in the model indices array (internal use)
  30810. * @hidden
  30811. */
  30812. _indicesLength: number;
  30813. /**
  30814. * Custom position function (internal use)
  30815. * @hidden
  30816. */
  30817. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  30818. /**
  30819. * Custom vertex function (internal use)
  30820. * @hidden
  30821. */
  30822. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  30823. /**
  30824. * Model material (internal use)
  30825. * @hidden
  30826. */
  30827. _material: Nullable<Material>;
  30828. /**
  30829. * 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.
  30830. * SPS internal tool, don't use it manually.
  30831. * @hidden
  30832. */
  30833. 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>);
  30834. }
  30835. /**
  30836. * Represents a Depth Sorted Particle in the solid particle system.
  30837. * @hidden
  30838. */
  30839. export class DepthSortedParticle {
  30840. /**
  30841. * Particle index
  30842. */
  30843. idx: number;
  30844. /**
  30845. * Index of the particle in the "indices" array
  30846. */
  30847. ind: number;
  30848. /**
  30849. * Length of the particle shape in the "indices" array
  30850. */
  30851. indicesLength: number;
  30852. /**
  30853. * Squared distance from the particle to the camera
  30854. */
  30855. sqDistance: number;
  30856. /**
  30857. * Material index when used with MultiMaterials
  30858. */
  30859. materialIndex: number;
  30860. /**
  30861. * Creates a new sorted particle
  30862. * @param materialIndex
  30863. */
  30864. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  30865. }
  30866. /**
  30867. * Represents a solid particle vertex
  30868. */
  30869. export class SolidParticleVertex {
  30870. /**
  30871. * Vertex position
  30872. */
  30873. position: Vector3;
  30874. /**
  30875. * Vertex color
  30876. */
  30877. color: Color4;
  30878. /**
  30879. * Vertex UV
  30880. */
  30881. uv: Vector2;
  30882. /**
  30883. * Creates a new solid particle vertex
  30884. */
  30885. constructor();
  30886. /** Vertex x coordinate */
  30887. get x(): number;
  30888. set x(val: number);
  30889. /** Vertex y coordinate */
  30890. get y(): number;
  30891. set y(val: number);
  30892. /** Vertex z coordinate */
  30893. get z(): number;
  30894. set z(val: number);
  30895. }
  30896. }
  30897. declare module BABYLON {
  30898. /**
  30899. * @hidden
  30900. */
  30901. export class _MeshCollisionData {
  30902. _checkCollisions: boolean;
  30903. _collisionMask: number;
  30904. _collisionGroup: number;
  30905. _surroundingMeshes: Nullable<AbstractMesh[]>;
  30906. _collider: Nullable<Collider>;
  30907. _oldPositionForCollisions: Vector3;
  30908. _diffPositionForCollisions: Vector3;
  30909. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  30910. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  30911. }
  30912. }
  30913. declare module BABYLON {
  30914. /** @hidden */
  30915. class _FacetDataStorage {
  30916. facetPositions: Vector3[];
  30917. facetNormals: Vector3[];
  30918. facetPartitioning: number[][];
  30919. facetNb: number;
  30920. partitioningSubdivisions: number;
  30921. partitioningBBoxRatio: number;
  30922. facetDataEnabled: boolean;
  30923. facetParameters: any;
  30924. bbSize: Vector3;
  30925. subDiv: {
  30926. max: number;
  30927. X: number;
  30928. Y: number;
  30929. Z: number;
  30930. };
  30931. facetDepthSort: boolean;
  30932. facetDepthSortEnabled: boolean;
  30933. depthSortedIndices: IndicesArray;
  30934. depthSortedFacets: {
  30935. ind: number;
  30936. sqDistance: number;
  30937. }[];
  30938. facetDepthSortFunction: (f1: {
  30939. ind: number;
  30940. sqDistance: number;
  30941. }, f2: {
  30942. ind: number;
  30943. sqDistance: number;
  30944. }) => number;
  30945. facetDepthSortFrom: Vector3;
  30946. facetDepthSortOrigin: Vector3;
  30947. invertedMatrix: Matrix;
  30948. }
  30949. /**
  30950. * @hidden
  30951. **/
  30952. class _InternalAbstractMeshDataInfo {
  30953. _hasVertexAlpha: boolean;
  30954. _useVertexColors: boolean;
  30955. _numBoneInfluencers: number;
  30956. _applyFog: boolean;
  30957. _receiveShadows: boolean;
  30958. _facetData: _FacetDataStorage;
  30959. _visibility: number;
  30960. _skeleton: Nullable<Skeleton>;
  30961. _layerMask: number;
  30962. _computeBonesUsingShaders: boolean;
  30963. _isActive: boolean;
  30964. _onlyForInstances: boolean;
  30965. _isActiveIntermediate: boolean;
  30966. _onlyForInstancesIntermediate: boolean;
  30967. _actAsRegularMesh: boolean;
  30968. }
  30969. /**
  30970. * Class used to store all common mesh properties
  30971. */
  30972. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  30973. /** No occlusion */
  30974. static OCCLUSION_TYPE_NONE: number;
  30975. /** Occlusion set to optimisitic */
  30976. static OCCLUSION_TYPE_OPTIMISTIC: number;
  30977. /** Occlusion set to strict */
  30978. static OCCLUSION_TYPE_STRICT: number;
  30979. /** Use an accurante occlusion algorithm */
  30980. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  30981. /** Use a conservative occlusion algorithm */
  30982. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  30983. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  30984. * Test order :
  30985. * Is the bounding sphere outside the frustum ?
  30986. * If not, are the bounding box vertices outside the frustum ?
  30987. * It not, then the cullable object is in the frustum.
  30988. */
  30989. static readonly CULLINGSTRATEGY_STANDARD: number;
  30990. /** Culling strategy : Bounding Sphere Only.
  30991. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  30992. * It's also less accurate than the standard because some not visible objects can still be selected.
  30993. * Test : is the bounding sphere outside the frustum ?
  30994. * If not, then the cullable object is in the frustum.
  30995. */
  30996. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  30997. /** Culling strategy : Optimistic Inclusion.
  30998. * This in an inclusion test first, then the standard exclusion test.
  30999. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  31000. * 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.
  31001. * Anyway, it's as accurate as the standard strategy.
  31002. * Test :
  31003. * Is the cullable object bounding sphere center in the frustum ?
  31004. * If not, apply the default culling strategy.
  31005. */
  31006. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  31007. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  31008. * This in an inclusion test first, then the bounding sphere only exclusion test.
  31009. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  31010. * 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.
  31011. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  31012. * Test :
  31013. * Is the cullable object bounding sphere center in the frustum ?
  31014. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  31015. */
  31016. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  31017. /**
  31018. * No billboard
  31019. */
  31020. static get BILLBOARDMODE_NONE(): number;
  31021. /** Billboard on X axis */
  31022. static get BILLBOARDMODE_X(): number;
  31023. /** Billboard on Y axis */
  31024. static get BILLBOARDMODE_Y(): number;
  31025. /** Billboard on Z axis */
  31026. static get BILLBOARDMODE_Z(): number;
  31027. /** Billboard on all axes */
  31028. static get BILLBOARDMODE_ALL(): number;
  31029. /** Billboard on using position instead of orientation */
  31030. static get BILLBOARDMODE_USE_POSITION(): number;
  31031. /** @hidden */
  31032. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  31033. /**
  31034. * The culling strategy to use to check whether the mesh must be rendered or not.
  31035. * This value can be changed at any time and will be used on the next render mesh selection.
  31036. * The possible values are :
  31037. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31038. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31039. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31040. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31041. * Please read each static variable documentation to get details about the culling process.
  31042. * */
  31043. cullingStrategy: number;
  31044. /**
  31045. * Gets the number of facets in the mesh
  31046. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  31047. */
  31048. get facetNb(): number;
  31049. /**
  31050. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  31051. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  31052. */
  31053. get partitioningSubdivisions(): number;
  31054. set partitioningSubdivisions(nb: number);
  31055. /**
  31056. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  31057. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  31058. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  31059. */
  31060. get partitioningBBoxRatio(): number;
  31061. set partitioningBBoxRatio(ratio: number);
  31062. /**
  31063. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  31064. * Works only for updatable meshes.
  31065. * Doesn't work with multi-materials
  31066. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  31067. */
  31068. get mustDepthSortFacets(): boolean;
  31069. set mustDepthSortFacets(sort: boolean);
  31070. /**
  31071. * The location (Vector3) where the facet depth sort must be computed from.
  31072. * By default, the active camera position.
  31073. * Used only when facet depth sort is enabled
  31074. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  31075. */
  31076. get facetDepthSortFrom(): Vector3;
  31077. set facetDepthSortFrom(location: Vector3);
  31078. /**
  31079. * gets a boolean indicating if facetData is enabled
  31080. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  31081. */
  31082. get isFacetDataEnabled(): boolean;
  31083. /** @hidden */
  31084. _updateNonUniformScalingState(value: boolean): boolean;
  31085. /**
  31086. * An event triggered when this mesh collides with another one
  31087. */
  31088. onCollideObservable: Observable<AbstractMesh>;
  31089. /** Set a function to call when this mesh collides with another one */
  31090. set onCollide(callback: () => void);
  31091. /**
  31092. * An event triggered when the collision's position changes
  31093. */
  31094. onCollisionPositionChangeObservable: Observable<Vector3>;
  31095. /** Set a function to call when the collision's position changes */
  31096. set onCollisionPositionChange(callback: () => void);
  31097. /**
  31098. * An event triggered when material is changed
  31099. */
  31100. onMaterialChangedObservable: Observable<AbstractMesh>;
  31101. /**
  31102. * Gets or sets the orientation for POV movement & rotation
  31103. */
  31104. definedFacingForward: boolean;
  31105. /** @hidden */
  31106. _occlusionQuery: Nullable<WebGLQuery>;
  31107. /** @hidden */
  31108. _renderingGroup: Nullable<RenderingGroup>;
  31109. /**
  31110. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  31111. */
  31112. get visibility(): number;
  31113. /**
  31114. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  31115. */
  31116. set visibility(value: number);
  31117. /** Gets or sets the alpha index used to sort transparent meshes
  31118. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  31119. */
  31120. alphaIndex: number;
  31121. /**
  31122. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  31123. */
  31124. isVisible: boolean;
  31125. /**
  31126. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  31127. */
  31128. isPickable: boolean;
  31129. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  31130. showSubMeshesBoundingBox: boolean;
  31131. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  31132. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  31133. */
  31134. isBlocker: boolean;
  31135. /**
  31136. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  31137. */
  31138. enablePointerMoveEvents: boolean;
  31139. /**
  31140. * Specifies the rendering group id for this mesh (0 by default)
  31141. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  31142. */
  31143. renderingGroupId: number;
  31144. private _material;
  31145. /** Gets or sets current material */
  31146. get material(): Nullable<Material>;
  31147. set material(value: Nullable<Material>);
  31148. /**
  31149. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  31150. * @see http://doc.babylonjs.com/babylon101/shadows
  31151. */
  31152. get receiveShadows(): boolean;
  31153. set receiveShadows(value: boolean);
  31154. /** Defines color to use when rendering outline */
  31155. outlineColor: Color3;
  31156. /** Define width to use when rendering outline */
  31157. outlineWidth: number;
  31158. /** Defines color to use when rendering overlay */
  31159. overlayColor: Color3;
  31160. /** Defines alpha to use when rendering overlay */
  31161. overlayAlpha: number;
  31162. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  31163. get hasVertexAlpha(): boolean;
  31164. set hasVertexAlpha(value: boolean);
  31165. /** 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) */
  31166. get useVertexColors(): boolean;
  31167. set useVertexColors(value: boolean);
  31168. /**
  31169. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  31170. */
  31171. get computeBonesUsingShaders(): boolean;
  31172. set computeBonesUsingShaders(value: boolean);
  31173. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  31174. get numBoneInfluencers(): number;
  31175. set numBoneInfluencers(value: number);
  31176. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  31177. get applyFog(): boolean;
  31178. set applyFog(value: boolean);
  31179. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  31180. useOctreeForRenderingSelection: boolean;
  31181. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  31182. useOctreeForPicking: boolean;
  31183. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  31184. useOctreeForCollisions: boolean;
  31185. /**
  31186. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  31187. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  31188. */
  31189. get layerMask(): number;
  31190. set layerMask(value: number);
  31191. /**
  31192. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  31193. */
  31194. alwaysSelectAsActiveMesh: boolean;
  31195. /**
  31196. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  31197. */
  31198. doNotSyncBoundingInfo: boolean;
  31199. /**
  31200. * Gets or sets the current action manager
  31201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31202. */
  31203. actionManager: Nullable<AbstractActionManager>;
  31204. private _meshCollisionData;
  31205. /**
  31206. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  31207. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31208. */
  31209. ellipsoid: Vector3;
  31210. /**
  31211. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  31212. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31213. */
  31214. ellipsoidOffset: Vector3;
  31215. /**
  31216. * Gets or sets a collision mask used to mask collisions (default is -1).
  31217. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31218. */
  31219. get collisionMask(): number;
  31220. set collisionMask(mask: number);
  31221. /**
  31222. * Gets or sets the current collision group mask (-1 by default).
  31223. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31224. */
  31225. get collisionGroup(): number;
  31226. set collisionGroup(mask: number);
  31227. /**
  31228. * Gets or sets current surrounding meshes (null by default).
  31229. *
  31230. * By default collision detection is tested against every mesh in the scene.
  31231. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  31232. * meshes will be tested for the collision.
  31233. *
  31234. * Note: if set to an empty array no collision will happen when this mesh is moved.
  31235. */
  31236. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  31237. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  31238. /**
  31239. * Defines edge width used when edgesRenderer is enabled
  31240. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31241. */
  31242. edgesWidth: number;
  31243. /**
  31244. * Defines edge color used when edgesRenderer is enabled
  31245. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31246. */
  31247. edgesColor: Color4;
  31248. /** @hidden */
  31249. _edgesRenderer: Nullable<IEdgesRenderer>;
  31250. /** @hidden */
  31251. _masterMesh: Nullable<AbstractMesh>;
  31252. /** @hidden */
  31253. _boundingInfo: Nullable<BoundingInfo>;
  31254. /** @hidden */
  31255. _renderId: number;
  31256. /**
  31257. * Gets or sets the list of subMeshes
  31258. * @see http://doc.babylonjs.com/how_to/multi_materials
  31259. */
  31260. subMeshes: SubMesh[];
  31261. /** @hidden */
  31262. _intersectionsInProgress: AbstractMesh[];
  31263. /** @hidden */
  31264. _unIndexed: boolean;
  31265. /** @hidden */
  31266. _lightSources: Light[];
  31267. /** Gets the list of lights affecting that mesh */
  31268. get lightSources(): Light[];
  31269. /** @hidden */
  31270. get _positions(): Nullable<Vector3[]>;
  31271. /** @hidden */
  31272. _waitingData: {
  31273. lods: Nullable<any>;
  31274. actions: Nullable<any>;
  31275. freezeWorldMatrix: Nullable<boolean>;
  31276. };
  31277. /** @hidden */
  31278. _bonesTransformMatrices: Nullable<Float32Array>;
  31279. /** @hidden */
  31280. _transformMatrixTexture: Nullable<RawTexture>;
  31281. /**
  31282. * Gets or sets a skeleton to apply skining transformations
  31283. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  31284. */
  31285. set skeleton(value: Nullable<Skeleton>);
  31286. get skeleton(): Nullable<Skeleton>;
  31287. /**
  31288. * An event triggered when the mesh is rebuilt.
  31289. */
  31290. onRebuildObservable: Observable<AbstractMesh>;
  31291. /**
  31292. * Creates a new AbstractMesh
  31293. * @param name defines the name of the mesh
  31294. * @param scene defines the hosting scene
  31295. */
  31296. constructor(name: string, scene?: Nullable<Scene>);
  31297. /**
  31298. * Returns the string "AbstractMesh"
  31299. * @returns "AbstractMesh"
  31300. */
  31301. getClassName(): string;
  31302. /**
  31303. * Gets a string representation of the current mesh
  31304. * @param fullDetails defines a boolean indicating if full details must be included
  31305. * @returns a string representation of the current mesh
  31306. */
  31307. toString(fullDetails?: boolean): string;
  31308. /**
  31309. * @hidden
  31310. */
  31311. protected _getEffectiveParent(): Nullable<Node>;
  31312. /** @hidden */
  31313. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  31314. /** @hidden */
  31315. _rebuild(): void;
  31316. /** @hidden */
  31317. _resyncLightSources(): void;
  31318. /** @hidden */
  31319. _resyncLightSource(light: Light): void;
  31320. /** @hidden */
  31321. _unBindEffect(): void;
  31322. /** @hidden */
  31323. _removeLightSource(light: Light, dispose: boolean): void;
  31324. private _markSubMeshesAsDirty;
  31325. /** @hidden */
  31326. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  31327. /** @hidden */
  31328. _markSubMeshesAsAttributesDirty(): void;
  31329. /** @hidden */
  31330. _markSubMeshesAsMiscDirty(): void;
  31331. /**
  31332. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  31333. */
  31334. get scaling(): Vector3;
  31335. set scaling(newScaling: Vector3);
  31336. /**
  31337. * Returns true if the mesh is blocked. Implemented by child classes
  31338. */
  31339. get isBlocked(): boolean;
  31340. /**
  31341. * Returns the mesh itself by default. Implemented by child classes
  31342. * @param camera defines the camera to use to pick the right LOD level
  31343. * @returns the currentAbstractMesh
  31344. */
  31345. getLOD(camera: Camera): Nullable<AbstractMesh>;
  31346. /**
  31347. * Returns 0 by default. Implemented by child classes
  31348. * @returns an integer
  31349. */
  31350. getTotalVertices(): number;
  31351. /**
  31352. * Returns a positive integer : the total number of indices in this mesh geometry.
  31353. * @returns the numner of indices or zero if the mesh has no geometry.
  31354. */
  31355. getTotalIndices(): number;
  31356. /**
  31357. * Returns null by default. Implemented by child classes
  31358. * @returns null
  31359. */
  31360. getIndices(): Nullable<IndicesArray>;
  31361. /**
  31362. * Returns the array of the requested vertex data kind. Implemented by child classes
  31363. * @param kind defines the vertex data kind to use
  31364. * @returns null
  31365. */
  31366. getVerticesData(kind: string): Nullable<FloatArray>;
  31367. /**
  31368. * Sets the vertex data of the mesh geometry for the requested `kind`.
  31369. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  31370. * Note that a new underlying VertexBuffer object is created each call.
  31371. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  31372. * @param kind defines vertex data kind:
  31373. * * VertexBuffer.PositionKind
  31374. * * VertexBuffer.UVKind
  31375. * * VertexBuffer.UV2Kind
  31376. * * VertexBuffer.UV3Kind
  31377. * * VertexBuffer.UV4Kind
  31378. * * VertexBuffer.UV5Kind
  31379. * * VertexBuffer.UV6Kind
  31380. * * VertexBuffer.ColorKind
  31381. * * VertexBuffer.MatricesIndicesKind
  31382. * * VertexBuffer.MatricesIndicesExtraKind
  31383. * * VertexBuffer.MatricesWeightsKind
  31384. * * VertexBuffer.MatricesWeightsExtraKind
  31385. * @param data defines the data source
  31386. * @param updatable defines if the data must be flagged as updatable (or static)
  31387. * @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
  31388. * @returns the current mesh
  31389. */
  31390. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  31391. /**
  31392. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  31393. * If the mesh has no geometry, it is simply returned as it is.
  31394. * @param kind defines vertex data kind:
  31395. * * VertexBuffer.PositionKind
  31396. * * VertexBuffer.UVKind
  31397. * * VertexBuffer.UV2Kind
  31398. * * VertexBuffer.UV3Kind
  31399. * * VertexBuffer.UV4Kind
  31400. * * VertexBuffer.UV5Kind
  31401. * * VertexBuffer.UV6Kind
  31402. * * VertexBuffer.ColorKind
  31403. * * VertexBuffer.MatricesIndicesKind
  31404. * * VertexBuffer.MatricesIndicesExtraKind
  31405. * * VertexBuffer.MatricesWeightsKind
  31406. * * VertexBuffer.MatricesWeightsExtraKind
  31407. * @param data defines the data source
  31408. * @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
  31409. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  31410. * @returns the current mesh
  31411. */
  31412. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  31413. /**
  31414. * Sets the mesh indices,
  31415. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  31416. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  31417. * @param totalVertices Defines the total number of vertices
  31418. * @returns the current mesh
  31419. */
  31420. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  31421. /**
  31422. * Gets a boolean indicating if specific vertex data is present
  31423. * @param kind defines the vertex data kind to use
  31424. * @returns true is data kind is present
  31425. */
  31426. isVerticesDataPresent(kind: string): boolean;
  31427. /**
  31428. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  31429. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  31430. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  31431. * @returns a BoundingInfo
  31432. */
  31433. getBoundingInfo(): BoundingInfo;
  31434. /**
  31435. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  31436. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  31437. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  31438. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  31439. * @returns the current mesh
  31440. */
  31441. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  31442. /**
  31443. * Overwrite the current bounding info
  31444. * @param boundingInfo defines the new bounding info
  31445. * @returns the current mesh
  31446. */
  31447. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  31448. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  31449. get useBones(): boolean;
  31450. /** @hidden */
  31451. _preActivate(): void;
  31452. /** @hidden */
  31453. _preActivateForIntermediateRendering(renderId: number): void;
  31454. /** @hidden */
  31455. _activate(renderId: number, intermediateRendering: boolean): boolean;
  31456. /** @hidden */
  31457. _postActivate(): void;
  31458. /** @hidden */
  31459. _freeze(): void;
  31460. /** @hidden */
  31461. _unFreeze(): void;
  31462. /**
  31463. * Gets the current world matrix
  31464. * @returns a Matrix
  31465. */
  31466. getWorldMatrix(): Matrix;
  31467. /** @hidden */
  31468. _getWorldMatrixDeterminant(): number;
  31469. /**
  31470. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  31471. */
  31472. get isAnInstance(): boolean;
  31473. /**
  31474. * Gets a boolean indicating if this mesh has instances
  31475. */
  31476. get hasInstances(): boolean;
  31477. /**
  31478. * Gets a boolean indicating if this mesh has thin instances
  31479. */
  31480. get hasThinInstances(): boolean;
  31481. /**
  31482. * Perform relative position change from the point of view of behind the front of the mesh.
  31483. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31484. * Supports definition of mesh facing forward or backward
  31485. * @param amountRight defines the distance on the right axis
  31486. * @param amountUp defines the distance on the up axis
  31487. * @param amountForward defines the distance on the forward axis
  31488. * @returns the current mesh
  31489. */
  31490. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  31491. /**
  31492. * Calculate relative position change from the point of view of behind the front of the mesh.
  31493. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31494. * Supports definition of mesh facing forward or backward
  31495. * @param amountRight defines the distance on the right axis
  31496. * @param amountUp defines the distance on the up axis
  31497. * @param amountForward defines the distance on the forward axis
  31498. * @returns the new displacement vector
  31499. */
  31500. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  31501. /**
  31502. * Perform relative rotation change from the point of view of behind the front of the mesh.
  31503. * Supports definition of mesh facing forward or backward
  31504. * @param flipBack defines the flip
  31505. * @param twirlClockwise defines the twirl
  31506. * @param tiltRight defines the tilt
  31507. * @returns the current mesh
  31508. */
  31509. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  31510. /**
  31511. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  31512. * Supports definition of mesh facing forward or backward.
  31513. * @param flipBack defines the flip
  31514. * @param twirlClockwise defines the twirl
  31515. * @param tiltRight defines the tilt
  31516. * @returns the new rotation vector
  31517. */
  31518. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  31519. /**
  31520. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  31521. * This means the mesh underlying bounding box and sphere are recomputed.
  31522. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  31523. * @returns the current mesh
  31524. */
  31525. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  31526. /** @hidden */
  31527. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  31528. /** @hidden */
  31529. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  31530. /** @hidden */
  31531. _updateBoundingInfo(): AbstractMesh;
  31532. /** @hidden */
  31533. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  31534. /** @hidden */
  31535. protected _afterComputeWorldMatrix(): void;
  31536. /** @hidden */
  31537. get _effectiveMesh(): AbstractMesh;
  31538. /**
  31539. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  31540. * A mesh is in the frustum if its bounding box intersects the frustum
  31541. * @param frustumPlanes defines the frustum to test
  31542. * @returns true if the mesh is in the frustum planes
  31543. */
  31544. isInFrustum(frustumPlanes: Plane[]): boolean;
  31545. /**
  31546. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  31547. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  31548. * @param frustumPlanes defines the frustum to test
  31549. * @returns true if the mesh is completely in the frustum planes
  31550. */
  31551. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  31552. /**
  31553. * True if the mesh intersects another mesh or a SolidParticle object
  31554. * @param mesh defines a target mesh or SolidParticle to test
  31555. * @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)
  31556. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  31557. * @returns true if there is an intersection
  31558. */
  31559. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  31560. /**
  31561. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  31562. * @param point defines the point to test
  31563. * @returns true if there is an intersection
  31564. */
  31565. intersectsPoint(point: Vector3): boolean;
  31566. /**
  31567. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  31568. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31569. */
  31570. get checkCollisions(): boolean;
  31571. set checkCollisions(collisionEnabled: boolean);
  31572. /**
  31573. * Gets Collider object used to compute collisions (not physics)
  31574. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31575. */
  31576. get collider(): Nullable<Collider>;
  31577. /**
  31578. * Move the mesh using collision engine
  31579. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31580. * @param displacement defines the requested displacement vector
  31581. * @returns the current mesh
  31582. */
  31583. moveWithCollisions(displacement: Vector3): AbstractMesh;
  31584. private _onCollisionPositionChange;
  31585. /** @hidden */
  31586. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  31587. /** @hidden */
  31588. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  31589. /** @hidden */
  31590. _checkCollision(collider: Collider): AbstractMesh;
  31591. /** @hidden */
  31592. _generatePointsArray(): boolean;
  31593. /**
  31594. * Checks if the passed Ray intersects with the mesh
  31595. * @param ray defines the ray to use
  31596. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  31597. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31598. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  31599. * @returns the picking info
  31600. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  31601. */
  31602. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  31603. /**
  31604. * Clones the current mesh
  31605. * @param name defines the mesh name
  31606. * @param newParent defines the new mesh parent
  31607. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  31608. * @returns the new mesh
  31609. */
  31610. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  31611. /**
  31612. * Disposes all the submeshes of the current meshnp
  31613. * @returns the current mesh
  31614. */
  31615. releaseSubMeshes(): AbstractMesh;
  31616. /**
  31617. * Releases resources associated with this abstract mesh.
  31618. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31619. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31620. */
  31621. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31622. /**
  31623. * Adds the passed mesh as a child to the current mesh
  31624. * @param mesh defines the child mesh
  31625. * @returns the current mesh
  31626. */
  31627. addChild(mesh: AbstractMesh): AbstractMesh;
  31628. /**
  31629. * Removes the passed mesh from the current mesh children list
  31630. * @param mesh defines the child mesh
  31631. * @returns the current mesh
  31632. */
  31633. removeChild(mesh: AbstractMesh): AbstractMesh;
  31634. /** @hidden */
  31635. private _initFacetData;
  31636. /**
  31637. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  31638. * This method can be called within the render loop.
  31639. * 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
  31640. * @returns the current mesh
  31641. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31642. */
  31643. updateFacetData(): AbstractMesh;
  31644. /**
  31645. * Returns the facetLocalNormals array.
  31646. * The normals are expressed in the mesh local spac
  31647. * @returns an array of Vector3
  31648. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31649. */
  31650. getFacetLocalNormals(): Vector3[];
  31651. /**
  31652. * Returns the facetLocalPositions array.
  31653. * The facet positions are expressed in the mesh local space
  31654. * @returns an array of Vector3
  31655. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31656. */
  31657. getFacetLocalPositions(): Vector3[];
  31658. /**
  31659. * Returns the facetLocalPartioning array
  31660. * @returns an array of array of numbers
  31661. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31662. */
  31663. getFacetLocalPartitioning(): number[][];
  31664. /**
  31665. * Returns the i-th facet position in the world system.
  31666. * This method allocates a new Vector3 per call
  31667. * @param i defines the facet index
  31668. * @returns a new Vector3
  31669. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31670. */
  31671. getFacetPosition(i: number): Vector3;
  31672. /**
  31673. * Sets the reference Vector3 with the i-th facet position in the world system
  31674. * @param i defines the facet index
  31675. * @param ref defines the target vector
  31676. * @returns the current mesh
  31677. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31678. */
  31679. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  31680. /**
  31681. * Returns the i-th facet normal in the world system.
  31682. * This method allocates a new Vector3 per call
  31683. * @param i defines the facet index
  31684. * @returns a new Vector3
  31685. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31686. */
  31687. getFacetNormal(i: number): Vector3;
  31688. /**
  31689. * Sets the reference Vector3 with the i-th facet normal in the world system
  31690. * @param i defines the facet index
  31691. * @param ref defines the target vector
  31692. * @returns the current mesh
  31693. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31694. */
  31695. getFacetNormalToRef(i: number, ref: Vector3): this;
  31696. /**
  31697. * 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)
  31698. * @param x defines x coordinate
  31699. * @param y defines y coordinate
  31700. * @param z defines z coordinate
  31701. * @returns the array of facet indexes
  31702. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31703. */
  31704. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  31705. /**
  31706. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  31707. * @param projected sets as the (x,y,z) world projection on the facet
  31708. * @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
  31709. * @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
  31710. * @param x defines x coordinate
  31711. * @param y defines y coordinate
  31712. * @param z defines z coordinate
  31713. * @returns the face index if found (or null instead)
  31714. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31715. */
  31716. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31717. /**
  31718. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  31719. * @param projected sets as the (x,y,z) local projection on the facet
  31720. * @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
  31721. * @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
  31722. * @param x defines x coordinate
  31723. * @param y defines y coordinate
  31724. * @param z defines z coordinate
  31725. * @returns the face index if found (or null instead)
  31726. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31727. */
  31728. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31729. /**
  31730. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  31731. * @returns the parameters
  31732. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31733. */
  31734. getFacetDataParameters(): any;
  31735. /**
  31736. * Disables the feature FacetData and frees the related memory
  31737. * @returns the current mesh
  31738. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31739. */
  31740. disableFacetData(): AbstractMesh;
  31741. /**
  31742. * Updates the AbstractMesh indices array
  31743. * @param indices defines the data source
  31744. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  31745. * @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)
  31746. * @returns the current mesh
  31747. */
  31748. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  31749. /**
  31750. * Creates new normals data for the mesh
  31751. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  31752. * @returns the current mesh
  31753. */
  31754. createNormals(updatable: boolean): AbstractMesh;
  31755. /**
  31756. * Align the mesh with a normal
  31757. * @param normal defines the normal to use
  31758. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  31759. * @returns the current mesh
  31760. */
  31761. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  31762. /** @hidden */
  31763. _checkOcclusionQuery(): boolean;
  31764. /**
  31765. * Disables the mesh edge rendering mode
  31766. * @returns the currentAbstractMesh
  31767. */
  31768. disableEdgesRendering(): AbstractMesh;
  31769. /**
  31770. * Enables the edge rendering mode on the mesh.
  31771. * This mode makes the mesh edges visible
  31772. * @param epsilon defines the maximal distance between two angles to detect a face
  31773. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  31774. * @returns the currentAbstractMesh
  31775. * @see https://www.babylonjs-playground.com/#19O9TU#0
  31776. */
  31777. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  31778. /**
  31779. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  31780. * @returns an array of particle systems in the scene that use the mesh as an emitter
  31781. */
  31782. getConnectedParticleSystems(): IParticleSystem[];
  31783. }
  31784. }
  31785. declare module BABYLON {
  31786. /**
  31787. * Interface used to define ActionEvent
  31788. */
  31789. export interface IActionEvent {
  31790. /** The mesh or sprite that triggered the action */
  31791. source: any;
  31792. /** The X mouse cursor position at the time of the event */
  31793. pointerX: number;
  31794. /** The Y mouse cursor position at the time of the event */
  31795. pointerY: number;
  31796. /** The mesh that is currently pointed at (can be null) */
  31797. meshUnderPointer: Nullable<AbstractMesh>;
  31798. /** the original (browser) event that triggered the ActionEvent */
  31799. sourceEvent?: any;
  31800. /** additional data for the event */
  31801. additionalData?: any;
  31802. }
  31803. /**
  31804. * ActionEvent is the event being sent when an action is triggered.
  31805. */
  31806. export class ActionEvent implements IActionEvent {
  31807. /** The mesh or sprite that triggered the action */
  31808. source: any;
  31809. /** The X mouse cursor position at the time of the event */
  31810. pointerX: number;
  31811. /** The Y mouse cursor position at the time of the event */
  31812. pointerY: number;
  31813. /** The mesh that is currently pointed at (can be null) */
  31814. meshUnderPointer: Nullable<AbstractMesh>;
  31815. /** the original (browser) event that triggered the ActionEvent */
  31816. sourceEvent?: any;
  31817. /** additional data for the event */
  31818. additionalData?: any;
  31819. /**
  31820. * Creates a new ActionEvent
  31821. * @param source The mesh or sprite that triggered the action
  31822. * @param pointerX The X mouse cursor position at the time of the event
  31823. * @param pointerY The Y mouse cursor position at the time of the event
  31824. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  31825. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  31826. * @param additionalData additional data for the event
  31827. */
  31828. constructor(
  31829. /** The mesh or sprite that triggered the action */
  31830. source: any,
  31831. /** The X mouse cursor position at the time of the event */
  31832. pointerX: number,
  31833. /** The Y mouse cursor position at the time of the event */
  31834. pointerY: number,
  31835. /** The mesh that is currently pointed at (can be null) */
  31836. meshUnderPointer: Nullable<AbstractMesh>,
  31837. /** the original (browser) event that triggered the ActionEvent */
  31838. sourceEvent?: any,
  31839. /** additional data for the event */
  31840. additionalData?: any);
  31841. /**
  31842. * Helper function to auto-create an ActionEvent from a source mesh.
  31843. * @param source The source mesh that triggered the event
  31844. * @param evt The original (browser) event
  31845. * @param additionalData additional data for the event
  31846. * @returns the new ActionEvent
  31847. */
  31848. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  31849. /**
  31850. * Helper function to auto-create an ActionEvent from a source sprite
  31851. * @param source The source sprite that triggered the event
  31852. * @param scene Scene associated with the sprite
  31853. * @param evt The original (browser) event
  31854. * @param additionalData additional data for the event
  31855. * @returns the new ActionEvent
  31856. */
  31857. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  31858. /**
  31859. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  31860. * @param scene the scene where the event occurred
  31861. * @param evt The original (browser) event
  31862. * @returns the new ActionEvent
  31863. */
  31864. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  31865. /**
  31866. * Helper function to auto-create an ActionEvent from a primitive
  31867. * @param prim defines the target primitive
  31868. * @param pointerPos defines the pointer position
  31869. * @param evt The original (browser) event
  31870. * @param additionalData additional data for the event
  31871. * @returns the new ActionEvent
  31872. */
  31873. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  31874. }
  31875. }
  31876. declare module BABYLON {
  31877. /**
  31878. * Abstract class used to decouple action Manager from scene and meshes.
  31879. * Do not instantiate.
  31880. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31881. */
  31882. export abstract class AbstractActionManager implements IDisposable {
  31883. /** Gets the list of active triggers */
  31884. static Triggers: {
  31885. [key: string]: number;
  31886. };
  31887. /** Gets the cursor to use when hovering items */
  31888. hoverCursor: string;
  31889. /** Gets the list of actions */
  31890. actions: IAction[];
  31891. /**
  31892. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  31893. */
  31894. isRecursive: boolean;
  31895. /**
  31896. * Releases all associated resources
  31897. */
  31898. abstract dispose(): void;
  31899. /**
  31900. * Does this action manager has pointer triggers
  31901. */
  31902. abstract get hasPointerTriggers(): boolean;
  31903. /**
  31904. * Does this action manager has pick triggers
  31905. */
  31906. abstract get hasPickTriggers(): boolean;
  31907. /**
  31908. * Process a specific trigger
  31909. * @param trigger defines the trigger to process
  31910. * @param evt defines the event details to be processed
  31911. */
  31912. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  31913. /**
  31914. * Does this action manager handles actions of any of the given triggers
  31915. * @param triggers defines the triggers to be tested
  31916. * @return a boolean indicating whether one (or more) of the triggers is handled
  31917. */
  31918. abstract hasSpecificTriggers(triggers: number[]): boolean;
  31919. /**
  31920. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  31921. * speed.
  31922. * @param triggerA defines the trigger to be tested
  31923. * @param triggerB defines the trigger to be tested
  31924. * @return a boolean indicating whether one (or more) of the triggers is handled
  31925. */
  31926. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  31927. /**
  31928. * Does this action manager handles actions of a given trigger
  31929. * @param trigger defines the trigger to be tested
  31930. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  31931. * @return whether the trigger is handled
  31932. */
  31933. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  31934. /**
  31935. * Serialize this manager to a JSON object
  31936. * @param name defines the property name to store this manager
  31937. * @returns a JSON representation of this manager
  31938. */
  31939. abstract serialize(name: string): any;
  31940. /**
  31941. * Registers an action to this action manager
  31942. * @param action defines the action to be registered
  31943. * @return the action amended (prepared) after registration
  31944. */
  31945. abstract registerAction(action: IAction): Nullable<IAction>;
  31946. /**
  31947. * Unregisters an action to this action manager
  31948. * @param action defines the action to be unregistered
  31949. * @return a boolean indicating whether the action has been unregistered
  31950. */
  31951. abstract unregisterAction(action: IAction): Boolean;
  31952. /**
  31953. * Does exist one action manager with at least one trigger
  31954. **/
  31955. static get HasTriggers(): boolean;
  31956. /**
  31957. * Does exist one action manager with at least one pick trigger
  31958. **/
  31959. static get HasPickTriggers(): boolean;
  31960. /**
  31961. * Does exist one action manager that handles actions of a given trigger
  31962. * @param trigger defines the trigger to be tested
  31963. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  31964. **/
  31965. static HasSpecificTrigger(trigger: number): boolean;
  31966. }
  31967. }
  31968. declare module BABYLON {
  31969. /**
  31970. * Defines how a node can be built from a string name.
  31971. */
  31972. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  31973. /**
  31974. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  31975. */
  31976. export class Node implements IBehaviorAware<Node> {
  31977. /** @hidden */
  31978. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  31979. private static _NodeConstructors;
  31980. /**
  31981. * Add a new node constructor
  31982. * @param type defines the type name of the node to construct
  31983. * @param constructorFunc defines the constructor function
  31984. */
  31985. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  31986. /**
  31987. * Returns a node constructor based on type name
  31988. * @param type defines the type name
  31989. * @param name defines the new node name
  31990. * @param scene defines the hosting scene
  31991. * @param options defines optional options to transmit to constructors
  31992. * @returns the new constructor or null
  31993. */
  31994. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  31995. /**
  31996. * Gets or sets the name of the node
  31997. */
  31998. name: string;
  31999. /**
  32000. * Gets or sets the id of the node
  32001. */
  32002. id: string;
  32003. /**
  32004. * Gets or sets the unique id of the node
  32005. */
  32006. uniqueId: number;
  32007. /**
  32008. * Gets or sets a string used to store user defined state for the node
  32009. */
  32010. state: string;
  32011. /**
  32012. * Gets or sets an object used to store user defined information for the node
  32013. */
  32014. metadata: any;
  32015. /**
  32016. * For internal use only. Please do not use.
  32017. */
  32018. reservedDataStore: any;
  32019. /**
  32020. * List of inspectable custom properties (used by the Inspector)
  32021. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  32022. */
  32023. inspectableCustomProperties: IInspectable[];
  32024. private _doNotSerialize;
  32025. /**
  32026. * Gets or sets a boolean used to define if the node must be serialized
  32027. */
  32028. get doNotSerialize(): boolean;
  32029. set doNotSerialize(value: boolean);
  32030. /** @hidden */
  32031. _isDisposed: boolean;
  32032. /**
  32033. * Gets a list of Animations associated with the node
  32034. */
  32035. animations: Animation[];
  32036. protected _ranges: {
  32037. [name: string]: Nullable<AnimationRange>;
  32038. };
  32039. /**
  32040. * Callback raised when the node is ready to be used
  32041. */
  32042. onReady: Nullable<(node: Node) => void>;
  32043. private _isEnabled;
  32044. private _isParentEnabled;
  32045. private _isReady;
  32046. /** @hidden */
  32047. _currentRenderId: number;
  32048. private _parentUpdateId;
  32049. /** @hidden */
  32050. _childUpdateId: number;
  32051. /** @hidden */
  32052. _waitingParentId: Nullable<string>;
  32053. /** @hidden */
  32054. _scene: Scene;
  32055. /** @hidden */
  32056. _cache: any;
  32057. private _parentNode;
  32058. private _children;
  32059. /** @hidden */
  32060. _worldMatrix: Matrix;
  32061. /** @hidden */
  32062. _worldMatrixDeterminant: number;
  32063. /** @hidden */
  32064. _worldMatrixDeterminantIsDirty: boolean;
  32065. /** @hidden */
  32066. private _sceneRootNodesIndex;
  32067. /**
  32068. * Gets a boolean indicating if the node has been disposed
  32069. * @returns true if the node was disposed
  32070. */
  32071. isDisposed(): boolean;
  32072. /**
  32073. * Gets or sets the parent of the node (without keeping the current position in the scene)
  32074. * @see https://doc.babylonjs.com/how_to/parenting
  32075. */
  32076. set parent(parent: Nullable<Node>);
  32077. get parent(): Nullable<Node>;
  32078. /** @hidden */
  32079. _addToSceneRootNodes(): void;
  32080. /** @hidden */
  32081. _removeFromSceneRootNodes(): void;
  32082. private _animationPropertiesOverride;
  32083. /**
  32084. * Gets or sets the animation properties override
  32085. */
  32086. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  32087. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  32088. /**
  32089. * Gets a string idenfifying the name of the class
  32090. * @returns "Node" string
  32091. */
  32092. getClassName(): string;
  32093. /** @hidden */
  32094. readonly _isNode: boolean;
  32095. /**
  32096. * An event triggered when the mesh is disposed
  32097. */
  32098. onDisposeObservable: Observable<Node>;
  32099. private _onDisposeObserver;
  32100. /**
  32101. * Sets a callback that will be raised when the node will be disposed
  32102. */
  32103. set onDispose(callback: () => void);
  32104. /**
  32105. * Creates a new Node
  32106. * @param name the name and id to be given to this node
  32107. * @param scene the scene this node will be added to
  32108. */
  32109. constructor(name: string, scene?: Nullable<Scene>);
  32110. /**
  32111. * Gets the scene of the node
  32112. * @returns a scene
  32113. */
  32114. getScene(): Scene;
  32115. /**
  32116. * Gets the engine of the node
  32117. * @returns a Engine
  32118. */
  32119. getEngine(): Engine;
  32120. private _behaviors;
  32121. /**
  32122. * Attach a behavior to the node
  32123. * @see http://doc.babylonjs.com/features/behaviour
  32124. * @param behavior defines the behavior to attach
  32125. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  32126. * @returns the current Node
  32127. */
  32128. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  32129. /**
  32130. * Remove an attached behavior
  32131. * @see http://doc.babylonjs.com/features/behaviour
  32132. * @param behavior defines the behavior to attach
  32133. * @returns the current Node
  32134. */
  32135. removeBehavior(behavior: Behavior<Node>): Node;
  32136. /**
  32137. * Gets the list of attached behaviors
  32138. * @see http://doc.babylonjs.com/features/behaviour
  32139. */
  32140. get behaviors(): Behavior<Node>[];
  32141. /**
  32142. * Gets an attached behavior by name
  32143. * @param name defines the name of the behavior to look for
  32144. * @see http://doc.babylonjs.com/features/behaviour
  32145. * @returns null if behavior was not found else the requested behavior
  32146. */
  32147. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  32148. /**
  32149. * Returns the latest update of the World matrix
  32150. * @returns a Matrix
  32151. */
  32152. getWorldMatrix(): Matrix;
  32153. /** @hidden */
  32154. _getWorldMatrixDeterminant(): number;
  32155. /**
  32156. * Returns directly the latest state of the mesh World matrix.
  32157. * A Matrix is returned.
  32158. */
  32159. get worldMatrixFromCache(): Matrix;
  32160. /** @hidden */
  32161. _initCache(): void;
  32162. /** @hidden */
  32163. updateCache(force?: boolean): void;
  32164. /** @hidden */
  32165. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32166. /** @hidden */
  32167. _updateCache(ignoreParentClass?: boolean): void;
  32168. /** @hidden */
  32169. _isSynchronized(): boolean;
  32170. /** @hidden */
  32171. _markSyncedWithParent(): void;
  32172. /** @hidden */
  32173. isSynchronizedWithParent(): boolean;
  32174. /** @hidden */
  32175. isSynchronized(): boolean;
  32176. /**
  32177. * Is this node ready to be used/rendered
  32178. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  32179. * @return true if the node is ready
  32180. */
  32181. isReady(completeCheck?: boolean): boolean;
  32182. /**
  32183. * Is this node enabled?
  32184. * 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
  32185. * @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
  32186. * @return whether this node (and its parent) is enabled
  32187. */
  32188. isEnabled(checkAncestors?: boolean): boolean;
  32189. /** @hidden */
  32190. protected _syncParentEnabledState(): void;
  32191. /**
  32192. * Set the enabled state of this node
  32193. * @param value defines the new enabled state
  32194. */
  32195. setEnabled(value: boolean): void;
  32196. /**
  32197. * Is this node a descendant of the given node?
  32198. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  32199. * @param ancestor defines the parent node to inspect
  32200. * @returns a boolean indicating if this node is a descendant of the given node
  32201. */
  32202. isDescendantOf(ancestor: Node): boolean;
  32203. /** @hidden */
  32204. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  32205. /**
  32206. * Will return all nodes that have this node as ascendant
  32207. * @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
  32208. * @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
  32209. * @return all children nodes of all types
  32210. */
  32211. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  32212. /**
  32213. * Get all child-meshes of this node
  32214. * @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)
  32215. * @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
  32216. * @returns an array of AbstractMesh
  32217. */
  32218. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  32219. /**
  32220. * Get all direct children of this node
  32221. * @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
  32222. * @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)
  32223. * @returns an array of Node
  32224. */
  32225. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  32226. /** @hidden */
  32227. _setReady(state: boolean): void;
  32228. /**
  32229. * Get an animation by name
  32230. * @param name defines the name of the animation to look for
  32231. * @returns null if not found else the requested animation
  32232. */
  32233. getAnimationByName(name: string): Nullable<Animation>;
  32234. /**
  32235. * Creates an animation range for this node
  32236. * @param name defines the name of the range
  32237. * @param from defines the starting key
  32238. * @param to defines the end key
  32239. */
  32240. createAnimationRange(name: string, from: number, to: number): void;
  32241. /**
  32242. * Delete a specific animation range
  32243. * @param name defines the name of the range to delete
  32244. * @param deleteFrames defines if animation frames from the range must be deleted as well
  32245. */
  32246. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  32247. /**
  32248. * Get an animation range by name
  32249. * @param name defines the name of the animation range to look for
  32250. * @returns null if not found else the requested animation range
  32251. */
  32252. getAnimationRange(name: string): Nullable<AnimationRange>;
  32253. /**
  32254. * Gets the list of all animation ranges defined on this node
  32255. * @returns an array
  32256. */
  32257. getAnimationRanges(): Nullable<AnimationRange>[];
  32258. /**
  32259. * Will start the animation sequence
  32260. * @param name defines the range frames for animation sequence
  32261. * @param loop defines if the animation should loop (false by default)
  32262. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  32263. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  32264. * @returns the object created for this animation. If range does not exist, it will return null
  32265. */
  32266. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  32267. /**
  32268. * Serialize animation ranges into a JSON compatible object
  32269. * @returns serialization object
  32270. */
  32271. serializeAnimationRanges(): any;
  32272. /**
  32273. * Computes the world matrix of the node
  32274. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  32275. * @returns the world matrix
  32276. */
  32277. computeWorldMatrix(force?: boolean): Matrix;
  32278. /**
  32279. * Releases resources associated with this node.
  32280. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32281. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32282. */
  32283. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32284. /**
  32285. * Parse animation range data from a serialization object and store them into a given node
  32286. * @param node defines where to store the animation ranges
  32287. * @param parsedNode defines the serialization object to read data from
  32288. * @param scene defines the hosting scene
  32289. */
  32290. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  32291. /**
  32292. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  32293. * @param includeDescendants Include bounding info from descendants as well (true by default)
  32294. * @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
  32295. * @returns the new bounding vectors
  32296. */
  32297. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  32298. min: Vector3;
  32299. max: Vector3;
  32300. };
  32301. }
  32302. }
  32303. declare module BABYLON {
  32304. /**
  32305. * @hidden
  32306. */
  32307. export class _IAnimationState {
  32308. key: number;
  32309. repeatCount: number;
  32310. workValue?: any;
  32311. loopMode?: number;
  32312. offsetValue?: any;
  32313. highLimitValue?: any;
  32314. }
  32315. /**
  32316. * Class used to store any kind of animation
  32317. */
  32318. export class Animation {
  32319. /**Name of the animation */
  32320. name: string;
  32321. /**Property to animate */
  32322. targetProperty: string;
  32323. /**The frames per second of the animation */
  32324. framePerSecond: number;
  32325. /**The data type of the animation */
  32326. dataType: number;
  32327. /**The loop mode of the animation */
  32328. loopMode?: number | undefined;
  32329. /**Specifies if blending should be enabled */
  32330. enableBlending?: boolean | undefined;
  32331. /**
  32332. * Use matrix interpolation instead of using direct key value when animating matrices
  32333. */
  32334. static AllowMatricesInterpolation: boolean;
  32335. /**
  32336. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  32337. */
  32338. static AllowMatrixDecomposeForInterpolation: boolean;
  32339. /** Define the Url to load snippets */
  32340. static SnippetUrl: string;
  32341. /** Snippet ID if the animation was created from the snippet server */
  32342. snippetId: string;
  32343. /**
  32344. * Stores the key frames of the animation
  32345. */
  32346. private _keys;
  32347. /**
  32348. * Stores the easing function of the animation
  32349. */
  32350. private _easingFunction;
  32351. /**
  32352. * @hidden Internal use only
  32353. */
  32354. _runtimeAnimations: RuntimeAnimation[];
  32355. /**
  32356. * The set of event that will be linked to this animation
  32357. */
  32358. private _events;
  32359. /**
  32360. * Stores an array of target property paths
  32361. */
  32362. targetPropertyPath: string[];
  32363. /**
  32364. * Stores the blending speed of the animation
  32365. */
  32366. blendingSpeed: number;
  32367. /**
  32368. * Stores the animation ranges for the animation
  32369. */
  32370. private _ranges;
  32371. /**
  32372. * @hidden Internal use
  32373. */
  32374. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  32375. /**
  32376. * Sets up an animation
  32377. * @param property The property to animate
  32378. * @param animationType The animation type to apply
  32379. * @param framePerSecond The frames per second of the animation
  32380. * @param easingFunction The easing function used in the animation
  32381. * @returns The created animation
  32382. */
  32383. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  32384. /**
  32385. * Create and start an animation on a node
  32386. * @param name defines the name of the global animation that will be run on all nodes
  32387. * @param node defines the root node where the animation will take place
  32388. * @param targetProperty defines property to animate
  32389. * @param framePerSecond defines the number of frame per second yo use
  32390. * @param totalFrame defines the number of frames in total
  32391. * @param from defines the initial value
  32392. * @param to defines the final value
  32393. * @param loopMode defines which loop mode you want to use (off by default)
  32394. * @param easingFunction defines the easing function to use (linear by default)
  32395. * @param onAnimationEnd defines the callback to call when animation end
  32396. * @returns the animatable created for this animation
  32397. */
  32398. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32399. /**
  32400. * Create and start an animation on a node and its descendants
  32401. * @param name defines the name of the global animation that will be run on all nodes
  32402. * @param node defines the root node where the animation will take place
  32403. * @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
  32404. * @param targetProperty defines property to animate
  32405. * @param framePerSecond defines the number of frame per second to use
  32406. * @param totalFrame defines the number of frames in total
  32407. * @param from defines the initial value
  32408. * @param to defines the final value
  32409. * @param loopMode defines which loop mode you want to use (off by default)
  32410. * @param easingFunction defines the easing function to use (linear by default)
  32411. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  32412. * @returns the list of animatables created for all nodes
  32413. * @example https://www.babylonjs-playground.com/#MH0VLI
  32414. */
  32415. 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[]>;
  32416. /**
  32417. * Creates a new animation, merges it with the existing animations and starts it
  32418. * @param name Name of the animation
  32419. * @param node Node which contains the scene that begins the animations
  32420. * @param targetProperty Specifies which property to animate
  32421. * @param framePerSecond The frames per second of the animation
  32422. * @param totalFrame The total number of frames
  32423. * @param from The frame at the beginning of the animation
  32424. * @param to The frame at the end of the animation
  32425. * @param loopMode Specifies the loop mode of the animation
  32426. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  32427. * @param onAnimationEnd Callback to run once the animation is complete
  32428. * @returns Nullable animation
  32429. */
  32430. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32431. /**
  32432. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  32433. * @param sourceAnimation defines the Animation containing keyframes to convert
  32434. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  32435. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  32436. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  32437. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  32438. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  32439. */
  32440. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  32441. /**
  32442. * Transition property of an host to the target Value
  32443. * @param property The property to transition
  32444. * @param targetValue The target Value of the property
  32445. * @param host The object where the property to animate belongs
  32446. * @param scene Scene used to run the animation
  32447. * @param frameRate Framerate (in frame/s) to use
  32448. * @param transition The transition type we want to use
  32449. * @param duration The duration of the animation, in milliseconds
  32450. * @param onAnimationEnd Callback trigger at the end of the animation
  32451. * @returns Nullable animation
  32452. */
  32453. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  32454. /**
  32455. * Return the array of runtime animations currently using this animation
  32456. */
  32457. get runtimeAnimations(): RuntimeAnimation[];
  32458. /**
  32459. * Specifies if any of the runtime animations are currently running
  32460. */
  32461. get hasRunningRuntimeAnimations(): boolean;
  32462. /**
  32463. * Initializes the animation
  32464. * @param name Name of the animation
  32465. * @param targetProperty Property to animate
  32466. * @param framePerSecond The frames per second of the animation
  32467. * @param dataType The data type of the animation
  32468. * @param loopMode The loop mode of the animation
  32469. * @param enableBlending Specifies if blending should be enabled
  32470. */
  32471. constructor(
  32472. /**Name of the animation */
  32473. name: string,
  32474. /**Property to animate */
  32475. targetProperty: string,
  32476. /**The frames per second of the animation */
  32477. framePerSecond: number,
  32478. /**The data type of the animation */
  32479. dataType: number,
  32480. /**The loop mode of the animation */
  32481. loopMode?: number | undefined,
  32482. /**Specifies if blending should be enabled */
  32483. enableBlending?: boolean | undefined);
  32484. /**
  32485. * Converts the animation to a string
  32486. * @param fullDetails support for multiple levels of logging within scene loading
  32487. * @returns String form of the animation
  32488. */
  32489. toString(fullDetails?: boolean): string;
  32490. /**
  32491. * Add an event to this animation
  32492. * @param event Event to add
  32493. */
  32494. addEvent(event: AnimationEvent): void;
  32495. /**
  32496. * Remove all events found at the given frame
  32497. * @param frame The frame to remove events from
  32498. */
  32499. removeEvents(frame: number): void;
  32500. /**
  32501. * Retrieves all the events from the animation
  32502. * @returns Events from the animation
  32503. */
  32504. getEvents(): AnimationEvent[];
  32505. /**
  32506. * Creates an animation range
  32507. * @param name Name of the animation range
  32508. * @param from Starting frame of the animation range
  32509. * @param to Ending frame of the animation
  32510. */
  32511. createRange(name: string, from: number, to: number): void;
  32512. /**
  32513. * Deletes an animation range by name
  32514. * @param name Name of the animation range to delete
  32515. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  32516. */
  32517. deleteRange(name: string, deleteFrames?: boolean): void;
  32518. /**
  32519. * Gets the animation range by name, or null if not defined
  32520. * @param name Name of the animation range
  32521. * @returns Nullable animation range
  32522. */
  32523. getRange(name: string): Nullable<AnimationRange>;
  32524. /**
  32525. * Gets the key frames from the animation
  32526. * @returns The key frames of the animation
  32527. */
  32528. getKeys(): Array<IAnimationKey>;
  32529. /**
  32530. * Gets the highest frame rate of the animation
  32531. * @returns Highest frame rate of the animation
  32532. */
  32533. getHighestFrame(): number;
  32534. /**
  32535. * Gets the easing function of the animation
  32536. * @returns Easing function of the animation
  32537. */
  32538. getEasingFunction(): IEasingFunction;
  32539. /**
  32540. * Sets the easing function of the animation
  32541. * @param easingFunction A custom mathematical formula for animation
  32542. */
  32543. setEasingFunction(easingFunction: EasingFunction): void;
  32544. /**
  32545. * Interpolates a scalar linearly
  32546. * @param startValue Start value of the animation curve
  32547. * @param endValue End value of the animation curve
  32548. * @param gradient Scalar amount to interpolate
  32549. * @returns Interpolated scalar value
  32550. */
  32551. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  32552. /**
  32553. * Interpolates a scalar cubically
  32554. * @param startValue Start value of the animation curve
  32555. * @param outTangent End tangent of the animation
  32556. * @param endValue End value of the animation curve
  32557. * @param inTangent Start tangent of the animation curve
  32558. * @param gradient Scalar amount to interpolate
  32559. * @returns Interpolated scalar value
  32560. */
  32561. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  32562. /**
  32563. * Interpolates a quaternion using a spherical linear interpolation
  32564. * @param startValue Start value of the animation curve
  32565. * @param endValue End value of the animation curve
  32566. * @param gradient Scalar amount to interpolate
  32567. * @returns Interpolated quaternion value
  32568. */
  32569. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  32570. /**
  32571. * Interpolates a quaternion cubically
  32572. * @param startValue Start value of the animation curve
  32573. * @param outTangent End tangent of the animation curve
  32574. * @param endValue End value of the animation curve
  32575. * @param inTangent Start tangent of the animation curve
  32576. * @param gradient Scalar amount to interpolate
  32577. * @returns Interpolated quaternion value
  32578. */
  32579. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  32580. /**
  32581. * Interpolates a Vector3 linearl
  32582. * @param startValue Start value of the animation curve
  32583. * @param endValue End value of the animation curve
  32584. * @param gradient Scalar amount to interpolate
  32585. * @returns Interpolated scalar value
  32586. */
  32587. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  32588. /**
  32589. * Interpolates a Vector3 cubically
  32590. * @param startValue Start value of the animation curve
  32591. * @param outTangent End tangent of the animation
  32592. * @param endValue End value of the animation curve
  32593. * @param inTangent Start tangent of the animation curve
  32594. * @param gradient Scalar amount to interpolate
  32595. * @returns InterpolatedVector3 value
  32596. */
  32597. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  32598. /**
  32599. * Interpolates a Vector2 linearly
  32600. * @param startValue Start value of the animation curve
  32601. * @param endValue End value of the animation curve
  32602. * @param gradient Scalar amount to interpolate
  32603. * @returns Interpolated Vector2 value
  32604. */
  32605. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  32606. /**
  32607. * Interpolates a Vector2 cubically
  32608. * @param startValue Start value of the animation curve
  32609. * @param outTangent End tangent of the animation
  32610. * @param endValue End value of the animation curve
  32611. * @param inTangent Start tangent of the animation curve
  32612. * @param gradient Scalar amount to interpolate
  32613. * @returns Interpolated Vector2 value
  32614. */
  32615. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  32616. /**
  32617. * Interpolates a size linearly
  32618. * @param startValue Start value of the animation curve
  32619. * @param endValue End value of the animation curve
  32620. * @param gradient Scalar amount to interpolate
  32621. * @returns Interpolated Size value
  32622. */
  32623. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  32624. /**
  32625. * Interpolates a Color3 linearly
  32626. * @param startValue Start value of the animation curve
  32627. * @param endValue End value of the animation curve
  32628. * @param gradient Scalar amount to interpolate
  32629. * @returns Interpolated Color3 value
  32630. */
  32631. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  32632. /**
  32633. * Interpolates a Color4 linearly
  32634. * @param startValue Start value of the animation curve
  32635. * @param endValue End value of the animation curve
  32636. * @param gradient Scalar amount to interpolate
  32637. * @returns Interpolated Color3 value
  32638. */
  32639. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  32640. /**
  32641. * @hidden Internal use only
  32642. */
  32643. _getKeyValue(value: any): any;
  32644. /**
  32645. * @hidden Internal use only
  32646. */
  32647. _interpolate(currentFrame: number, state: _IAnimationState): any;
  32648. /**
  32649. * Defines the function to use to interpolate matrices
  32650. * @param startValue defines the start matrix
  32651. * @param endValue defines the end matrix
  32652. * @param gradient defines the gradient between both matrices
  32653. * @param result defines an optional target matrix where to store the interpolation
  32654. * @returns the interpolated matrix
  32655. */
  32656. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  32657. /**
  32658. * Makes a copy of the animation
  32659. * @returns Cloned animation
  32660. */
  32661. clone(): Animation;
  32662. /**
  32663. * Sets the key frames of the animation
  32664. * @param values The animation key frames to set
  32665. */
  32666. setKeys(values: Array<IAnimationKey>): void;
  32667. /**
  32668. * Serializes the animation to an object
  32669. * @returns Serialized object
  32670. */
  32671. serialize(): any;
  32672. /**
  32673. * Float animation type
  32674. */
  32675. static readonly ANIMATIONTYPE_FLOAT: number;
  32676. /**
  32677. * Vector3 animation type
  32678. */
  32679. static readonly ANIMATIONTYPE_VECTOR3: number;
  32680. /**
  32681. * Quaternion animation type
  32682. */
  32683. static readonly ANIMATIONTYPE_QUATERNION: number;
  32684. /**
  32685. * Matrix animation type
  32686. */
  32687. static readonly ANIMATIONTYPE_MATRIX: number;
  32688. /**
  32689. * Color3 animation type
  32690. */
  32691. static readonly ANIMATIONTYPE_COLOR3: number;
  32692. /**
  32693. * Color3 animation type
  32694. */
  32695. static readonly ANIMATIONTYPE_COLOR4: number;
  32696. /**
  32697. * Vector2 animation type
  32698. */
  32699. static readonly ANIMATIONTYPE_VECTOR2: number;
  32700. /**
  32701. * Size animation type
  32702. */
  32703. static readonly ANIMATIONTYPE_SIZE: number;
  32704. /**
  32705. * Relative Loop Mode
  32706. */
  32707. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  32708. /**
  32709. * Cycle Loop Mode
  32710. */
  32711. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  32712. /**
  32713. * Constant Loop Mode
  32714. */
  32715. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  32716. /** @hidden */
  32717. static _UniversalLerp(left: any, right: any, amount: number): any;
  32718. /**
  32719. * Parses an animation object and creates an animation
  32720. * @param parsedAnimation Parsed animation object
  32721. * @returns Animation object
  32722. */
  32723. static Parse(parsedAnimation: any): Animation;
  32724. /**
  32725. * Appends the serialized animations from the source animations
  32726. * @param source Source containing the animations
  32727. * @param destination Target to store the animations
  32728. */
  32729. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32730. /**
  32731. * Creates a new animation or an array of animations from a snippet saved in a remote file
  32732. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  32733. * @param url defines the url to load from
  32734. * @returns a promise that will resolve to the new animation or an array of animations
  32735. */
  32736. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  32737. /**
  32738. * Creates an animation or an array of animations from a snippet saved by the Inspector
  32739. * @param snippetId defines the snippet to load
  32740. * @returns a promise that will resolve to the new animation or a new array of animations
  32741. */
  32742. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  32743. }
  32744. }
  32745. declare module BABYLON {
  32746. /**
  32747. * Interface containing an array of animations
  32748. */
  32749. export interface IAnimatable {
  32750. /**
  32751. * Array of animations
  32752. */
  32753. animations: Nullable<Array<Animation>>;
  32754. }
  32755. }
  32756. declare module BABYLON {
  32757. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  32758. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32759. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32760. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32761. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32762. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32763. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32764. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32765. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32766. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32767. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32768. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32769. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32770. /**
  32771. * Decorator used to define property that can be serialized as reference to a camera
  32772. * @param sourceName defines the name of the property to decorate
  32773. */
  32774. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32775. /**
  32776. * Class used to help serialization objects
  32777. */
  32778. export class SerializationHelper {
  32779. /** @hidden */
  32780. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  32781. /** @hidden */
  32782. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  32783. /** @hidden */
  32784. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  32785. /** @hidden */
  32786. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  32787. /**
  32788. * Appends the serialized animations from the source animations
  32789. * @param source Source containing the animations
  32790. * @param destination Target to store the animations
  32791. */
  32792. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32793. /**
  32794. * Static function used to serialized a specific entity
  32795. * @param entity defines the entity to serialize
  32796. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  32797. * @returns a JSON compatible object representing the serialization of the entity
  32798. */
  32799. static Serialize<T>(entity: T, serializationObject?: any): any;
  32800. /**
  32801. * Creates a new entity from a serialization data object
  32802. * @param creationFunction defines a function used to instanciated the new entity
  32803. * @param source defines the source serialization data
  32804. * @param scene defines the hosting scene
  32805. * @param rootUrl defines the root url for resources
  32806. * @returns a new entity
  32807. */
  32808. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  32809. /**
  32810. * Clones an object
  32811. * @param creationFunction defines the function used to instanciate the new object
  32812. * @param source defines the source object
  32813. * @returns the cloned object
  32814. */
  32815. static Clone<T>(creationFunction: () => T, source: T): T;
  32816. /**
  32817. * Instanciates a new object based on a source one (some data will be shared between both object)
  32818. * @param creationFunction defines the function used to instanciate the new object
  32819. * @param source defines the source object
  32820. * @returns the new object
  32821. */
  32822. static Instanciate<T>(creationFunction: () => T, source: T): T;
  32823. }
  32824. }
  32825. declare module BABYLON {
  32826. /**
  32827. * Base class of all the textures in babylon.
  32828. * It groups all the common properties the materials, post process, lights... might need
  32829. * in order to make a correct use of the texture.
  32830. */
  32831. export class BaseTexture implements IAnimatable {
  32832. /**
  32833. * Default anisotropic filtering level for the application.
  32834. * It is set to 4 as a good tradeoff between perf and quality.
  32835. */
  32836. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  32837. /**
  32838. * Gets or sets the unique id of the texture
  32839. */
  32840. uniqueId: number;
  32841. /**
  32842. * Define the name of the texture.
  32843. */
  32844. name: string;
  32845. /**
  32846. * Gets or sets an object used to store user defined information.
  32847. */
  32848. metadata: any;
  32849. /**
  32850. * For internal use only. Please do not use.
  32851. */
  32852. reservedDataStore: any;
  32853. private _hasAlpha;
  32854. /**
  32855. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  32856. */
  32857. set hasAlpha(value: boolean);
  32858. get hasAlpha(): boolean;
  32859. /**
  32860. * Defines if the alpha value should be determined via the rgb values.
  32861. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  32862. */
  32863. getAlphaFromRGB: boolean;
  32864. /**
  32865. * Intensity or strength of the texture.
  32866. * It is commonly used by materials to fine tune the intensity of the texture
  32867. */
  32868. level: number;
  32869. /**
  32870. * Define the UV chanel to use starting from 0 and defaulting to 0.
  32871. * This is part of the texture as textures usually maps to one uv set.
  32872. */
  32873. coordinatesIndex: number;
  32874. private _coordinatesMode;
  32875. /**
  32876. * How a texture is mapped.
  32877. *
  32878. * | Value | Type | Description |
  32879. * | ----- | ----------------------------------- | ----------- |
  32880. * | 0 | EXPLICIT_MODE | |
  32881. * | 1 | SPHERICAL_MODE | |
  32882. * | 2 | PLANAR_MODE | |
  32883. * | 3 | CUBIC_MODE | |
  32884. * | 4 | PROJECTION_MODE | |
  32885. * | 5 | SKYBOX_MODE | |
  32886. * | 6 | INVCUBIC_MODE | |
  32887. * | 7 | EQUIRECTANGULAR_MODE | |
  32888. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  32889. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  32890. */
  32891. set coordinatesMode(value: number);
  32892. get coordinatesMode(): number;
  32893. /**
  32894. * | Value | Type | Description |
  32895. * | ----- | ------------------ | ----------- |
  32896. * | 0 | CLAMP_ADDRESSMODE | |
  32897. * | 1 | WRAP_ADDRESSMODE | |
  32898. * | 2 | MIRROR_ADDRESSMODE | |
  32899. */
  32900. wrapU: number;
  32901. /**
  32902. * | Value | Type | Description |
  32903. * | ----- | ------------------ | ----------- |
  32904. * | 0 | CLAMP_ADDRESSMODE | |
  32905. * | 1 | WRAP_ADDRESSMODE | |
  32906. * | 2 | MIRROR_ADDRESSMODE | |
  32907. */
  32908. wrapV: number;
  32909. /**
  32910. * | Value | Type | Description |
  32911. * | ----- | ------------------ | ----------- |
  32912. * | 0 | CLAMP_ADDRESSMODE | |
  32913. * | 1 | WRAP_ADDRESSMODE | |
  32914. * | 2 | MIRROR_ADDRESSMODE | |
  32915. */
  32916. wrapR: number;
  32917. /**
  32918. * With compliant hardware and browser (supporting anisotropic filtering)
  32919. * this defines the level of anisotropic filtering in the texture.
  32920. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  32921. */
  32922. anisotropicFilteringLevel: number;
  32923. /**
  32924. * Define if the texture is a cube texture or if false a 2d texture.
  32925. */
  32926. get isCube(): boolean;
  32927. set isCube(value: boolean);
  32928. /**
  32929. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  32930. */
  32931. get is3D(): boolean;
  32932. set is3D(value: boolean);
  32933. /**
  32934. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  32935. */
  32936. get is2DArray(): boolean;
  32937. set is2DArray(value: boolean);
  32938. /**
  32939. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  32940. * HDR texture are usually stored in linear space.
  32941. * This only impacts the PBR and Background materials
  32942. */
  32943. gammaSpace: boolean;
  32944. /**
  32945. * Gets or sets whether or not the texture contains RGBD data.
  32946. */
  32947. get isRGBD(): boolean;
  32948. set isRGBD(value: boolean);
  32949. /**
  32950. * Is Z inverted in the texture (useful in a cube texture).
  32951. */
  32952. invertZ: boolean;
  32953. /**
  32954. * Are mip maps generated for this texture or not.
  32955. */
  32956. get noMipmap(): boolean;
  32957. /**
  32958. * @hidden
  32959. */
  32960. lodLevelInAlpha: boolean;
  32961. /**
  32962. * With prefiltered texture, defined the offset used during the prefiltering steps.
  32963. */
  32964. get lodGenerationOffset(): number;
  32965. set lodGenerationOffset(value: number);
  32966. /**
  32967. * With prefiltered texture, defined the scale used during the prefiltering steps.
  32968. */
  32969. get lodGenerationScale(): number;
  32970. set lodGenerationScale(value: number);
  32971. /**
  32972. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  32973. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  32974. * average roughness values.
  32975. */
  32976. get linearSpecularLOD(): boolean;
  32977. set linearSpecularLOD(value: boolean);
  32978. /**
  32979. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  32980. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  32981. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  32982. */
  32983. get irradianceTexture(): Nullable<BaseTexture>;
  32984. set irradianceTexture(value: Nullable<BaseTexture>);
  32985. /**
  32986. * Define if the texture is a render target.
  32987. */
  32988. isRenderTarget: boolean;
  32989. /**
  32990. * Define the unique id of the texture in the scene.
  32991. */
  32992. get uid(): string;
  32993. /** @hidden */
  32994. _prefiltered: boolean;
  32995. /**
  32996. * Return a string representation of the texture.
  32997. * @returns the texture as a string
  32998. */
  32999. toString(): string;
  33000. /**
  33001. * Get the class name of the texture.
  33002. * @returns "BaseTexture"
  33003. */
  33004. getClassName(): string;
  33005. /**
  33006. * Define the list of animation attached to the texture.
  33007. */
  33008. animations: Animation[];
  33009. /**
  33010. * An event triggered when the texture is disposed.
  33011. */
  33012. onDisposeObservable: Observable<BaseTexture>;
  33013. private _onDisposeObserver;
  33014. /**
  33015. * Callback triggered when the texture has been disposed.
  33016. * Kept for back compatibility, you can use the onDisposeObservable instead.
  33017. */
  33018. set onDispose(callback: () => void);
  33019. /**
  33020. * Define the current state of the loading sequence when in delayed load mode.
  33021. */
  33022. delayLoadState: number;
  33023. private _scene;
  33024. private _engine;
  33025. /** @hidden */
  33026. _texture: Nullable<InternalTexture>;
  33027. private _uid;
  33028. /**
  33029. * Define if the texture is preventinga material to render or not.
  33030. * If not and the texture is not ready, the engine will use a default black texture instead.
  33031. */
  33032. get isBlocking(): boolean;
  33033. /**
  33034. * Instantiates a new BaseTexture.
  33035. * Base class of all the textures in babylon.
  33036. * It groups all the common properties the materials, post process, lights... might need
  33037. * in order to make a correct use of the texture.
  33038. * @param sceneOrEngine Define the scene or engine the texture blongs to
  33039. */
  33040. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  33041. /**
  33042. * Get the scene the texture belongs to.
  33043. * @returns the scene or null if undefined
  33044. */
  33045. getScene(): Nullable<Scene>;
  33046. /** @hidden */
  33047. protected _getEngine(): Nullable<ThinEngine>;
  33048. /**
  33049. * Get the texture transform matrix used to offset tile the texture for istance.
  33050. * @returns the transformation matrix
  33051. */
  33052. getTextureMatrix(): Matrix;
  33053. /**
  33054. * Get the texture reflection matrix used to rotate/transform the reflection.
  33055. * @returns the reflection matrix
  33056. */
  33057. getReflectionTextureMatrix(): Matrix;
  33058. /**
  33059. * Get the underlying lower level texture from Babylon.
  33060. * @returns the insternal texture
  33061. */
  33062. getInternalTexture(): Nullable<InternalTexture>;
  33063. /**
  33064. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  33065. * @returns true if ready or not blocking
  33066. */
  33067. isReadyOrNotBlocking(): boolean;
  33068. /**
  33069. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  33070. * @returns true if fully ready
  33071. */
  33072. isReady(): boolean;
  33073. private _cachedSize;
  33074. /**
  33075. * Get the size of the texture.
  33076. * @returns the texture size.
  33077. */
  33078. getSize(): ISize;
  33079. /**
  33080. * Get the base size of the texture.
  33081. * It can be different from the size if the texture has been resized for POT for instance
  33082. * @returns the base size
  33083. */
  33084. getBaseSize(): ISize;
  33085. /**
  33086. * Update the sampling mode of the texture.
  33087. * Default is Trilinear mode.
  33088. *
  33089. * | Value | Type | Description |
  33090. * | ----- | ------------------ | ----------- |
  33091. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  33092. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  33093. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  33094. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  33095. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  33096. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  33097. * | 7 | NEAREST_LINEAR | |
  33098. * | 8 | NEAREST_NEAREST | |
  33099. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  33100. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  33101. * | 11 | LINEAR_LINEAR | |
  33102. * | 12 | LINEAR_NEAREST | |
  33103. *
  33104. * > _mag_: magnification filter (close to the viewer)
  33105. * > _min_: minification filter (far from the viewer)
  33106. * > _mip_: filter used between mip map levels
  33107. *@param samplingMode Define the new sampling mode of the texture
  33108. */
  33109. updateSamplingMode(samplingMode: number): void;
  33110. /**
  33111. * Scales the texture if is `canRescale()`
  33112. * @param ratio the resize factor we want to use to rescale
  33113. */
  33114. scale(ratio: number): void;
  33115. /**
  33116. * Get if the texture can rescale.
  33117. */
  33118. get canRescale(): boolean;
  33119. /** @hidden */
  33120. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  33121. /** @hidden */
  33122. _rebuild(): void;
  33123. /**
  33124. * Triggers the load sequence in delayed load mode.
  33125. */
  33126. delayLoad(): void;
  33127. /**
  33128. * Clones the texture.
  33129. * @returns the cloned texture
  33130. */
  33131. clone(): Nullable<BaseTexture>;
  33132. /**
  33133. * Get the texture underlying type (INT, FLOAT...)
  33134. */
  33135. get textureType(): number;
  33136. /**
  33137. * Get the texture underlying format (RGB, RGBA...)
  33138. */
  33139. get textureFormat(): number;
  33140. /**
  33141. * Indicates that textures need to be re-calculated for all materials
  33142. */
  33143. protected _markAllSubMeshesAsTexturesDirty(): void;
  33144. /**
  33145. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  33146. * This will returns an RGBA array buffer containing either in values (0-255) or
  33147. * float values (0-1) depending of the underlying buffer type.
  33148. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  33149. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  33150. * @param buffer defines a user defined buffer to fill with data (can be null)
  33151. * @returns The Array buffer containing the pixels data.
  33152. */
  33153. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  33154. /**
  33155. * Release and destroy the underlying lower level texture aka internalTexture.
  33156. */
  33157. releaseInternalTexture(): void;
  33158. /** @hidden */
  33159. get _lodTextureHigh(): Nullable<BaseTexture>;
  33160. /** @hidden */
  33161. get _lodTextureMid(): Nullable<BaseTexture>;
  33162. /** @hidden */
  33163. get _lodTextureLow(): Nullable<BaseTexture>;
  33164. /**
  33165. * Dispose the texture and release its associated resources.
  33166. */
  33167. dispose(): void;
  33168. /**
  33169. * Serialize the texture into a JSON representation that can be parsed later on.
  33170. * @returns the JSON representation of the texture
  33171. */
  33172. serialize(): any;
  33173. /**
  33174. * Helper function to be called back once a list of texture contains only ready textures.
  33175. * @param textures Define the list of textures to wait for
  33176. * @param callback Define the callback triggered once the entire list will be ready
  33177. */
  33178. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  33179. private static _isScene;
  33180. }
  33181. }
  33182. declare module BABYLON {
  33183. /**
  33184. * Options to be used when creating an effect.
  33185. */
  33186. export interface IEffectCreationOptions {
  33187. /**
  33188. * Atrributes that will be used in the shader.
  33189. */
  33190. attributes: string[];
  33191. /**
  33192. * Uniform varible names that will be set in the shader.
  33193. */
  33194. uniformsNames: string[];
  33195. /**
  33196. * Uniform buffer variable names that will be set in the shader.
  33197. */
  33198. uniformBuffersNames: string[];
  33199. /**
  33200. * Sampler texture variable names that will be set in the shader.
  33201. */
  33202. samplers: string[];
  33203. /**
  33204. * Define statements that will be set in the shader.
  33205. */
  33206. defines: any;
  33207. /**
  33208. * Possible fallbacks for this effect to improve performance when needed.
  33209. */
  33210. fallbacks: Nullable<IEffectFallbacks>;
  33211. /**
  33212. * Callback that will be called when the shader is compiled.
  33213. */
  33214. onCompiled: Nullable<(effect: Effect) => void>;
  33215. /**
  33216. * Callback that will be called if an error occurs during shader compilation.
  33217. */
  33218. onError: Nullable<(effect: Effect, errors: string) => void>;
  33219. /**
  33220. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33221. */
  33222. indexParameters?: any;
  33223. /**
  33224. * Max number of lights that can be used in the shader.
  33225. */
  33226. maxSimultaneousLights?: number;
  33227. /**
  33228. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  33229. */
  33230. transformFeedbackVaryings?: Nullable<string[]>;
  33231. /**
  33232. * 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
  33233. */
  33234. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  33235. }
  33236. /**
  33237. * Effect containing vertex and fragment shader that can be executed on an object.
  33238. */
  33239. export class Effect implements IDisposable {
  33240. /**
  33241. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  33242. */
  33243. static ShadersRepository: string;
  33244. /**
  33245. * Enable logging of the shader code when a compilation error occurs
  33246. */
  33247. static LogShaderCodeOnCompilationError: boolean;
  33248. /**
  33249. * Name of the effect.
  33250. */
  33251. name: any;
  33252. /**
  33253. * String container all the define statements that should be set on the shader.
  33254. */
  33255. defines: string;
  33256. /**
  33257. * Callback that will be called when the shader is compiled.
  33258. */
  33259. onCompiled: Nullable<(effect: Effect) => void>;
  33260. /**
  33261. * Callback that will be called if an error occurs during shader compilation.
  33262. */
  33263. onError: Nullable<(effect: Effect, errors: string) => void>;
  33264. /**
  33265. * Callback that will be called when effect is bound.
  33266. */
  33267. onBind: Nullable<(effect: Effect) => void>;
  33268. /**
  33269. * Unique ID of the effect.
  33270. */
  33271. uniqueId: number;
  33272. /**
  33273. * Observable that will be called when the shader is compiled.
  33274. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  33275. */
  33276. onCompileObservable: Observable<Effect>;
  33277. /**
  33278. * Observable that will be called if an error occurs during shader compilation.
  33279. */
  33280. onErrorObservable: Observable<Effect>;
  33281. /** @hidden */
  33282. _onBindObservable: Nullable<Observable<Effect>>;
  33283. /**
  33284. * @hidden
  33285. * Specifies if the effect was previously ready
  33286. */
  33287. _wasPreviouslyReady: boolean;
  33288. /**
  33289. * Observable that will be called when effect is bound.
  33290. */
  33291. get onBindObservable(): Observable<Effect>;
  33292. /** @hidden */
  33293. _bonesComputationForcedToCPU: boolean;
  33294. private static _uniqueIdSeed;
  33295. private _engine;
  33296. private _uniformBuffersNames;
  33297. private _uniformBuffersNamesList;
  33298. private _uniformsNames;
  33299. private _samplerList;
  33300. private _samplers;
  33301. private _isReady;
  33302. private _compilationError;
  33303. private _allFallbacksProcessed;
  33304. private _attributesNames;
  33305. private _attributes;
  33306. private _attributeLocationByName;
  33307. private _uniforms;
  33308. /**
  33309. * Key for the effect.
  33310. * @hidden
  33311. */
  33312. _key: string;
  33313. private _indexParameters;
  33314. private _fallbacks;
  33315. private _vertexSourceCode;
  33316. private _fragmentSourceCode;
  33317. private _vertexSourceCodeOverride;
  33318. private _fragmentSourceCodeOverride;
  33319. private _transformFeedbackVaryings;
  33320. /**
  33321. * Compiled shader to webGL program.
  33322. * @hidden
  33323. */
  33324. _pipelineContext: Nullable<IPipelineContext>;
  33325. private _valueCache;
  33326. private static _baseCache;
  33327. /**
  33328. * Instantiates an effect.
  33329. * An effect can be used to create/manage/execute vertex and fragment shaders.
  33330. * @param baseName Name of the effect.
  33331. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  33332. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  33333. * @param samplers List of sampler variables that will be passed to the shader.
  33334. * @param engine Engine to be used to render the effect
  33335. * @param defines Define statements to be added to the shader.
  33336. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  33337. * @param onCompiled Callback that will be called when the shader is compiled.
  33338. * @param onError Callback that will be called if an error occurs during shader compilation.
  33339. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33340. */
  33341. 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);
  33342. private _useFinalCode;
  33343. /**
  33344. * Unique key for this effect
  33345. */
  33346. get key(): string;
  33347. /**
  33348. * If the effect has been compiled and prepared.
  33349. * @returns if the effect is compiled and prepared.
  33350. */
  33351. isReady(): boolean;
  33352. private _isReadyInternal;
  33353. /**
  33354. * The engine the effect was initialized with.
  33355. * @returns the engine.
  33356. */
  33357. getEngine(): Engine;
  33358. /**
  33359. * The pipeline context for this effect
  33360. * @returns the associated pipeline context
  33361. */
  33362. getPipelineContext(): Nullable<IPipelineContext>;
  33363. /**
  33364. * The set of names of attribute variables for the shader.
  33365. * @returns An array of attribute names.
  33366. */
  33367. getAttributesNames(): string[];
  33368. /**
  33369. * Returns the attribute at the given index.
  33370. * @param index The index of the attribute.
  33371. * @returns The location of the attribute.
  33372. */
  33373. getAttributeLocation(index: number): number;
  33374. /**
  33375. * Returns the attribute based on the name of the variable.
  33376. * @param name of the attribute to look up.
  33377. * @returns the attribute location.
  33378. */
  33379. getAttributeLocationByName(name: string): number;
  33380. /**
  33381. * The number of attributes.
  33382. * @returns the numnber of attributes.
  33383. */
  33384. getAttributesCount(): number;
  33385. /**
  33386. * Gets the index of a uniform variable.
  33387. * @param uniformName of the uniform to look up.
  33388. * @returns the index.
  33389. */
  33390. getUniformIndex(uniformName: string): number;
  33391. /**
  33392. * Returns the attribute based on the name of the variable.
  33393. * @param uniformName of the uniform to look up.
  33394. * @returns the location of the uniform.
  33395. */
  33396. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  33397. /**
  33398. * Returns an array of sampler variable names
  33399. * @returns The array of sampler variable names.
  33400. */
  33401. getSamplers(): string[];
  33402. /**
  33403. * Returns an array of uniform variable names
  33404. * @returns The array of uniform variable names.
  33405. */
  33406. getUniformNames(): string[];
  33407. /**
  33408. * Returns an array of uniform buffer variable names
  33409. * @returns The array of uniform buffer variable names.
  33410. */
  33411. getUniformBuffersNames(): string[];
  33412. /**
  33413. * Returns the index parameters used to create the effect
  33414. * @returns The index parameters object
  33415. */
  33416. getIndexParameters(): any;
  33417. /**
  33418. * The error from the last compilation.
  33419. * @returns the error string.
  33420. */
  33421. getCompilationError(): string;
  33422. /**
  33423. * Gets a boolean indicating that all fallbacks were used during compilation
  33424. * @returns true if all fallbacks were used
  33425. */
  33426. allFallbacksProcessed(): boolean;
  33427. /**
  33428. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  33429. * @param func The callback to be used.
  33430. */
  33431. executeWhenCompiled(func: (effect: Effect) => void): void;
  33432. private _checkIsReady;
  33433. private _loadShader;
  33434. /**
  33435. * Gets the vertex shader source code of this effect
  33436. */
  33437. get vertexSourceCode(): string;
  33438. /**
  33439. * Gets the fragment shader source code of this effect
  33440. */
  33441. get fragmentSourceCode(): string;
  33442. /**
  33443. * Recompiles the webGL program
  33444. * @param vertexSourceCode The source code for the vertex shader.
  33445. * @param fragmentSourceCode The source code for the fragment shader.
  33446. * @param onCompiled Callback called when completed.
  33447. * @param onError Callback called on error.
  33448. * @hidden
  33449. */
  33450. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  33451. /**
  33452. * Prepares the effect
  33453. * @hidden
  33454. */
  33455. _prepareEffect(): void;
  33456. private _getShaderCodeAndErrorLine;
  33457. private _processCompilationErrors;
  33458. /**
  33459. * Checks if the effect is supported. (Must be called after compilation)
  33460. */
  33461. get isSupported(): boolean;
  33462. /**
  33463. * Binds a texture to the engine to be used as output of the shader.
  33464. * @param channel Name of the output variable.
  33465. * @param texture Texture to bind.
  33466. * @hidden
  33467. */
  33468. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  33469. /**
  33470. * Sets a texture on the engine to be used in the shader.
  33471. * @param channel Name of the sampler variable.
  33472. * @param texture Texture to set.
  33473. */
  33474. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  33475. /**
  33476. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  33477. * @param channel Name of the sampler variable.
  33478. * @param texture Texture to set.
  33479. */
  33480. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  33481. /**
  33482. * Sets an array of textures on the engine to be used in the shader.
  33483. * @param channel Name of the variable.
  33484. * @param textures Textures to set.
  33485. */
  33486. setTextureArray(channel: string, textures: BaseTexture[]): void;
  33487. /**
  33488. * 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)
  33489. * @param channel Name of the sampler variable.
  33490. * @param postProcess Post process to get the input texture from.
  33491. */
  33492. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  33493. /**
  33494. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  33495. * 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)
  33496. * @param channel Name of the sampler variable.
  33497. * @param postProcess Post process to get the output texture from.
  33498. */
  33499. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  33500. /** @hidden */
  33501. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  33502. /** @hidden */
  33503. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  33504. /** @hidden */
  33505. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  33506. /** @hidden */
  33507. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  33508. /**
  33509. * Binds a buffer to a uniform.
  33510. * @param buffer Buffer to bind.
  33511. * @param name Name of the uniform variable to bind to.
  33512. */
  33513. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  33514. /**
  33515. * Binds block to a uniform.
  33516. * @param blockName Name of the block to bind.
  33517. * @param index Index to bind.
  33518. */
  33519. bindUniformBlock(blockName: string, index: number): void;
  33520. /**
  33521. * Sets an interger value on a uniform variable.
  33522. * @param uniformName Name of the variable.
  33523. * @param value Value to be set.
  33524. * @returns this effect.
  33525. */
  33526. setInt(uniformName: string, value: number): Effect;
  33527. /**
  33528. * Sets an int array on a uniform variable.
  33529. * @param uniformName Name of the variable.
  33530. * @param array array to be set.
  33531. * @returns this effect.
  33532. */
  33533. setIntArray(uniformName: string, array: Int32Array): Effect;
  33534. /**
  33535. * 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)
  33536. * @param uniformName Name of the variable.
  33537. * @param array array to be set.
  33538. * @returns this effect.
  33539. */
  33540. setIntArray2(uniformName: string, array: Int32Array): Effect;
  33541. /**
  33542. * 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)
  33543. * @param uniformName Name of the variable.
  33544. * @param array array to be set.
  33545. * @returns this effect.
  33546. */
  33547. setIntArray3(uniformName: string, array: Int32Array): Effect;
  33548. /**
  33549. * 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)
  33550. * @param uniformName Name of the variable.
  33551. * @param array array to be set.
  33552. * @returns this effect.
  33553. */
  33554. setIntArray4(uniformName: string, array: Int32Array): Effect;
  33555. /**
  33556. * Sets an float array on a uniform variable.
  33557. * @param uniformName Name of the variable.
  33558. * @param array array to be set.
  33559. * @returns this effect.
  33560. */
  33561. setFloatArray(uniformName: string, array: Float32Array): Effect;
  33562. /**
  33563. * 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)
  33564. * @param uniformName Name of the variable.
  33565. * @param array array to be set.
  33566. * @returns this effect.
  33567. */
  33568. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  33569. /**
  33570. * 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)
  33571. * @param uniformName Name of the variable.
  33572. * @param array array to be set.
  33573. * @returns this effect.
  33574. */
  33575. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  33576. /**
  33577. * 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)
  33578. * @param uniformName Name of the variable.
  33579. * @param array array to be set.
  33580. * @returns this effect.
  33581. */
  33582. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  33583. /**
  33584. * Sets an array on a uniform variable.
  33585. * @param uniformName Name of the variable.
  33586. * @param array array to be set.
  33587. * @returns this effect.
  33588. */
  33589. setArray(uniformName: string, array: number[]): Effect;
  33590. /**
  33591. * 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)
  33592. * @param uniformName Name of the variable.
  33593. * @param array array to be set.
  33594. * @returns this effect.
  33595. */
  33596. setArray2(uniformName: string, array: number[]): Effect;
  33597. /**
  33598. * 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)
  33599. * @param uniformName Name of the variable.
  33600. * @param array array to be set.
  33601. * @returns this effect.
  33602. */
  33603. setArray3(uniformName: string, array: number[]): Effect;
  33604. /**
  33605. * 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)
  33606. * @param uniformName Name of the variable.
  33607. * @param array array to be set.
  33608. * @returns this effect.
  33609. */
  33610. setArray4(uniformName: string, array: number[]): Effect;
  33611. /**
  33612. * Sets matrices on a uniform variable.
  33613. * @param uniformName Name of the variable.
  33614. * @param matrices matrices to be set.
  33615. * @returns this effect.
  33616. */
  33617. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  33618. /**
  33619. * Sets matrix on a uniform variable.
  33620. * @param uniformName Name of the variable.
  33621. * @param matrix matrix to be set.
  33622. * @returns this effect.
  33623. */
  33624. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  33625. /**
  33626. * 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)
  33627. * @param uniformName Name of the variable.
  33628. * @param matrix matrix to be set.
  33629. * @returns this effect.
  33630. */
  33631. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  33632. /**
  33633. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  33634. * @param uniformName Name of the variable.
  33635. * @param matrix matrix to be set.
  33636. * @returns this effect.
  33637. */
  33638. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  33639. /**
  33640. * Sets a float on a uniform variable.
  33641. * @param uniformName Name of the variable.
  33642. * @param value value to be set.
  33643. * @returns this effect.
  33644. */
  33645. setFloat(uniformName: string, value: number): Effect;
  33646. /**
  33647. * Sets a boolean on a uniform variable.
  33648. * @param uniformName Name of the variable.
  33649. * @param bool value to be set.
  33650. * @returns this effect.
  33651. */
  33652. setBool(uniformName: string, bool: boolean): Effect;
  33653. /**
  33654. * Sets a Vector2 on a uniform variable.
  33655. * @param uniformName Name of the variable.
  33656. * @param vector2 vector2 to be set.
  33657. * @returns this effect.
  33658. */
  33659. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  33660. /**
  33661. * Sets a float2 on a uniform variable.
  33662. * @param uniformName Name of the variable.
  33663. * @param x First float in float2.
  33664. * @param y Second float in float2.
  33665. * @returns this effect.
  33666. */
  33667. setFloat2(uniformName: string, x: number, y: number): Effect;
  33668. /**
  33669. * Sets a Vector3 on a uniform variable.
  33670. * @param uniformName Name of the variable.
  33671. * @param vector3 Value to be set.
  33672. * @returns this effect.
  33673. */
  33674. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  33675. /**
  33676. * Sets a float3 on a uniform variable.
  33677. * @param uniformName Name of the variable.
  33678. * @param x First float in float3.
  33679. * @param y Second float in float3.
  33680. * @param z Third float in float3.
  33681. * @returns this effect.
  33682. */
  33683. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  33684. /**
  33685. * Sets a Vector4 on a uniform variable.
  33686. * @param uniformName Name of the variable.
  33687. * @param vector4 Value to be set.
  33688. * @returns this effect.
  33689. */
  33690. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  33691. /**
  33692. * Sets a float4 on a uniform variable.
  33693. * @param uniformName Name of the variable.
  33694. * @param x First float in float4.
  33695. * @param y Second float in float4.
  33696. * @param z Third float in float4.
  33697. * @param w Fourth float in float4.
  33698. * @returns this effect.
  33699. */
  33700. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  33701. /**
  33702. * Sets a Color3 on a uniform variable.
  33703. * @param uniformName Name of the variable.
  33704. * @param color3 Value to be set.
  33705. * @returns this effect.
  33706. */
  33707. setColor3(uniformName: string, color3: IColor3Like): Effect;
  33708. /**
  33709. * Sets a Color4 on a uniform variable.
  33710. * @param uniformName Name of the variable.
  33711. * @param color3 Value to be set.
  33712. * @param alpha Alpha value to be set.
  33713. * @returns this effect.
  33714. */
  33715. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  33716. /**
  33717. * Sets a Color4 on a uniform variable
  33718. * @param uniformName defines the name of the variable
  33719. * @param color4 defines the value to be set
  33720. * @returns this effect.
  33721. */
  33722. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  33723. /** Release all associated resources */
  33724. dispose(): void;
  33725. /**
  33726. * This function will add a new shader to the shader store
  33727. * @param name the name of the shader
  33728. * @param pixelShader optional pixel shader content
  33729. * @param vertexShader optional vertex shader content
  33730. */
  33731. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  33732. /**
  33733. * Store of each shader (The can be looked up using effect.key)
  33734. */
  33735. static ShadersStore: {
  33736. [key: string]: string;
  33737. };
  33738. /**
  33739. * Store of each included file for a shader (The can be looked up using effect.key)
  33740. */
  33741. static IncludesShadersStore: {
  33742. [key: string]: string;
  33743. };
  33744. /**
  33745. * Resets the cache of effects.
  33746. */
  33747. static ResetCache(): void;
  33748. }
  33749. }
  33750. declare module BABYLON {
  33751. /**
  33752. * Interface used to describe the capabilities of the engine relatively to the current browser
  33753. */
  33754. export interface EngineCapabilities {
  33755. /** Maximum textures units per fragment shader */
  33756. maxTexturesImageUnits: number;
  33757. /** Maximum texture units per vertex shader */
  33758. maxVertexTextureImageUnits: number;
  33759. /** Maximum textures units in the entire pipeline */
  33760. maxCombinedTexturesImageUnits: number;
  33761. /** Maximum texture size */
  33762. maxTextureSize: number;
  33763. /** Maximum texture samples */
  33764. maxSamples?: number;
  33765. /** Maximum cube texture size */
  33766. maxCubemapTextureSize: number;
  33767. /** Maximum render texture size */
  33768. maxRenderTextureSize: number;
  33769. /** Maximum number of vertex attributes */
  33770. maxVertexAttribs: number;
  33771. /** Maximum number of varyings */
  33772. maxVaryingVectors: number;
  33773. /** Maximum number of uniforms per vertex shader */
  33774. maxVertexUniformVectors: number;
  33775. /** Maximum number of uniforms per fragment shader */
  33776. maxFragmentUniformVectors: number;
  33777. /** Defines if standard derivates (dx/dy) are supported */
  33778. standardDerivatives: boolean;
  33779. /** Defines if s3tc texture compression is supported */
  33780. s3tc?: WEBGL_compressed_texture_s3tc;
  33781. /** Defines if pvrtc texture compression is supported */
  33782. pvrtc: any;
  33783. /** Defines if etc1 texture compression is supported */
  33784. etc1: any;
  33785. /** Defines if etc2 texture compression is supported */
  33786. etc2: any;
  33787. /** Defines if astc texture compression is supported */
  33788. astc: any;
  33789. /** Defines if float textures are supported */
  33790. textureFloat: boolean;
  33791. /** Defines if vertex array objects are supported */
  33792. vertexArrayObject: boolean;
  33793. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  33794. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  33795. /** Gets the maximum level of anisotropy supported */
  33796. maxAnisotropy: number;
  33797. /** Defines if instancing is supported */
  33798. instancedArrays: boolean;
  33799. /** Defines if 32 bits indices are supported */
  33800. uintIndices: boolean;
  33801. /** Defines if high precision shaders are supported */
  33802. highPrecisionShaderSupported: boolean;
  33803. /** Defines if depth reading in the fragment shader is supported */
  33804. fragmentDepthSupported: boolean;
  33805. /** Defines if float texture linear filtering is supported*/
  33806. textureFloatLinearFiltering: boolean;
  33807. /** Defines if rendering to float textures is supported */
  33808. textureFloatRender: boolean;
  33809. /** Defines if half float textures are supported*/
  33810. textureHalfFloat: boolean;
  33811. /** Defines if half float texture linear filtering is supported*/
  33812. textureHalfFloatLinearFiltering: boolean;
  33813. /** Defines if rendering to half float textures is supported */
  33814. textureHalfFloatRender: boolean;
  33815. /** Defines if textureLOD shader command is supported */
  33816. textureLOD: boolean;
  33817. /** Defines if draw buffers extension is supported */
  33818. drawBuffersExtension: boolean;
  33819. /** Defines if depth textures are supported */
  33820. depthTextureExtension: boolean;
  33821. /** Defines if float color buffer are supported */
  33822. colorBufferFloat: boolean;
  33823. /** Gets disjoint timer query extension (null if not supported) */
  33824. timerQuery?: EXT_disjoint_timer_query;
  33825. /** Defines if timestamp can be used with timer query */
  33826. canUseTimestampForTimerQuery: boolean;
  33827. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  33828. multiview?: any;
  33829. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  33830. oculusMultiview?: any;
  33831. /** Function used to let the system compiles shaders in background */
  33832. parallelShaderCompile?: {
  33833. COMPLETION_STATUS_KHR: number;
  33834. };
  33835. /** Max number of texture samples for MSAA */
  33836. maxMSAASamples: number;
  33837. /** Defines if the blend min max extension is supported */
  33838. blendMinMax: boolean;
  33839. }
  33840. }
  33841. declare module BABYLON {
  33842. /**
  33843. * @hidden
  33844. **/
  33845. export class DepthCullingState {
  33846. private _isDepthTestDirty;
  33847. private _isDepthMaskDirty;
  33848. private _isDepthFuncDirty;
  33849. private _isCullFaceDirty;
  33850. private _isCullDirty;
  33851. private _isZOffsetDirty;
  33852. private _isFrontFaceDirty;
  33853. private _depthTest;
  33854. private _depthMask;
  33855. private _depthFunc;
  33856. private _cull;
  33857. private _cullFace;
  33858. private _zOffset;
  33859. private _frontFace;
  33860. /**
  33861. * Initializes the state.
  33862. */
  33863. constructor();
  33864. get isDirty(): boolean;
  33865. get zOffset(): number;
  33866. set zOffset(value: number);
  33867. get cullFace(): Nullable<number>;
  33868. set cullFace(value: Nullable<number>);
  33869. get cull(): Nullable<boolean>;
  33870. set cull(value: Nullable<boolean>);
  33871. get depthFunc(): Nullable<number>;
  33872. set depthFunc(value: Nullable<number>);
  33873. get depthMask(): boolean;
  33874. set depthMask(value: boolean);
  33875. get depthTest(): boolean;
  33876. set depthTest(value: boolean);
  33877. get frontFace(): Nullable<number>;
  33878. set frontFace(value: Nullable<number>);
  33879. reset(): void;
  33880. apply(gl: WebGLRenderingContext): void;
  33881. }
  33882. }
  33883. declare module BABYLON {
  33884. /**
  33885. * @hidden
  33886. **/
  33887. export class StencilState {
  33888. /** 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 */
  33889. static readonly ALWAYS: number;
  33890. /** Passed to stencilOperation to specify that stencil value must be kept */
  33891. static readonly KEEP: number;
  33892. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33893. static readonly REPLACE: number;
  33894. private _isStencilTestDirty;
  33895. private _isStencilMaskDirty;
  33896. private _isStencilFuncDirty;
  33897. private _isStencilOpDirty;
  33898. private _stencilTest;
  33899. private _stencilMask;
  33900. private _stencilFunc;
  33901. private _stencilFuncRef;
  33902. private _stencilFuncMask;
  33903. private _stencilOpStencilFail;
  33904. private _stencilOpDepthFail;
  33905. private _stencilOpStencilDepthPass;
  33906. get isDirty(): boolean;
  33907. get stencilFunc(): number;
  33908. set stencilFunc(value: number);
  33909. get stencilFuncRef(): number;
  33910. set stencilFuncRef(value: number);
  33911. get stencilFuncMask(): number;
  33912. set stencilFuncMask(value: number);
  33913. get stencilOpStencilFail(): number;
  33914. set stencilOpStencilFail(value: number);
  33915. get stencilOpDepthFail(): number;
  33916. set stencilOpDepthFail(value: number);
  33917. get stencilOpStencilDepthPass(): number;
  33918. set stencilOpStencilDepthPass(value: number);
  33919. get stencilMask(): number;
  33920. set stencilMask(value: number);
  33921. get stencilTest(): boolean;
  33922. set stencilTest(value: boolean);
  33923. constructor();
  33924. reset(): void;
  33925. apply(gl: WebGLRenderingContext): void;
  33926. }
  33927. }
  33928. declare module BABYLON {
  33929. /**
  33930. * @hidden
  33931. **/
  33932. export class AlphaState {
  33933. private _isAlphaBlendDirty;
  33934. private _isBlendFunctionParametersDirty;
  33935. private _isBlendEquationParametersDirty;
  33936. private _isBlendConstantsDirty;
  33937. private _alphaBlend;
  33938. private _blendFunctionParameters;
  33939. private _blendEquationParameters;
  33940. private _blendConstants;
  33941. /**
  33942. * Initializes the state.
  33943. */
  33944. constructor();
  33945. get isDirty(): boolean;
  33946. get alphaBlend(): boolean;
  33947. set alphaBlend(value: boolean);
  33948. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  33949. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  33950. setAlphaEquationParameters(rgb: number, alpha: number): void;
  33951. reset(): void;
  33952. apply(gl: WebGLRenderingContext): void;
  33953. }
  33954. }
  33955. declare module BABYLON {
  33956. /** @hidden */
  33957. export class WebGL2ShaderProcessor implements IShaderProcessor {
  33958. attributeProcessor(attribute: string): string;
  33959. varyingProcessor(varying: string, isFragment: boolean): string;
  33960. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  33961. }
  33962. }
  33963. declare module BABYLON {
  33964. /**
  33965. * Interface for attribute information associated with buffer instanciation
  33966. */
  33967. export interface InstancingAttributeInfo {
  33968. /**
  33969. * Name of the GLSL attribute
  33970. * if attribute index is not specified, this is used to retrieve the index from the effect
  33971. */
  33972. attributeName: string;
  33973. /**
  33974. * Index/offset of the attribute in the vertex shader
  33975. * if not specified, this will be computes from the name.
  33976. */
  33977. index?: number;
  33978. /**
  33979. * size of the attribute, 1, 2, 3 or 4
  33980. */
  33981. attributeSize: number;
  33982. /**
  33983. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  33984. */
  33985. offset: number;
  33986. /**
  33987. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  33988. * default to 1
  33989. */
  33990. divisor?: number;
  33991. /**
  33992. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  33993. * default is FLOAT
  33994. */
  33995. attributeType?: number;
  33996. /**
  33997. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  33998. */
  33999. normalized?: boolean;
  34000. }
  34001. }
  34002. declare module BABYLON {
  34003. interface ThinEngine {
  34004. /**
  34005. * Update a video texture
  34006. * @param texture defines the texture to update
  34007. * @param video defines the video element to use
  34008. * @param invertY defines if data must be stored with Y axis inverted
  34009. */
  34010. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  34011. }
  34012. }
  34013. declare module BABYLON {
  34014. interface ThinEngine {
  34015. /**
  34016. * Creates a dynamic texture
  34017. * @param width defines the width of the texture
  34018. * @param height defines the height of the texture
  34019. * @param generateMipMaps defines if the engine should generate the mip levels
  34020. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  34021. * @returns the dynamic texture inside an InternalTexture
  34022. */
  34023. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  34024. /**
  34025. * Update the content of a dynamic texture
  34026. * @param texture defines the texture to update
  34027. * @param canvas defines the canvas containing the source
  34028. * @param invertY defines if data must be stored with Y axis inverted
  34029. * @param premulAlpha defines if alpha is stored as premultiplied
  34030. * @param format defines the format of the data
  34031. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  34032. */
  34033. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  34034. }
  34035. }
  34036. declare module BABYLON {
  34037. /**
  34038. * Settings for finer control over video usage
  34039. */
  34040. export interface VideoTextureSettings {
  34041. /**
  34042. * Applies `autoplay` to video, if specified
  34043. */
  34044. autoPlay?: boolean;
  34045. /**
  34046. * Applies `loop` to video, if specified
  34047. */
  34048. loop?: boolean;
  34049. /**
  34050. * Automatically updates internal texture from video at every frame in the render loop
  34051. */
  34052. autoUpdateTexture: boolean;
  34053. /**
  34054. * Image src displayed during the video loading or until the user interacts with the video.
  34055. */
  34056. poster?: string;
  34057. }
  34058. /**
  34059. * If you want to display a video in your scene, this is the special texture for that.
  34060. * This special texture works similar to other textures, with the exception of a few parameters.
  34061. * @see https://doc.babylonjs.com/how_to/video_texture
  34062. */
  34063. export class VideoTexture extends Texture {
  34064. /**
  34065. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  34066. */
  34067. readonly autoUpdateTexture: boolean;
  34068. /**
  34069. * The video instance used by the texture internally
  34070. */
  34071. readonly video: HTMLVideoElement;
  34072. private _onUserActionRequestedObservable;
  34073. /**
  34074. * Event triggerd when a dom action is required by the user to play the video.
  34075. * This happens due to recent changes in browser policies preventing video to auto start.
  34076. */
  34077. get onUserActionRequestedObservable(): Observable<Texture>;
  34078. private _generateMipMaps;
  34079. private _stillImageCaptured;
  34080. private _displayingPosterTexture;
  34081. private _settings;
  34082. private _createInternalTextureOnEvent;
  34083. private _frameId;
  34084. private _currentSrc;
  34085. /**
  34086. * Creates a video texture.
  34087. * If you want to display a video in your scene, this is the special texture for that.
  34088. * This special texture works similar to other textures, with the exception of a few parameters.
  34089. * @see https://doc.babylonjs.com/how_to/video_texture
  34090. * @param name optional name, will detect from video source, if not defined
  34091. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  34092. * @param scene is obviously the current scene.
  34093. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  34094. * @param invertY is false by default but can be used to invert video on Y axis
  34095. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  34096. * @param settings allows finer control over video usage
  34097. */
  34098. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  34099. private _getName;
  34100. private _getVideo;
  34101. private _createInternalTexture;
  34102. private reset;
  34103. /**
  34104. * @hidden Internal method to initiate `update`.
  34105. */
  34106. _rebuild(): void;
  34107. /**
  34108. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  34109. */
  34110. update(): void;
  34111. /**
  34112. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  34113. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  34114. */
  34115. updateTexture(isVisible: boolean): void;
  34116. protected _updateInternalTexture: () => void;
  34117. /**
  34118. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  34119. * @param url New url.
  34120. */
  34121. updateURL(url: string): void;
  34122. /**
  34123. * Clones the texture.
  34124. * @returns the cloned texture
  34125. */
  34126. clone(): VideoTexture;
  34127. /**
  34128. * Dispose the texture and release its associated resources.
  34129. */
  34130. dispose(): void;
  34131. /**
  34132. * Creates a video texture straight from a stream.
  34133. * @param scene Define the scene the texture should be created in
  34134. * @param stream Define the stream the texture should be created from
  34135. * @returns The created video texture as a promise
  34136. */
  34137. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  34138. /**
  34139. * Creates a video texture straight from your WebCam video feed.
  34140. * @param scene Define the scene the texture should be created in
  34141. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  34142. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  34143. * @returns The created video texture as a promise
  34144. */
  34145. static CreateFromWebCamAsync(scene: Scene, constraints: {
  34146. minWidth: number;
  34147. maxWidth: number;
  34148. minHeight: number;
  34149. maxHeight: number;
  34150. deviceId: string;
  34151. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  34152. /**
  34153. * Creates a video texture straight from your WebCam video feed.
  34154. * @param scene Define the scene the texture should be created in
  34155. * @param onReady Define a callback to triggered once the texture will be ready
  34156. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  34157. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  34158. */
  34159. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  34160. minWidth: number;
  34161. maxWidth: number;
  34162. minHeight: number;
  34163. maxHeight: number;
  34164. deviceId: string;
  34165. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  34166. }
  34167. }
  34168. declare module BABYLON {
  34169. /**
  34170. * Defines the interface used by objects working like Scene
  34171. * @hidden
  34172. */
  34173. export interface ISceneLike {
  34174. _addPendingData(data: any): void;
  34175. _removePendingData(data: any): void;
  34176. offlineProvider: IOfflineProvider;
  34177. }
  34178. /** Interface defining initialization parameters for Engine class */
  34179. export interface EngineOptions extends WebGLContextAttributes {
  34180. /**
  34181. * Defines if the engine should no exceed a specified device ratio
  34182. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  34183. */
  34184. limitDeviceRatio?: number;
  34185. /**
  34186. * Defines if webvr should be enabled automatically
  34187. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34188. */
  34189. autoEnableWebVR?: boolean;
  34190. /**
  34191. * Defines if webgl2 should be turned off even if supported
  34192. * @see http://doc.babylonjs.com/features/webgl2
  34193. */
  34194. disableWebGL2Support?: boolean;
  34195. /**
  34196. * Defines if webaudio should be initialized as well
  34197. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34198. */
  34199. audioEngine?: boolean;
  34200. /**
  34201. * Defines if animations should run using a deterministic lock step
  34202. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34203. */
  34204. deterministicLockstep?: boolean;
  34205. /** Defines the maximum steps to use with deterministic lock step mode */
  34206. lockstepMaxSteps?: number;
  34207. /** Defines the seconds between each deterministic lock step */
  34208. timeStep?: number;
  34209. /**
  34210. * Defines that engine should ignore context lost events
  34211. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  34212. */
  34213. doNotHandleContextLost?: boolean;
  34214. /**
  34215. * Defines that engine should ignore modifying touch action attribute and style
  34216. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  34217. */
  34218. doNotHandleTouchAction?: boolean;
  34219. /**
  34220. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  34221. */
  34222. useHighPrecisionFloats?: boolean;
  34223. /**
  34224. * Make the canvas XR Compatible for XR sessions
  34225. */
  34226. xrCompatible?: boolean;
  34227. }
  34228. /**
  34229. * The base engine class (root of all engines)
  34230. */
  34231. export class ThinEngine {
  34232. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  34233. static ExceptionList: ({
  34234. key: string;
  34235. capture: string;
  34236. captureConstraint: number;
  34237. targets: string[];
  34238. } | {
  34239. key: string;
  34240. capture: null;
  34241. captureConstraint: null;
  34242. targets: string[];
  34243. })[];
  34244. /** @hidden */
  34245. static _TextureLoaders: IInternalTextureLoader[];
  34246. /**
  34247. * Returns the current npm package of the sdk
  34248. */
  34249. static get NpmPackage(): string;
  34250. /**
  34251. * Returns the current version of the framework
  34252. */
  34253. static get Version(): string;
  34254. /**
  34255. * Returns a string describing the current engine
  34256. */
  34257. get description(): string;
  34258. /**
  34259. * Gets or sets the epsilon value used by collision engine
  34260. */
  34261. static CollisionsEpsilon: number;
  34262. /**
  34263. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34264. */
  34265. static get ShadersRepository(): string;
  34266. static set ShadersRepository(value: string);
  34267. /** @hidden */
  34268. _shaderProcessor: IShaderProcessor;
  34269. /**
  34270. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  34271. */
  34272. forcePOTTextures: boolean;
  34273. /**
  34274. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  34275. */
  34276. isFullscreen: boolean;
  34277. /**
  34278. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  34279. */
  34280. cullBackFaces: boolean;
  34281. /**
  34282. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  34283. */
  34284. renderEvenInBackground: boolean;
  34285. /**
  34286. * Gets or sets a boolean indicating that cache can be kept between frames
  34287. */
  34288. preventCacheWipeBetweenFrames: boolean;
  34289. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  34290. validateShaderPrograms: boolean;
  34291. /**
  34292. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  34293. * This can provide greater z depth for distant objects.
  34294. */
  34295. useReverseDepthBuffer: boolean;
  34296. /**
  34297. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  34298. */
  34299. disableUniformBuffers: boolean;
  34300. /** @hidden */
  34301. _uniformBuffers: UniformBuffer[];
  34302. /**
  34303. * Gets a boolean indicating that the engine supports uniform buffers
  34304. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  34305. */
  34306. get supportsUniformBuffers(): boolean;
  34307. /** @hidden */
  34308. _gl: WebGLRenderingContext;
  34309. /** @hidden */
  34310. _webGLVersion: number;
  34311. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  34312. protected _windowIsBackground: boolean;
  34313. protected _creationOptions: EngineOptions;
  34314. protected _highPrecisionShadersAllowed: boolean;
  34315. /** @hidden */
  34316. get _shouldUseHighPrecisionShader(): boolean;
  34317. /**
  34318. * Gets a boolean indicating that only power of 2 textures are supported
  34319. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  34320. */
  34321. get needPOTTextures(): boolean;
  34322. /** @hidden */
  34323. _badOS: boolean;
  34324. /** @hidden */
  34325. _badDesktopOS: boolean;
  34326. private _hardwareScalingLevel;
  34327. /** @hidden */
  34328. _caps: EngineCapabilities;
  34329. private _isStencilEnable;
  34330. private _glVersion;
  34331. private _glRenderer;
  34332. private _glVendor;
  34333. /** @hidden */
  34334. _videoTextureSupported: boolean;
  34335. protected _renderingQueueLaunched: boolean;
  34336. protected _activeRenderLoops: (() => void)[];
  34337. /**
  34338. * Observable signaled when a context lost event is raised
  34339. */
  34340. onContextLostObservable: Observable<ThinEngine>;
  34341. /**
  34342. * Observable signaled when a context restored event is raised
  34343. */
  34344. onContextRestoredObservable: Observable<ThinEngine>;
  34345. private _onContextLost;
  34346. private _onContextRestored;
  34347. protected _contextWasLost: boolean;
  34348. /** @hidden */
  34349. _doNotHandleContextLost: boolean;
  34350. /**
  34351. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  34352. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  34353. */
  34354. get doNotHandleContextLost(): boolean;
  34355. set doNotHandleContextLost(value: boolean);
  34356. /**
  34357. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  34358. */
  34359. disableVertexArrayObjects: boolean;
  34360. /** @hidden */
  34361. protected _colorWrite: boolean;
  34362. /** @hidden */
  34363. protected _colorWriteChanged: boolean;
  34364. /** @hidden */
  34365. protected _depthCullingState: DepthCullingState;
  34366. /** @hidden */
  34367. protected _stencilState: StencilState;
  34368. /** @hidden */
  34369. _alphaState: AlphaState;
  34370. /** @hidden */
  34371. _alphaMode: number;
  34372. /** @hidden */
  34373. _alphaEquation: number;
  34374. /** @hidden */
  34375. _internalTexturesCache: InternalTexture[];
  34376. /** @hidden */
  34377. protected _activeChannel: number;
  34378. private _currentTextureChannel;
  34379. /** @hidden */
  34380. protected _boundTexturesCache: {
  34381. [key: string]: Nullable<InternalTexture>;
  34382. };
  34383. /** @hidden */
  34384. protected _currentEffect: Nullable<Effect>;
  34385. /** @hidden */
  34386. protected _currentProgram: Nullable<WebGLProgram>;
  34387. private _compiledEffects;
  34388. private _vertexAttribArraysEnabled;
  34389. /** @hidden */
  34390. protected _cachedViewport: Nullable<IViewportLike>;
  34391. private _cachedVertexArrayObject;
  34392. /** @hidden */
  34393. protected _cachedVertexBuffers: any;
  34394. /** @hidden */
  34395. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  34396. /** @hidden */
  34397. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  34398. /** @hidden */
  34399. _currentRenderTarget: Nullable<InternalTexture>;
  34400. private _uintIndicesCurrentlySet;
  34401. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  34402. /** @hidden */
  34403. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  34404. /** @hidden */
  34405. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  34406. private _currentBufferPointers;
  34407. private _currentInstanceLocations;
  34408. private _currentInstanceBuffers;
  34409. private _textureUnits;
  34410. /** @hidden */
  34411. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  34412. /** @hidden */
  34413. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  34414. /** @hidden */
  34415. _boundRenderFunction: any;
  34416. private _vaoRecordInProgress;
  34417. private _mustWipeVertexAttributes;
  34418. private _emptyTexture;
  34419. private _emptyCubeTexture;
  34420. private _emptyTexture3D;
  34421. private _emptyTexture2DArray;
  34422. /** @hidden */
  34423. _frameHandler: number;
  34424. private _nextFreeTextureSlots;
  34425. private _maxSimultaneousTextures;
  34426. private _activeRequests;
  34427. /** @hidden */
  34428. _transformTextureUrl: Nullable<(url: string) => string>;
  34429. protected get _supportsHardwareTextureRescaling(): boolean;
  34430. private _framebufferDimensionsObject;
  34431. /**
  34432. * sets the object from which width and height will be taken from when getting render width and height
  34433. * Will fallback to the gl object
  34434. * @param dimensions the framebuffer width and height that will be used.
  34435. */
  34436. set framebufferDimensionsObject(dimensions: Nullable<{
  34437. framebufferWidth: number;
  34438. framebufferHeight: number;
  34439. }>);
  34440. /**
  34441. * Gets the current viewport
  34442. */
  34443. get currentViewport(): Nullable<IViewportLike>;
  34444. /**
  34445. * Gets the default empty texture
  34446. */
  34447. get emptyTexture(): InternalTexture;
  34448. /**
  34449. * Gets the default empty 3D texture
  34450. */
  34451. get emptyTexture3D(): InternalTexture;
  34452. /**
  34453. * Gets the default empty 2D array texture
  34454. */
  34455. get emptyTexture2DArray(): InternalTexture;
  34456. /**
  34457. * Gets the default empty cube texture
  34458. */
  34459. get emptyCubeTexture(): InternalTexture;
  34460. /**
  34461. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  34462. */
  34463. readonly premultipliedAlpha: boolean;
  34464. /**
  34465. * Observable event triggered before each texture is initialized
  34466. */
  34467. onBeforeTextureInitObservable: Observable<Texture>;
  34468. /**
  34469. * Creates a new engine
  34470. * @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
  34471. * @param antialias defines enable antialiasing (default: false)
  34472. * @param options defines further options to be sent to the getContext() function
  34473. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34474. */
  34475. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34476. private _rebuildInternalTextures;
  34477. private _rebuildEffects;
  34478. /**
  34479. * Gets a boolean indicating if all created effects are ready
  34480. * @returns true if all effects are ready
  34481. */
  34482. areAllEffectsReady(): boolean;
  34483. protected _rebuildBuffers(): void;
  34484. protected _initGLContext(): void;
  34485. /**
  34486. * Gets version of the current webGL context
  34487. */
  34488. get webGLVersion(): number;
  34489. /**
  34490. * Gets a string idenfifying the name of the class
  34491. * @returns "Engine" string
  34492. */
  34493. getClassName(): string;
  34494. /**
  34495. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  34496. */
  34497. get isStencilEnable(): boolean;
  34498. /** @hidden */
  34499. _prepareWorkingCanvas(): void;
  34500. /**
  34501. * Reset the texture cache to empty state
  34502. */
  34503. resetTextureCache(): void;
  34504. /**
  34505. * Gets an object containing information about the current webGL context
  34506. * @returns an object containing the vender, the renderer and the version of the current webGL context
  34507. */
  34508. getGlInfo(): {
  34509. vendor: string;
  34510. renderer: string;
  34511. version: string;
  34512. };
  34513. /**
  34514. * Defines the hardware scaling level.
  34515. * By default the hardware scaling level is computed from the window device ratio.
  34516. * 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.
  34517. * @param level defines the level to use
  34518. */
  34519. setHardwareScalingLevel(level: number): void;
  34520. /**
  34521. * Gets the current hardware scaling level.
  34522. * By default the hardware scaling level is computed from the window device ratio.
  34523. * 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.
  34524. * @returns a number indicating the current hardware scaling level
  34525. */
  34526. getHardwareScalingLevel(): number;
  34527. /**
  34528. * Gets the list of loaded textures
  34529. * @returns an array containing all loaded textures
  34530. */
  34531. getLoadedTexturesCache(): InternalTexture[];
  34532. /**
  34533. * Gets the object containing all engine capabilities
  34534. * @returns the EngineCapabilities object
  34535. */
  34536. getCaps(): EngineCapabilities;
  34537. /**
  34538. * stop executing a render loop function and remove it from the execution array
  34539. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  34540. */
  34541. stopRenderLoop(renderFunction?: () => void): void;
  34542. /** @hidden */
  34543. _renderLoop(): void;
  34544. /**
  34545. * Gets the HTML canvas attached with the current webGL context
  34546. * @returns a HTML canvas
  34547. */
  34548. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  34549. /**
  34550. * Gets host window
  34551. * @returns the host window object
  34552. */
  34553. getHostWindow(): Nullable<Window>;
  34554. /**
  34555. * Gets the current render width
  34556. * @param useScreen defines if screen size must be used (or the current render target if any)
  34557. * @returns a number defining the current render width
  34558. */
  34559. getRenderWidth(useScreen?: boolean): number;
  34560. /**
  34561. * Gets the current render height
  34562. * @param useScreen defines if screen size must be used (or the current render target if any)
  34563. * @returns a number defining the current render height
  34564. */
  34565. getRenderHeight(useScreen?: boolean): number;
  34566. /**
  34567. * Can be used to override the current requestAnimationFrame requester.
  34568. * @hidden
  34569. */
  34570. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  34571. /**
  34572. * Register and execute a render loop. The engine can have more than one render function
  34573. * @param renderFunction defines the function to continuously execute
  34574. */
  34575. runRenderLoop(renderFunction: () => void): void;
  34576. /**
  34577. * Clear the current render buffer or the current render target (if any is set up)
  34578. * @param color defines the color to use
  34579. * @param backBuffer defines if the back buffer must be cleared
  34580. * @param depth defines if the depth buffer must be cleared
  34581. * @param stencil defines if the stencil buffer must be cleared
  34582. */
  34583. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  34584. private _viewportCached;
  34585. /** @hidden */
  34586. _viewport(x: number, y: number, width: number, height: number): void;
  34587. /**
  34588. * Set the WebGL's viewport
  34589. * @param viewport defines the viewport element to be used
  34590. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  34591. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  34592. */
  34593. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  34594. /**
  34595. * Begin a new frame
  34596. */
  34597. beginFrame(): void;
  34598. /**
  34599. * Enf the current frame
  34600. */
  34601. endFrame(): void;
  34602. /**
  34603. * Resize the view according to the canvas' size
  34604. */
  34605. resize(): void;
  34606. /**
  34607. * Force a specific size of the canvas
  34608. * @param width defines the new canvas' width
  34609. * @param height defines the new canvas' height
  34610. */
  34611. setSize(width: number, height: number): void;
  34612. /**
  34613. * Binds the frame buffer to the specified texture.
  34614. * @param texture The texture to render to or null for the default canvas
  34615. * @param faceIndex The face of the texture to render to in case of cube texture
  34616. * @param requiredWidth The width of the target to render to
  34617. * @param requiredHeight The height of the target to render to
  34618. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  34619. * @param lodLevel defines the lod level to bind to the frame buffer
  34620. * @param layer defines the 2d array index to bind to frame buffer to
  34621. */
  34622. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  34623. /** @hidden */
  34624. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  34625. /**
  34626. * Unbind the current render target texture from the webGL context
  34627. * @param texture defines the render target texture to unbind
  34628. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  34629. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  34630. */
  34631. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  34632. /**
  34633. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  34634. */
  34635. flushFramebuffer(): void;
  34636. /**
  34637. * Unbind the current render target and bind the default framebuffer
  34638. */
  34639. restoreDefaultFramebuffer(): void;
  34640. /** @hidden */
  34641. protected _resetVertexBufferBinding(): void;
  34642. /**
  34643. * Creates a vertex buffer
  34644. * @param data the data for the vertex buffer
  34645. * @returns the new WebGL static buffer
  34646. */
  34647. createVertexBuffer(data: DataArray): DataBuffer;
  34648. private _createVertexBuffer;
  34649. /**
  34650. * Creates a dynamic vertex buffer
  34651. * @param data the data for the dynamic vertex buffer
  34652. * @returns the new WebGL dynamic buffer
  34653. */
  34654. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  34655. protected _resetIndexBufferBinding(): void;
  34656. /**
  34657. * Creates a new index buffer
  34658. * @param indices defines the content of the index buffer
  34659. * @param updatable defines if the index buffer must be updatable
  34660. * @returns a new webGL buffer
  34661. */
  34662. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  34663. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  34664. /**
  34665. * Bind a webGL buffer to the webGL context
  34666. * @param buffer defines the buffer to bind
  34667. */
  34668. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  34669. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  34670. private bindBuffer;
  34671. /**
  34672. * update the bound buffer with the given data
  34673. * @param data defines the data to update
  34674. */
  34675. updateArrayBuffer(data: Float32Array): void;
  34676. private _vertexAttribPointer;
  34677. /** @hidden */
  34678. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  34679. private _bindVertexBuffersAttributes;
  34680. /**
  34681. * Records a vertex array object
  34682. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34683. * @param vertexBuffers defines the list of vertex buffers to store
  34684. * @param indexBuffer defines the index buffer to store
  34685. * @param effect defines the effect to store
  34686. * @returns the new vertex array object
  34687. */
  34688. recordVertexArrayObject(vertexBuffers: {
  34689. [key: string]: VertexBuffer;
  34690. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  34691. /**
  34692. * Bind a specific vertex array object
  34693. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34694. * @param vertexArrayObject defines the vertex array object to bind
  34695. * @param indexBuffer defines the index buffer to bind
  34696. */
  34697. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  34698. /**
  34699. * Bind webGl buffers directly to the webGL context
  34700. * @param vertexBuffer defines the vertex buffer to bind
  34701. * @param indexBuffer defines the index buffer to bind
  34702. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  34703. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  34704. * @param effect defines the effect associated with the vertex buffer
  34705. */
  34706. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  34707. private _unbindVertexArrayObject;
  34708. /**
  34709. * Bind a list of vertex buffers to the webGL context
  34710. * @param vertexBuffers defines the list of vertex buffers to bind
  34711. * @param indexBuffer defines the index buffer to bind
  34712. * @param effect defines the effect associated with the vertex buffers
  34713. */
  34714. bindBuffers(vertexBuffers: {
  34715. [key: string]: Nullable<VertexBuffer>;
  34716. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  34717. /**
  34718. * Unbind all instance attributes
  34719. */
  34720. unbindInstanceAttributes(): void;
  34721. /**
  34722. * Release and free the memory of a vertex array object
  34723. * @param vao defines the vertex array object to delete
  34724. */
  34725. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  34726. /** @hidden */
  34727. _releaseBuffer(buffer: DataBuffer): boolean;
  34728. protected _deleteBuffer(buffer: DataBuffer): void;
  34729. /**
  34730. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  34731. * @param instancesBuffer defines the webGL buffer to update and bind
  34732. * @param data defines the data to store in the buffer
  34733. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  34734. */
  34735. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  34736. /**
  34737. * Bind the content of a webGL buffer used with instantiation
  34738. * @param instancesBuffer defines the webGL buffer to bind
  34739. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  34740. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  34741. */
  34742. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  34743. /**
  34744. * Disable the instance attribute corresponding to the name in parameter
  34745. * @param name defines the name of the attribute to disable
  34746. */
  34747. disableInstanceAttributeByName(name: string): void;
  34748. /**
  34749. * Disable the instance attribute corresponding to the location in parameter
  34750. * @param attributeLocation defines the attribute location of the attribute to disable
  34751. */
  34752. disableInstanceAttribute(attributeLocation: number): void;
  34753. /**
  34754. * Disable the attribute corresponding to the location in parameter
  34755. * @param attributeLocation defines the attribute location of the attribute to disable
  34756. */
  34757. disableAttributeByIndex(attributeLocation: number): void;
  34758. /**
  34759. * Send a draw order
  34760. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34761. * @param indexStart defines the starting index
  34762. * @param indexCount defines the number of index to draw
  34763. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34764. */
  34765. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  34766. /**
  34767. * Draw a list of points
  34768. * @param verticesStart defines the index of first vertex to draw
  34769. * @param verticesCount defines the count of vertices to draw
  34770. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34771. */
  34772. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34773. /**
  34774. * Draw a list of unindexed primitives
  34775. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34776. * @param verticesStart defines the index of first vertex to draw
  34777. * @param verticesCount defines the count of vertices to draw
  34778. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34779. */
  34780. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34781. /**
  34782. * Draw a list of indexed primitives
  34783. * @param fillMode defines the primitive to use
  34784. * @param indexStart defines the starting index
  34785. * @param indexCount defines the number of index to draw
  34786. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34787. */
  34788. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  34789. /**
  34790. * Draw a list of unindexed primitives
  34791. * @param fillMode defines the primitive to use
  34792. * @param verticesStart defines the index of first vertex to draw
  34793. * @param verticesCount defines the count of vertices to draw
  34794. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34795. */
  34796. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34797. private _drawMode;
  34798. /** @hidden */
  34799. protected _reportDrawCall(): void;
  34800. /** @hidden */
  34801. _releaseEffect(effect: Effect): void;
  34802. /** @hidden */
  34803. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34804. /**
  34805. * Create a new effect (used to store vertex/fragment shaders)
  34806. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  34807. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  34808. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  34809. * @param samplers defines an array of string used to represent textures
  34810. * @param defines defines the string containing the defines to use to compile the shaders
  34811. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  34812. * @param onCompiled defines a function to call when the effect creation is successful
  34813. * @param onError defines a function to call when the effect creation has failed
  34814. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  34815. * @returns the new Effect
  34816. */
  34817. 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;
  34818. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  34819. private _compileShader;
  34820. private _compileRawShader;
  34821. /** @hidden */
  34822. _getShaderSource(shader: WebGLShader): Nullable<string>;
  34823. /**
  34824. * Directly creates a webGL program
  34825. * @param pipelineContext defines the pipeline context to attach to
  34826. * @param vertexCode defines the vertex shader code to use
  34827. * @param fragmentCode defines the fragment shader code to use
  34828. * @param context defines the webGL context to use (if not set, the current one will be used)
  34829. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34830. * @returns the new webGL program
  34831. */
  34832. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34833. /**
  34834. * Creates a webGL program
  34835. * @param pipelineContext defines the pipeline context to attach to
  34836. * @param vertexCode defines the vertex shader code to use
  34837. * @param fragmentCode defines the fragment shader code to use
  34838. * @param defines defines the string containing the defines to use to compile the shaders
  34839. * @param context defines the webGL context to use (if not set, the current one will be used)
  34840. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34841. * @returns the new webGL program
  34842. */
  34843. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34844. /**
  34845. * Creates a new pipeline context
  34846. * @returns the new pipeline
  34847. */
  34848. createPipelineContext(): IPipelineContext;
  34849. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34850. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  34851. /** @hidden */
  34852. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  34853. /** @hidden */
  34854. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  34855. /** @hidden */
  34856. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  34857. /**
  34858. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  34859. * @param pipelineContext defines the pipeline context to use
  34860. * @param uniformsNames defines the list of uniform names
  34861. * @returns an array of webGL uniform locations
  34862. */
  34863. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  34864. /**
  34865. * Gets the lsit of active attributes for a given webGL program
  34866. * @param pipelineContext defines the pipeline context to use
  34867. * @param attributesNames defines the list of attribute names to get
  34868. * @returns an array of indices indicating the offset of each attribute
  34869. */
  34870. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  34871. /**
  34872. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  34873. * @param effect defines the effect to activate
  34874. */
  34875. enableEffect(effect: Nullable<Effect>): void;
  34876. /**
  34877. * Set the value of an uniform to a number (int)
  34878. * @param uniform defines the webGL uniform location where to store the value
  34879. * @param value defines the int number to store
  34880. */
  34881. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  34882. /**
  34883. * Set the value of an uniform to an array of int32
  34884. * @param uniform defines the webGL uniform location where to store the value
  34885. * @param array defines the array of int32 to store
  34886. */
  34887. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34888. /**
  34889. * Set the value of an uniform to an array of int32 (stored as vec2)
  34890. * @param uniform defines the webGL uniform location where to store the value
  34891. * @param array defines the array of int32 to store
  34892. */
  34893. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34894. /**
  34895. * Set the value of an uniform to an array of int32 (stored as vec3)
  34896. * @param uniform defines the webGL uniform location where to store the value
  34897. * @param array defines the array of int32 to store
  34898. */
  34899. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34900. /**
  34901. * Set the value of an uniform to an array of int32 (stored as vec4)
  34902. * @param uniform defines the webGL uniform location where to store the value
  34903. * @param array defines the array of int32 to store
  34904. */
  34905. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34906. /**
  34907. * Set the value of an uniform to an array of number
  34908. * @param uniform defines the webGL uniform location where to store the value
  34909. * @param array defines the array of number to store
  34910. */
  34911. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34912. /**
  34913. * Set the value of an uniform to an array of number (stored as vec2)
  34914. * @param uniform defines the webGL uniform location where to store the value
  34915. * @param array defines the array of number to store
  34916. */
  34917. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34918. /**
  34919. * Set the value of an uniform to an array of number (stored as vec3)
  34920. * @param uniform defines the webGL uniform location where to store the value
  34921. * @param array defines the array of number to store
  34922. */
  34923. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34924. /**
  34925. * Set the value of an uniform to an array of number (stored as vec4)
  34926. * @param uniform defines the webGL uniform location where to store the value
  34927. * @param array defines the array of number to store
  34928. */
  34929. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34930. /**
  34931. * Set the value of an uniform to an array of float32 (stored as matrices)
  34932. * @param uniform defines the webGL uniform location where to store the value
  34933. * @param matrices defines the array of float32 to store
  34934. */
  34935. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  34936. /**
  34937. * Set the value of an uniform to a matrix (3x3)
  34938. * @param uniform defines the webGL uniform location where to store the value
  34939. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  34940. */
  34941. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  34942. /**
  34943. * Set the value of an uniform to a matrix (2x2)
  34944. * @param uniform defines the webGL uniform location where to store the value
  34945. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  34946. */
  34947. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  34948. /**
  34949. * Set the value of an uniform to a number (float)
  34950. * @param uniform defines the webGL uniform location where to store the value
  34951. * @param value defines the float number to store
  34952. */
  34953. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  34954. /**
  34955. * Set the value of an uniform to a vec2
  34956. * @param uniform defines the webGL uniform location where to store the value
  34957. * @param x defines the 1st component of the value
  34958. * @param y defines the 2nd component of the value
  34959. */
  34960. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  34961. /**
  34962. * Set the value of an uniform to a vec3
  34963. * @param uniform defines the webGL uniform location where to store the value
  34964. * @param x defines the 1st component of the value
  34965. * @param y defines the 2nd component of the value
  34966. * @param z defines the 3rd component of the value
  34967. */
  34968. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  34969. /**
  34970. * Set the value of an uniform to a vec4
  34971. * @param uniform defines the webGL uniform location where to store the value
  34972. * @param x defines the 1st component of the value
  34973. * @param y defines the 2nd component of the value
  34974. * @param z defines the 3rd component of the value
  34975. * @param w defines the 4th component of the value
  34976. */
  34977. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  34978. /**
  34979. * Apply all cached states (depth, culling, stencil and alpha)
  34980. */
  34981. applyStates(): void;
  34982. /**
  34983. * Enable or disable color writing
  34984. * @param enable defines the state to set
  34985. */
  34986. setColorWrite(enable: boolean): void;
  34987. /**
  34988. * Gets a boolean indicating if color writing is enabled
  34989. * @returns the current color writing state
  34990. */
  34991. getColorWrite(): boolean;
  34992. /**
  34993. * Gets the depth culling state manager
  34994. */
  34995. get depthCullingState(): DepthCullingState;
  34996. /**
  34997. * Gets the alpha state manager
  34998. */
  34999. get alphaState(): AlphaState;
  35000. /**
  35001. * Gets the stencil state manager
  35002. */
  35003. get stencilState(): StencilState;
  35004. /**
  35005. * Clears the list of texture accessible through engine.
  35006. * This can help preventing texture load conflict due to name collision.
  35007. */
  35008. clearInternalTexturesCache(): void;
  35009. /**
  35010. * Force the entire cache to be cleared
  35011. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  35012. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  35013. */
  35014. wipeCaches(bruteForce?: boolean): void;
  35015. /** @hidden */
  35016. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  35017. min: number;
  35018. mag: number;
  35019. };
  35020. /** @hidden */
  35021. _createTexture(): WebGLTexture;
  35022. /**
  35023. * Usually called from Texture.ts.
  35024. * Passed information to create a WebGLTexture
  35025. * @param url defines a value which contains one of the following:
  35026. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  35027. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  35028. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  35029. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  35030. * @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)
  35031. * @param scene needed for loading to the correct scene
  35032. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  35033. * @param onLoad optional callback to be called upon successful completion
  35034. * @param onError optional callback to be called upon failure
  35035. * @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
  35036. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  35037. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  35038. * @param forcedExtension defines the extension to use to pick the right loader
  35039. * @param mimeType defines an optional mime type
  35040. * @returns a InternalTexture for assignment back into BABYLON.Texture
  35041. */
  35042. 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;
  35043. /**
  35044. * Loads an image as an HTMLImageElement.
  35045. * @param input url string, ArrayBuffer, or Blob to load
  35046. * @param onLoad callback called when the image successfully loads
  35047. * @param onError callback called when the image fails to load
  35048. * @param offlineProvider offline provider for caching
  35049. * @param mimeType optional mime type
  35050. * @returns the HTMLImageElement of the loaded image
  35051. * @hidden
  35052. */
  35053. 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>;
  35054. /**
  35055. * @hidden
  35056. */
  35057. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  35058. private _unpackFlipYCached;
  35059. /**
  35060. * In case you are sharing the context with other applications, it might
  35061. * be interested to not cache the unpack flip y state to ensure a consistent
  35062. * value would be set.
  35063. */
  35064. enableUnpackFlipYCached: boolean;
  35065. /** @hidden */
  35066. _unpackFlipY(value: boolean): void;
  35067. /** @hidden */
  35068. _getUnpackAlignement(): number;
  35069. private _getTextureTarget;
  35070. /**
  35071. * Update the sampling mode of a given texture
  35072. * @param samplingMode defines the required sampling mode
  35073. * @param texture defines the texture to update
  35074. * @param generateMipMaps defines whether to generate mipmaps for the texture
  35075. */
  35076. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  35077. /**
  35078. * Update the sampling mode of a given texture
  35079. * @param texture defines the texture to update
  35080. * @param wrapU defines the texture wrap mode of the u coordinates
  35081. * @param wrapV defines the texture wrap mode of the v coordinates
  35082. * @param wrapR defines the texture wrap mode of the r coordinates
  35083. */
  35084. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  35085. /** @hidden */
  35086. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  35087. width: number;
  35088. height: number;
  35089. layers?: number;
  35090. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  35091. /** @hidden */
  35092. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  35093. /** @hidden */
  35094. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  35095. /**
  35096. * Update a portion of an internal texture
  35097. * @param texture defines the texture to update
  35098. * @param imageData defines the data to store into the texture
  35099. * @param xOffset defines the x coordinates of the update rectangle
  35100. * @param yOffset defines the y coordinates of the update rectangle
  35101. * @param width defines the width of the update rectangle
  35102. * @param height defines the height of the update rectangle
  35103. * @param faceIndex defines the face index if texture is a cube (0 by default)
  35104. * @param lod defines the lod level to update (0 by default)
  35105. */
  35106. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  35107. /** @hidden */
  35108. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  35109. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  35110. private _prepareWebGLTexture;
  35111. /** @hidden */
  35112. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  35113. private _getDepthStencilBuffer;
  35114. /** @hidden */
  35115. _releaseFramebufferObjects(texture: InternalTexture): void;
  35116. /** @hidden */
  35117. _releaseTexture(texture: InternalTexture): void;
  35118. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  35119. protected _setProgram(program: WebGLProgram): void;
  35120. protected _boundUniforms: {
  35121. [key: number]: WebGLUniformLocation;
  35122. };
  35123. /**
  35124. * Binds an effect to the webGL context
  35125. * @param effect defines the effect to bind
  35126. */
  35127. bindSamplers(effect: Effect): void;
  35128. private _activateCurrentTexture;
  35129. /** @hidden */
  35130. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  35131. /** @hidden */
  35132. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  35133. /**
  35134. * Unbind all textures from the webGL context
  35135. */
  35136. unbindAllTextures(): void;
  35137. /**
  35138. * Sets a texture to the according uniform.
  35139. * @param channel The texture channel
  35140. * @param uniform The uniform to set
  35141. * @param texture The texture to apply
  35142. */
  35143. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  35144. private _bindSamplerUniformToChannel;
  35145. private _getTextureWrapMode;
  35146. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  35147. /**
  35148. * Sets an array of texture to the webGL context
  35149. * @param channel defines the channel where the texture array must be set
  35150. * @param uniform defines the associated uniform location
  35151. * @param textures defines the array of textures to bind
  35152. */
  35153. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  35154. /** @hidden */
  35155. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  35156. private _setTextureParameterFloat;
  35157. private _setTextureParameterInteger;
  35158. /**
  35159. * Unbind all vertex attributes from the webGL context
  35160. */
  35161. unbindAllAttributes(): void;
  35162. /**
  35163. * 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
  35164. */
  35165. releaseEffects(): void;
  35166. /**
  35167. * Dispose and release all associated resources
  35168. */
  35169. dispose(): void;
  35170. /**
  35171. * Attach a new callback raised when context lost event is fired
  35172. * @param callback defines the callback to call
  35173. */
  35174. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  35175. /**
  35176. * Attach a new callback raised when context restored event is fired
  35177. * @param callback defines the callback to call
  35178. */
  35179. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  35180. /**
  35181. * Get the current error code of the webGL context
  35182. * @returns the error code
  35183. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  35184. */
  35185. getError(): number;
  35186. private _canRenderToFloatFramebuffer;
  35187. private _canRenderToHalfFloatFramebuffer;
  35188. private _canRenderToFramebuffer;
  35189. /** @hidden */
  35190. _getWebGLTextureType(type: number): number;
  35191. /** @hidden */
  35192. _getInternalFormat(format: number): number;
  35193. /** @hidden */
  35194. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  35195. /** @hidden */
  35196. _getRGBAMultiSampleBufferFormat(type: number): number;
  35197. /** @hidden */
  35198. _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;
  35199. /**
  35200. * Loads a file from a url
  35201. * @param url url to load
  35202. * @param onSuccess callback called when the file successfully loads
  35203. * @param onProgress callback called while file is loading (if the server supports this mode)
  35204. * @param offlineProvider defines the offline provider for caching
  35205. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35206. * @param onError callback called when the file fails to load
  35207. * @returns a file request object
  35208. * @hidden
  35209. */
  35210. 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;
  35211. /**
  35212. * Reads pixels from the current frame buffer. Please note that this function can be slow
  35213. * @param x defines the x coordinate of the rectangle where pixels must be read
  35214. * @param y defines the y coordinate of the rectangle where pixels must be read
  35215. * @param width defines the width of the rectangle where pixels must be read
  35216. * @param height defines the height of the rectangle where pixels must be read
  35217. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  35218. * @returns a Uint8Array containing RGBA colors
  35219. */
  35220. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  35221. private static _isSupported;
  35222. /**
  35223. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  35224. * @returns true if the engine can be created
  35225. * @ignorenaming
  35226. */
  35227. static isSupported(): boolean;
  35228. /**
  35229. * Find the next highest power of two.
  35230. * @param x Number to start search from.
  35231. * @return Next highest power of two.
  35232. */
  35233. static CeilingPOT(x: number): number;
  35234. /**
  35235. * Find the next lowest power of two.
  35236. * @param x Number to start search from.
  35237. * @return Next lowest power of two.
  35238. */
  35239. static FloorPOT(x: number): number;
  35240. /**
  35241. * Find the nearest power of two.
  35242. * @param x Number to start search from.
  35243. * @return Next nearest power of two.
  35244. */
  35245. static NearestPOT(x: number): number;
  35246. /**
  35247. * Get the closest exponent of two
  35248. * @param value defines the value to approximate
  35249. * @param max defines the maximum value to return
  35250. * @param mode defines how to define the closest value
  35251. * @returns closest exponent of two of the given value
  35252. */
  35253. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  35254. /**
  35255. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  35256. * @param func - the function to be called
  35257. * @param requester - the object that will request the next frame. Falls back to window.
  35258. * @returns frame number
  35259. */
  35260. static QueueNewFrame(func: () => void, requester?: any): number;
  35261. /**
  35262. * Gets host document
  35263. * @returns the host document object
  35264. */
  35265. getHostDocument(): Nullable<Document>;
  35266. }
  35267. }
  35268. declare module BABYLON {
  35269. /**
  35270. * Class representing spherical harmonics coefficients to the 3rd degree
  35271. */
  35272. export class SphericalHarmonics {
  35273. /**
  35274. * Defines whether or not the harmonics have been prescaled for rendering.
  35275. */
  35276. preScaled: boolean;
  35277. /**
  35278. * The l0,0 coefficients of the spherical harmonics
  35279. */
  35280. l00: Vector3;
  35281. /**
  35282. * The l1,-1 coefficients of the spherical harmonics
  35283. */
  35284. l1_1: Vector3;
  35285. /**
  35286. * The l1,0 coefficients of the spherical harmonics
  35287. */
  35288. l10: Vector3;
  35289. /**
  35290. * The l1,1 coefficients of the spherical harmonics
  35291. */
  35292. l11: Vector3;
  35293. /**
  35294. * The l2,-2 coefficients of the spherical harmonics
  35295. */
  35296. l2_2: Vector3;
  35297. /**
  35298. * The l2,-1 coefficients of the spherical harmonics
  35299. */
  35300. l2_1: Vector3;
  35301. /**
  35302. * The l2,0 coefficients of the spherical harmonics
  35303. */
  35304. l20: Vector3;
  35305. /**
  35306. * The l2,1 coefficients of the spherical harmonics
  35307. */
  35308. l21: Vector3;
  35309. /**
  35310. * The l2,2 coefficients of the spherical harmonics
  35311. */
  35312. l22: Vector3;
  35313. /**
  35314. * Adds a light to the spherical harmonics
  35315. * @param direction the direction of the light
  35316. * @param color the color of the light
  35317. * @param deltaSolidAngle the delta solid angle of the light
  35318. */
  35319. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  35320. /**
  35321. * Scales the spherical harmonics by the given amount
  35322. * @param scale the amount to scale
  35323. */
  35324. scaleInPlace(scale: number): void;
  35325. /**
  35326. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  35327. *
  35328. * ```
  35329. * E_lm = A_l * L_lm
  35330. * ```
  35331. *
  35332. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  35333. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  35334. * the scaling factors are given in equation 9.
  35335. */
  35336. convertIncidentRadianceToIrradiance(): void;
  35337. /**
  35338. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  35339. *
  35340. * ```
  35341. * L = (1/pi) * E * rho
  35342. * ```
  35343. *
  35344. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  35345. */
  35346. convertIrradianceToLambertianRadiance(): void;
  35347. /**
  35348. * Integrates the reconstruction coefficients directly in to the SH preventing further
  35349. * required operations at run time.
  35350. *
  35351. * This is simply done by scaling back the SH with Ylm constants parameter.
  35352. * The trigonometric part being applied by the shader at run time.
  35353. */
  35354. preScaleForRendering(): void;
  35355. /**
  35356. * Constructs a spherical harmonics from an array.
  35357. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  35358. * @returns the spherical harmonics
  35359. */
  35360. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  35361. /**
  35362. * Gets the spherical harmonics from polynomial
  35363. * @param polynomial the spherical polynomial
  35364. * @returns the spherical harmonics
  35365. */
  35366. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  35367. }
  35368. /**
  35369. * Class representing spherical polynomial coefficients to the 3rd degree
  35370. */
  35371. export class SphericalPolynomial {
  35372. private _harmonics;
  35373. /**
  35374. * The spherical harmonics used to create the polynomials.
  35375. */
  35376. get preScaledHarmonics(): SphericalHarmonics;
  35377. /**
  35378. * The x coefficients of the spherical polynomial
  35379. */
  35380. x: Vector3;
  35381. /**
  35382. * The y coefficients of the spherical polynomial
  35383. */
  35384. y: Vector3;
  35385. /**
  35386. * The z coefficients of the spherical polynomial
  35387. */
  35388. z: Vector3;
  35389. /**
  35390. * The xx coefficients of the spherical polynomial
  35391. */
  35392. xx: Vector3;
  35393. /**
  35394. * The yy coefficients of the spherical polynomial
  35395. */
  35396. yy: Vector3;
  35397. /**
  35398. * The zz coefficients of the spherical polynomial
  35399. */
  35400. zz: Vector3;
  35401. /**
  35402. * The xy coefficients of the spherical polynomial
  35403. */
  35404. xy: Vector3;
  35405. /**
  35406. * The yz coefficients of the spherical polynomial
  35407. */
  35408. yz: Vector3;
  35409. /**
  35410. * The zx coefficients of the spherical polynomial
  35411. */
  35412. zx: Vector3;
  35413. /**
  35414. * Adds an ambient color to the spherical polynomial
  35415. * @param color the color to add
  35416. */
  35417. addAmbient(color: Color3): void;
  35418. /**
  35419. * Scales the spherical polynomial by the given amount
  35420. * @param scale the amount to scale
  35421. */
  35422. scaleInPlace(scale: number): void;
  35423. /**
  35424. * Gets the spherical polynomial from harmonics
  35425. * @param harmonics the spherical harmonics
  35426. * @returns the spherical polynomial
  35427. */
  35428. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  35429. /**
  35430. * Constructs a spherical polynomial from an array.
  35431. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  35432. * @returns the spherical polynomial
  35433. */
  35434. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  35435. }
  35436. }
  35437. declare module BABYLON {
  35438. /**
  35439. * Defines the source of the internal texture
  35440. */
  35441. export enum InternalTextureSource {
  35442. /**
  35443. * The source of the texture data is unknown
  35444. */
  35445. Unknown = 0,
  35446. /**
  35447. * Texture data comes from an URL
  35448. */
  35449. Url = 1,
  35450. /**
  35451. * Texture data is only used for temporary storage
  35452. */
  35453. Temp = 2,
  35454. /**
  35455. * Texture data comes from raw data (ArrayBuffer)
  35456. */
  35457. Raw = 3,
  35458. /**
  35459. * Texture content is dynamic (video or dynamic texture)
  35460. */
  35461. Dynamic = 4,
  35462. /**
  35463. * Texture content is generated by rendering to it
  35464. */
  35465. RenderTarget = 5,
  35466. /**
  35467. * Texture content is part of a multi render target process
  35468. */
  35469. MultiRenderTarget = 6,
  35470. /**
  35471. * Texture data comes from a cube data file
  35472. */
  35473. Cube = 7,
  35474. /**
  35475. * Texture data comes from a raw cube data
  35476. */
  35477. CubeRaw = 8,
  35478. /**
  35479. * Texture data come from a prefiltered cube data file
  35480. */
  35481. CubePrefiltered = 9,
  35482. /**
  35483. * Texture content is raw 3D data
  35484. */
  35485. Raw3D = 10,
  35486. /**
  35487. * Texture content is raw 2D array data
  35488. */
  35489. Raw2DArray = 11,
  35490. /**
  35491. * Texture content is a depth texture
  35492. */
  35493. Depth = 12,
  35494. /**
  35495. * Texture data comes from a raw cube data encoded with RGBD
  35496. */
  35497. CubeRawRGBD = 13
  35498. }
  35499. /**
  35500. * Class used to store data associated with WebGL texture data for the engine
  35501. * This class should not be used directly
  35502. */
  35503. export class InternalTexture {
  35504. /** @hidden */
  35505. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  35506. /**
  35507. * Defines if the texture is ready
  35508. */
  35509. isReady: boolean;
  35510. /**
  35511. * Defines if the texture is a cube texture
  35512. */
  35513. isCube: boolean;
  35514. /**
  35515. * Defines if the texture contains 3D data
  35516. */
  35517. is3D: boolean;
  35518. /**
  35519. * Defines if the texture contains 2D array data
  35520. */
  35521. is2DArray: boolean;
  35522. /**
  35523. * Defines if the texture contains multiview data
  35524. */
  35525. isMultiview: boolean;
  35526. /**
  35527. * Gets the URL used to load this texture
  35528. */
  35529. url: string;
  35530. /**
  35531. * Gets the sampling mode of the texture
  35532. */
  35533. samplingMode: number;
  35534. /**
  35535. * Gets a boolean indicating if the texture needs mipmaps generation
  35536. */
  35537. generateMipMaps: boolean;
  35538. /**
  35539. * Gets the number of samples used by the texture (WebGL2+ only)
  35540. */
  35541. samples: number;
  35542. /**
  35543. * Gets the type of the texture (int, float...)
  35544. */
  35545. type: number;
  35546. /**
  35547. * Gets the format of the texture (RGB, RGBA...)
  35548. */
  35549. format: number;
  35550. /**
  35551. * Observable called when the texture is loaded
  35552. */
  35553. onLoadedObservable: Observable<InternalTexture>;
  35554. /**
  35555. * Gets the width of the texture
  35556. */
  35557. width: number;
  35558. /**
  35559. * Gets the height of the texture
  35560. */
  35561. height: number;
  35562. /**
  35563. * Gets the depth of the texture
  35564. */
  35565. depth: number;
  35566. /**
  35567. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  35568. */
  35569. baseWidth: number;
  35570. /**
  35571. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  35572. */
  35573. baseHeight: number;
  35574. /**
  35575. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  35576. */
  35577. baseDepth: number;
  35578. /**
  35579. * Gets a boolean indicating if the texture is inverted on Y axis
  35580. */
  35581. invertY: boolean;
  35582. /** @hidden */
  35583. _invertVScale: boolean;
  35584. /** @hidden */
  35585. _associatedChannel: number;
  35586. /** @hidden */
  35587. _source: InternalTextureSource;
  35588. /** @hidden */
  35589. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  35590. /** @hidden */
  35591. _bufferView: Nullable<ArrayBufferView>;
  35592. /** @hidden */
  35593. _bufferViewArray: Nullable<ArrayBufferView[]>;
  35594. /** @hidden */
  35595. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  35596. /** @hidden */
  35597. _size: number;
  35598. /** @hidden */
  35599. _extension: string;
  35600. /** @hidden */
  35601. _files: Nullable<string[]>;
  35602. /** @hidden */
  35603. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35604. /** @hidden */
  35605. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35606. /** @hidden */
  35607. _framebuffer: Nullable<WebGLFramebuffer>;
  35608. /** @hidden */
  35609. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  35610. /** @hidden */
  35611. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  35612. /** @hidden */
  35613. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  35614. /** @hidden */
  35615. _attachments: Nullable<number[]>;
  35616. /** @hidden */
  35617. _cachedCoordinatesMode: Nullable<number>;
  35618. /** @hidden */
  35619. _cachedWrapU: Nullable<number>;
  35620. /** @hidden */
  35621. _cachedWrapV: Nullable<number>;
  35622. /** @hidden */
  35623. _cachedWrapR: Nullable<number>;
  35624. /** @hidden */
  35625. _cachedAnisotropicFilteringLevel: Nullable<number>;
  35626. /** @hidden */
  35627. _isDisabled: boolean;
  35628. /** @hidden */
  35629. _compression: Nullable<string>;
  35630. /** @hidden */
  35631. _generateStencilBuffer: boolean;
  35632. /** @hidden */
  35633. _generateDepthBuffer: boolean;
  35634. /** @hidden */
  35635. _comparisonFunction: number;
  35636. /** @hidden */
  35637. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  35638. /** @hidden */
  35639. _lodGenerationScale: number;
  35640. /** @hidden */
  35641. _lodGenerationOffset: number;
  35642. /** @hidden */
  35643. _depthStencilTexture: Nullable<InternalTexture>;
  35644. /** @hidden */
  35645. _colorTextureArray: Nullable<WebGLTexture>;
  35646. /** @hidden */
  35647. _depthStencilTextureArray: Nullable<WebGLTexture>;
  35648. /** @hidden */
  35649. _lodTextureHigh: Nullable<BaseTexture>;
  35650. /** @hidden */
  35651. _lodTextureMid: Nullable<BaseTexture>;
  35652. /** @hidden */
  35653. _lodTextureLow: Nullable<BaseTexture>;
  35654. /** @hidden */
  35655. _isRGBD: boolean;
  35656. /** @hidden */
  35657. _linearSpecularLOD: boolean;
  35658. /** @hidden */
  35659. _irradianceTexture: Nullable<BaseTexture>;
  35660. /** @hidden */
  35661. _webGLTexture: Nullable<WebGLTexture>;
  35662. /** @hidden */
  35663. _references: number;
  35664. private _engine;
  35665. /**
  35666. * Gets the Engine the texture belongs to.
  35667. * @returns The babylon engine
  35668. */
  35669. getEngine(): ThinEngine;
  35670. /**
  35671. * Gets the data source type of the texture
  35672. */
  35673. get source(): InternalTextureSource;
  35674. /**
  35675. * Creates a new InternalTexture
  35676. * @param engine defines the engine to use
  35677. * @param source defines the type of data that will be used
  35678. * @param delayAllocation if the texture allocation should be delayed (default: false)
  35679. */
  35680. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  35681. /**
  35682. * Increments the number of references (ie. the number of Texture that point to it)
  35683. */
  35684. incrementReferences(): void;
  35685. /**
  35686. * Change the size of the texture (not the size of the content)
  35687. * @param width defines the new width
  35688. * @param height defines the new height
  35689. * @param depth defines the new depth (1 by default)
  35690. */
  35691. updateSize(width: int, height: int, depth?: int): void;
  35692. /** @hidden */
  35693. _rebuild(): void;
  35694. /** @hidden */
  35695. _swapAndDie(target: InternalTexture): void;
  35696. /**
  35697. * Dispose the current allocated resources
  35698. */
  35699. dispose(): void;
  35700. }
  35701. }
  35702. declare module BABYLON {
  35703. /**
  35704. * Class used to work with sound analyzer using fast fourier transform (FFT)
  35705. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35706. */
  35707. export class Analyser {
  35708. /**
  35709. * Gets or sets the smoothing
  35710. * @ignorenaming
  35711. */
  35712. SMOOTHING: number;
  35713. /**
  35714. * Gets or sets the FFT table size
  35715. * @ignorenaming
  35716. */
  35717. FFT_SIZE: number;
  35718. /**
  35719. * Gets or sets the bar graph amplitude
  35720. * @ignorenaming
  35721. */
  35722. BARGRAPHAMPLITUDE: number;
  35723. /**
  35724. * Gets or sets the position of the debug canvas
  35725. * @ignorenaming
  35726. */
  35727. DEBUGCANVASPOS: {
  35728. x: number;
  35729. y: number;
  35730. };
  35731. /**
  35732. * Gets or sets the debug canvas size
  35733. * @ignorenaming
  35734. */
  35735. DEBUGCANVASSIZE: {
  35736. width: number;
  35737. height: number;
  35738. };
  35739. private _byteFreqs;
  35740. private _byteTime;
  35741. private _floatFreqs;
  35742. private _webAudioAnalyser;
  35743. private _debugCanvas;
  35744. private _debugCanvasContext;
  35745. private _scene;
  35746. private _registerFunc;
  35747. private _audioEngine;
  35748. /**
  35749. * Creates a new analyser
  35750. * @param scene defines hosting scene
  35751. */
  35752. constructor(scene: Scene);
  35753. /**
  35754. * Get the number of data values you will have to play with for the visualization
  35755. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  35756. * @returns a number
  35757. */
  35758. getFrequencyBinCount(): number;
  35759. /**
  35760. * Gets the current frequency data as a byte array
  35761. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35762. * @returns a Uint8Array
  35763. */
  35764. getByteFrequencyData(): Uint8Array;
  35765. /**
  35766. * Gets the current waveform as a byte array
  35767. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  35768. * @returns a Uint8Array
  35769. */
  35770. getByteTimeDomainData(): Uint8Array;
  35771. /**
  35772. * Gets the current frequency data as a float array
  35773. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35774. * @returns a Float32Array
  35775. */
  35776. getFloatFrequencyData(): Float32Array;
  35777. /**
  35778. * Renders the debug canvas
  35779. */
  35780. drawDebugCanvas(): void;
  35781. /**
  35782. * Stops rendering the debug canvas and removes it
  35783. */
  35784. stopDebugCanvas(): void;
  35785. /**
  35786. * Connects two audio nodes
  35787. * @param inputAudioNode defines first node to connect
  35788. * @param outputAudioNode defines second node to connect
  35789. */
  35790. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  35791. /**
  35792. * Releases all associated resources
  35793. */
  35794. dispose(): void;
  35795. }
  35796. }
  35797. declare module BABYLON {
  35798. /**
  35799. * This represents an audio engine and it is responsible
  35800. * to play, synchronize and analyse sounds throughout the application.
  35801. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35802. */
  35803. export interface IAudioEngine extends IDisposable {
  35804. /**
  35805. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35806. */
  35807. readonly canUseWebAudio: boolean;
  35808. /**
  35809. * Gets the current AudioContext if available.
  35810. */
  35811. readonly audioContext: Nullable<AudioContext>;
  35812. /**
  35813. * The master gain node defines the global audio volume of your audio engine.
  35814. */
  35815. readonly masterGain: GainNode;
  35816. /**
  35817. * Gets whether or not mp3 are supported by your browser.
  35818. */
  35819. readonly isMP3supported: boolean;
  35820. /**
  35821. * Gets whether or not ogg are supported by your browser.
  35822. */
  35823. readonly isOGGsupported: boolean;
  35824. /**
  35825. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35826. * @ignoreNaming
  35827. */
  35828. WarnedWebAudioUnsupported: boolean;
  35829. /**
  35830. * Defines if the audio engine relies on a custom unlocked button.
  35831. * In this case, the embedded button will not be displayed.
  35832. */
  35833. useCustomUnlockedButton: boolean;
  35834. /**
  35835. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  35836. */
  35837. readonly unlocked: boolean;
  35838. /**
  35839. * Event raised when audio has been unlocked on the browser.
  35840. */
  35841. onAudioUnlockedObservable: Observable<AudioEngine>;
  35842. /**
  35843. * Event raised when audio has been locked on the browser.
  35844. */
  35845. onAudioLockedObservable: Observable<AudioEngine>;
  35846. /**
  35847. * Flags the audio engine in Locked state.
  35848. * This happens due to new browser policies preventing audio to autoplay.
  35849. */
  35850. lock(): void;
  35851. /**
  35852. * Unlocks the audio engine once a user action has been done on the dom.
  35853. * This is helpful to resume play once browser policies have been satisfied.
  35854. */
  35855. unlock(): void;
  35856. /**
  35857. * Gets the global volume sets on the master gain.
  35858. * @returns the global volume if set or -1 otherwise
  35859. */
  35860. getGlobalVolume(): number;
  35861. /**
  35862. * Sets the global volume of your experience (sets on the master gain).
  35863. * @param newVolume Defines the new global volume of the application
  35864. */
  35865. setGlobalVolume(newVolume: number): void;
  35866. /**
  35867. * Connect the audio engine to an audio analyser allowing some amazing
  35868. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35869. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35870. * @param analyser The analyser to connect to the engine
  35871. */
  35872. connectToAnalyser(analyser: Analyser): void;
  35873. }
  35874. /**
  35875. * This represents the default audio engine used in babylon.
  35876. * It is responsible to play, synchronize and analyse sounds throughout the application.
  35877. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35878. */
  35879. export class AudioEngine implements IAudioEngine {
  35880. private _audioContext;
  35881. private _audioContextInitialized;
  35882. private _muteButton;
  35883. private _hostElement;
  35884. /**
  35885. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35886. */
  35887. canUseWebAudio: boolean;
  35888. /**
  35889. * The master gain node defines the global audio volume of your audio engine.
  35890. */
  35891. masterGain: GainNode;
  35892. /**
  35893. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35894. * @ignoreNaming
  35895. */
  35896. WarnedWebAudioUnsupported: boolean;
  35897. /**
  35898. * Gets whether or not mp3 are supported by your browser.
  35899. */
  35900. isMP3supported: boolean;
  35901. /**
  35902. * Gets whether or not ogg are supported by your browser.
  35903. */
  35904. isOGGsupported: boolean;
  35905. /**
  35906. * Gets whether audio has been unlocked on the device.
  35907. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  35908. * a user interaction has happened.
  35909. */
  35910. unlocked: boolean;
  35911. /**
  35912. * Defines if the audio engine relies on a custom unlocked button.
  35913. * In this case, the embedded button will not be displayed.
  35914. */
  35915. useCustomUnlockedButton: boolean;
  35916. /**
  35917. * Event raised when audio has been unlocked on the browser.
  35918. */
  35919. onAudioUnlockedObservable: Observable<AudioEngine>;
  35920. /**
  35921. * Event raised when audio has been locked on the browser.
  35922. */
  35923. onAudioLockedObservable: Observable<AudioEngine>;
  35924. /**
  35925. * Gets the current AudioContext if available.
  35926. */
  35927. get audioContext(): Nullable<AudioContext>;
  35928. private _connectedAnalyser;
  35929. /**
  35930. * Instantiates a new audio engine.
  35931. *
  35932. * There should be only one per page as some browsers restrict the number
  35933. * of audio contexts you can create.
  35934. * @param hostElement defines the host element where to display the mute icon if necessary
  35935. */
  35936. constructor(hostElement?: Nullable<HTMLElement>);
  35937. /**
  35938. * Flags the audio engine in Locked state.
  35939. * This happens due to new browser policies preventing audio to autoplay.
  35940. */
  35941. lock(): void;
  35942. /**
  35943. * Unlocks the audio engine once a user action has been done on the dom.
  35944. * This is helpful to resume play once browser policies have been satisfied.
  35945. */
  35946. unlock(): void;
  35947. private _resumeAudioContext;
  35948. private _initializeAudioContext;
  35949. private _tryToRun;
  35950. private _triggerRunningState;
  35951. private _triggerSuspendedState;
  35952. private _displayMuteButton;
  35953. private _moveButtonToTopLeft;
  35954. private _onResize;
  35955. private _hideMuteButton;
  35956. /**
  35957. * Destroy and release the resources associated with the audio ccontext.
  35958. */
  35959. dispose(): void;
  35960. /**
  35961. * Gets the global volume sets on the master gain.
  35962. * @returns the global volume if set or -1 otherwise
  35963. */
  35964. getGlobalVolume(): number;
  35965. /**
  35966. * Sets the global volume of your experience (sets on the master gain).
  35967. * @param newVolume Defines the new global volume of the application
  35968. */
  35969. setGlobalVolume(newVolume: number): void;
  35970. /**
  35971. * Connect the audio engine to an audio analyser allowing some amazing
  35972. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35973. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35974. * @param analyser The analyser to connect to the engine
  35975. */
  35976. connectToAnalyser(analyser: Analyser): void;
  35977. }
  35978. }
  35979. declare module BABYLON {
  35980. /**
  35981. * Interface used to present a loading screen while loading a scene
  35982. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35983. */
  35984. export interface ILoadingScreen {
  35985. /**
  35986. * Function called to display the loading screen
  35987. */
  35988. displayLoadingUI: () => void;
  35989. /**
  35990. * Function called to hide the loading screen
  35991. */
  35992. hideLoadingUI: () => void;
  35993. /**
  35994. * Gets or sets the color to use for the background
  35995. */
  35996. loadingUIBackgroundColor: string;
  35997. /**
  35998. * Gets or sets the text to display while loading
  35999. */
  36000. loadingUIText: string;
  36001. }
  36002. /**
  36003. * Class used for the default loading screen
  36004. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36005. */
  36006. export class DefaultLoadingScreen implements ILoadingScreen {
  36007. private _renderingCanvas;
  36008. private _loadingText;
  36009. private _loadingDivBackgroundColor;
  36010. private _loadingDiv;
  36011. private _loadingTextDiv;
  36012. /** Gets or sets the logo url to use for the default loading screen */
  36013. static DefaultLogoUrl: string;
  36014. /** Gets or sets the spinner url to use for the default loading screen */
  36015. static DefaultSpinnerUrl: string;
  36016. /**
  36017. * Creates a new default loading screen
  36018. * @param _renderingCanvas defines the canvas used to render the scene
  36019. * @param _loadingText defines the default text to display
  36020. * @param _loadingDivBackgroundColor defines the default background color
  36021. */
  36022. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  36023. /**
  36024. * Function called to display the loading screen
  36025. */
  36026. displayLoadingUI(): void;
  36027. /**
  36028. * Function called to hide the loading screen
  36029. */
  36030. hideLoadingUI(): void;
  36031. /**
  36032. * Gets or sets the text to display while loading
  36033. */
  36034. set loadingUIText(text: string);
  36035. get loadingUIText(): string;
  36036. /**
  36037. * Gets or sets the color to use for the background
  36038. */
  36039. get loadingUIBackgroundColor(): string;
  36040. set loadingUIBackgroundColor(color: string);
  36041. private _resizeLoadingUI;
  36042. }
  36043. }
  36044. declare module BABYLON {
  36045. /**
  36046. * Interface for any object that can request an animation frame
  36047. */
  36048. export interface ICustomAnimationFrameRequester {
  36049. /**
  36050. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  36051. */
  36052. renderFunction?: Function;
  36053. /**
  36054. * Called to request the next frame to render to
  36055. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  36056. */
  36057. requestAnimationFrame: Function;
  36058. /**
  36059. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  36060. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  36061. */
  36062. requestID?: number;
  36063. }
  36064. }
  36065. declare module BABYLON {
  36066. /**
  36067. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  36068. */
  36069. export class PerformanceMonitor {
  36070. private _enabled;
  36071. private _rollingFrameTime;
  36072. private _lastFrameTimeMs;
  36073. /**
  36074. * constructor
  36075. * @param frameSampleSize The number of samples required to saturate the sliding window
  36076. */
  36077. constructor(frameSampleSize?: number);
  36078. /**
  36079. * Samples current frame
  36080. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  36081. */
  36082. sampleFrame(timeMs?: number): void;
  36083. /**
  36084. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  36085. */
  36086. get averageFrameTime(): number;
  36087. /**
  36088. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  36089. */
  36090. get averageFrameTimeVariance(): number;
  36091. /**
  36092. * Returns the frame time of the most recent frame
  36093. */
  36094. get instantaneousFrameTime(): number;
  36095. /**
  36096. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  36097. */
  36098. get averageFPS(): number;
  36099. /**
  36100. * Returns the average framerate in frames per second using the most recent frame time
  36101. */
  36102. get instantaneousFPS(): number;
  36103. /**
  36104. * Returns true if enough samples have been taken to completely fill the sliding window
  36105. */
  36106. get isSaturated(): boolean;
  36107. /**
  36108. * Enables contributions to the sliding window sample set
  36109. */
  36110. enable(): void;
  36111. /**
  36112. * Disables contributions to the sliding window sample set
  36113. * Samples will not be interpolated over the disabled period
  36114. */
  36115. disable(): void;
  36116. /**
  36117. * Returns true if sampling is enabled
  36118. */
  36119. get isEnabled(): boolean;
  36120. /**
  36121. * Resets performance monitor
  36122. */
  36123. reset(): void;
  36124. }
  36125. /**
  36126. * RollingAverage
  36127. *
  36128. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  36129. */
  36130. export class RollingAverage {
  36131. /**
  36132. * Current average
  36133. */
  36134. average: number;
  36135. /**
  36136. * Current variance
  36137. */
  36138. variance: number;
  36139. protected _samples: Array<number>;
  36140. protected _sampleCount: number;
  36141. protected _pos: number;
  36142. protected _m2: number;
  36143. /**
  36144. * constructor
  36145. * @param length The number of samples required to saturate the sliding window
  36146. */
  36147. constructor(length: number);
  36148. /**
  36149. * Adds a sample to the sample set
  36150. * @param v The sample value
  36151. */
  36152. add(v: number): void;
  36153. /**
  36154. * Returns previously added values or null if outside of history or outside the sliding window domain
  36155. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  36156. * @return Value previously recorded with add() or null if outside of range
  36157. */
  36158. history(i: number): number;
  36159. /**
  36160. * Returns true if enough samples have been taken to completely fill the sliding window
  36161. * @return true if sample-set saturated
  36162. */
  36163. isSaturated(): boolean;
  36164. /**
  36165. * Resets the rolling average (equivalent to 0 samples taken so far)
  36166. */
  36167. reset(): void;
  36168. /**
  36169. * Wraps a value around the sample range boundaries
  36170. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  36171. * @return Wrapped position in sample range
  36172. */
  36173. protected _wrapPosition(i: number): number;
  36174. }
  36175. }
  36176. declare module BABYLON {
  36177. /**
  36178. * This class is used to track a performance counter which is number based.
  36179. * The user has access to many properties which give statistics of different nature.
  36180. *
  36181. * The implementer can track two kinds of Performance Counter: time and count.
  36182. * 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.
  36183. * 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.
  36184. */
  36185. export class PerfCounter {
  36186. /**
  36187. * Gets or sets a global boolean to turn on and off all the counters
  36188. */
  36189. static Enabled: boolean;
  36190. /**
  36191. * Returns the smallest value ever
  36192. */
  36193. get min(): number;
  36194. /**
  36195. * Returns the biggest value ever
  36196. */
  36197. get max(): number;
  36198. /**
  36199. * Returns the average value since the performance counter is running
  36200. */
  36201. get average(): number;
  36202. /**
  36203. * Returns the average value of the last second the counter was monitored
  36204. */
  36205. get lastSecAverage(): number;
  36206. /**
  36207. * Returns the current value
  36208. */
  36209. get current(): number;
  36210. /**
  36211. * Gets the accumulated total
  36212. */
  36213. get total(): number;
  36214. /**
  36215. * Gets the total value count
  36216. */
  36217. get count(): number;
  36218. /**
  36219. * Creates a new counter
  36220. */
  36221. constructor();
  36222. /**
  36223. * Call this method to start monitoring a new frame.
  36224. * 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.
  36225. */
  36226. fetchNewFrame(): void;
  36227. /**
  36228. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  36229. * @param newCount the count value to add to the monitored count
  36230. * @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.
  36231. */
  36232. addCount(newCount: number, fetchResult: boolean): void;
  36233. /**
  36234. * Start monitoring this performance counter
  36235. */
  36236. beginMonitoring(): void;
  36237. /**
  36238. * Compute the time lapsed since the previous beginMonitoring() call.
  36239. * @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
  36240. */
  36241. endMonitoring(newFrame?: boolean): void;
  36242. private _fetchResult;
  36243. private _startMonitoringTime;
  36244. private _min;
  36245. private _max;
  36246. private _average;
  36247. private _current;
  36248. private _totalValueCount;
  36249. private _totalAccumulated;
  36250. private _lastSecAverage;
  36251. private _lastSecAccumulated;
  36252. private _lastSecTime;
  36253. private _lastSecValueCount;
  36254. }
  36255. }
  36256. declare module BABYLON {
  36257. interface ThinEngine {
  36258. /**
  36259. * Sets alpha constants used by some alpha blending modes
  36260. * @param r defines the red component
  36261. * @param g defines the green component
  36262. * @param b defines the blue component
  36263. * @param a defines the alpha component
  36264. */
  36265. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  36266. /**
  36267. * Sets the current alpha mode
  36268. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  36269. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  36270. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36271. */
  36272. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  36273. /**
  36274. * Gets the current alpha mode
  36275. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36276. * @returns the current alpha mode
  36277. */
  36278. getAlphaMode(): number;
  36279. /**
  36280. * Sets the current alpha equation
  36281. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  36282. */
  36283. setAlphaEquation(equation: number): void;
  36284. /**
  36285. * Gets the current alpha equation.
  36286. * @returns the current alpha equation
  36287. */
  36288. getAlphaEquation(): number;
  36289. }
  36290. }
  36291. declare module BABYLON {
  36292. interface ThinEngine {
  36293. /** @hidden */
  36294. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  36295. }
  36296. }
  36297. declare module BABYLON {
  36298. /**
  36299. * Defines the interface used by display changed events
  36300. */
  36301. export interface IDisplayChangedEventArgs {
  36302. /** Gets the vrDisplay object (if any) */
  36303. vrDisplay: Nullable<any>;
  36304. /** Gets a boolean indicating if webVR is supported */
  36305. vrSupported: boolean;
  36306. }
  36307. /**
  36308. * Defines the interface used by objects containing a viewport (like a camera)
  36309. */
  36310. interface IViewportOwnerLike {
  36311. /**
  36312. * Gets or sets the viewport
  36313. */
  36314. viewport: IViewportLike;
  36315. }
  36316. /**
  36317. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  36318. */
  36319. export class Engine extends ThinEngine {
  36320. /** Defines that alpha blending is disabled */
  36321. static readonly ALPHA_DISABLE: number;
  36322. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  36323. static readonly ALPHA_ADD: number;
  36324. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  36325. static readonly ALPHA_COMBINE: number;
  36326. /** Defines that alpha blending to DEST - SRC * DEST */
  36327. static readonly ALPHA_SUBTRACT: number;
  36328. /** Defines that alpha blending to SRC * DEST */
  36329. static readonly ALPHA_MULTIPLY: number;
  36330. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  36331. static readonly ALPHA_MAXIMIZED: number;
  36332. /** Defines that alpha blending to SRC + DEST */
  36333. static readonly ALPHA_ONEONE: number;
  36334. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  36335. static readonly ALPHA_PREMULTIPLIED: number;
  36336. /**
  36337. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  36338. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  36339. */
  36340. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  36341. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  36342. static readonly ALPHA_INTERPOLATE: number;
  36343. /**
  36344. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  36345. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  36346. */
  36347. static readonly ALPHA_SCREENMODE: number;
  36348. /** Defines that the ressource is not delayed*/
  36349. static readonly DELAYLOADSTATE_NONE: number;
  36350. /** Defines that the ressource was successfully delay loaded */
  36351. static readonly DELAYLOADSTATE_LOADED: number;
  36352. /** Defines that the ressource is currently delay loading */
  36353. static readonly DELAYLOADSTATE_LOADING: number;
  36354. /** Defines that the ressource is delayed and has not started loading */
  36355. static readonly DELAYLOADSTATE_NOTLOADED: number;
  36356. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  36357. static readonly NEVER: number;
  36358. /** 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 */
  36359. static readonly ALWAYS: number;
  36360. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  36361. static readonly LESS: number;
  36362. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  36363. static readonly EQUAL: number;
  36364. /** 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 */
  36365. static readonly LEQUAL: number;
  36366. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  36367. static readonly GREATER: number;
  36368. /** 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 */
  36369. static readonly GEQUAL: number;
  36370. /** 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 */
  36371. static readonly NOTEQUAL: number;
  36372. /** Passed to stencilOperation to specify that stencil value must be kept */
  36373. static readonly KEEP: number;
  36374. /** Passed to stencilOperation to specify that stencil value must be replaced */
  36375. static readonly REPLACE: number;
  36376. /** Passed to stencilOperation to specify that stencil value must be incremented */
  36377. static readonly INCR: number;
  36378. /** Passed to stencilOperation to specify that stencil value must be decremented */
  36379. static readonly DECR: number;
  36380. /** Passed to stencilOperation to specify that stencil value must be inverted */
  36381. static readonly INVERT: number;
  36382. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  36383. static readonly INCR_WRAP: number;
  36384. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  36385. static readonly DECR_WRAP: number;
  36386. /** Texture is not repeating outside of 0..1 UVs */
  36387. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  36388. /** Texture is repeating outside of 0..1 UVs */
  36389. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  36390. /** Texture is repeating and mirrored */
  36391. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  36392. /** ALPHA */
  36393. static readonly TEXTUREFORMAT_ALPHA: number;
  36394. /** LUMINANCE */
  36395. static readonly TEXTUREFORMAT_LUMINANCE: number;
  36396. /** LUMINANCE_ALPHA */
  36397. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  36398. /** RGB */
  36399. static readonly TEXTUREFORMAT_RGB: number;
  36400. /** RGBA */
  36401. static readonly TEXTUREFORMAT_RGBA: number;
  36402. /** RED */
  36403. static readonly TEXTUREFORMAT_RED: number;
  36404. /** RED (2nd reference) */
  36405. static readonly TEXTUREFORMAT_R: number;
  36406. /** RG */
  36407. static readonly TEXTUREFORMAT_RG: number;
  36408. /** RED_INTEGER */
  36409. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  36410. /** RED_INTEGER (2nd reference) */
  36411. static readonly TEXTUREFORMAT_R_INTEGER: number;
  36412. /** RG_INTEGER */
  36413. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  36414. /** RGB_INTEGER */
  36415. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  36416. /** RGBA_INTEGER */
  36417. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  36418. /** UNSIGNED_BYTE */
  36419. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  36420. /** UNSIGNED_BYTE (2nd reference) */
  36421. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  36422. /** FLOAT */
  36423. static readonly TEXTURETYPE_FLOAT: number;
  36424. /** HALF_FLOAT */
  36425. static readonly TEXTURETYPE_HALF_FLOAT: number;
  36426. /** BYTE */
  36427. static readonly TEXTURETYPE_BYTE: number;
  36428. /** SHORT */
  36429. static readonly TEXTURETYPE_SHORT: number;
  36430. /** UNSIGNED_SHORT */
  36431. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  36432. /** INT */
  36433. static readonly TEXTURETYPE_INT: number;
  36434. /** UNSIGNED_INT */
  36435. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  36436. /** UNSIGNED_SHORT_4_4_4_4 */
  36437. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  36438. /** UNSIGNED_SHORT_5_5_5_1 */
  36439. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  36440. /** UNSIGNED_SHORT_5_6_5 */
  36441. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  36442. /** UNSIGNED_INT_2_10_10_10_REV */
  36443. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  36444. /** UNSIGNED_INT_24_8 */
  36445. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  36446. /** UNSIGNED_INT_10F_11F_11F_REV */
  36447. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  36448. /** UNSIGNED_INT_5_9_9_9_REV */
  36449. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  36450. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  36451. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  36452. /** nearest is mag = nearest and min = nearest and mip = linear */
  36453. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  36454. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36455. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  36456. /** Trilinear is mag = linear and min = linear and mip = linear */
  36457. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  36458. /** nearest is mag = nearest and min = nearest and mip = linear */
  36459. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  36460. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36461. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  36462. /** Trilinear is mag = linear and min = linear and mip = linear */
  36463. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  36464. /** mag = nearest and min = nearest and mip = nearest */
  36465. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  36466. /** mag = nearest and min = linear and mip = nearest */
  36467. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  36468. /** mag = nearest and min = linear and mip = linear */
  36469. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  36470. /** mag = nearest and min = linear and mip = none */
  36471. static readonly TEXTURE_NEAREST_LINEAR: number;
  36472. /** mag = nearest and min = nearest and mip = none */
  36473. static readonly TEXTURE_NEAREST_NEAREST: number;
  36474. /** mag = linear and min = nearest and mip = nearest */
  36475. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  36476. /** mag = linear and min = nearest and mip = linear */
  36477. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  36478. /** mag = linear and min = linear and mip = none */
  36479. static readonly TEXTURE_LINEAR_LINEAR: number;
  36480. /** mag = linear and min = nearest and mip = none */
  36481. static readonly TEXTURE_LINEAR_NEAREST: number;
  36482. /** Explicit coordinates mode */
  36483. static readonly TEXTURE_EXPLICIT_MODE: number;
  36484. /** Spherical coordinates mode */
  36485. static readonly TEXTURE_SPHERICAL_MODE: number;
  36486. /** Planar coordinates mode */
  36487. static readonly TEXTURE_PLANAR_MODE: number;
  36488. /** Cubic coordinates mode */
  36489. static readonly TEXTURE_CUBIC_MODE: number;
  36490. /** Projection coordinates mode */
  36491. static readonly TEXTURE_PROJECTION_MODE: number;
  36492. /** Skybox coordinates mode */
  36493. static readonly TEXTURE_SKYBOX_MODE: number;
  36494. /** Inverse Cubic coordinates mode */
  36495. static readonly TEXTURE_INVCUBIC_MODE: number;
  36496. /** Equirectangular coordinates mode */
  36497. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  36498. /** Equirectangular Fixed coordinates mode */
  36499. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  36500. /** Equirectangular Fixed Mirrored coordinates mode */
  36501. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  36502. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  36503. static readonly SCALEMODE_FLOOR: number;
  36504. /** Defines that texture rescaling will look for the nearest power of 2 size */
  36505. static readonly SCALEMODE_NEAREST: number;
  36506. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  36507. static readonly SCALEMODE_CEILING: number;
  36508. /**
  36509. * Returns the current npm package of the sdk
  36510. */
  36511. static get NpmPackage(): string;
  36512. /**
  36513. * Returns the current version of the framework
  36514. */
  36515. static get Version(): string;
  36516. /** Gets the list of created engines */
  36517. static get Instances(): Engine[];
  36518. /**
  36519. * Gets the latest created engine
  36520. */
  36521. static get LastCreatedEngine(): Nullable<Engine>;
  36522. /**
  36523. * Gets the latest created scene
  36524. */
  36525. static get LastCreatedScene(): Nullable<Scene>;
  36526. /**
  36527. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  36528. * @param flag defines which part of the materials must be marked as dirty
  36529. * @param predicate defines a predicate used to filter which materials should be affected
  36530. */
  36531. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36532. /**
  36533. * Method called to create the default loading screen.
  36534. * This can be overriden in your own app.
  36535. * @param canvas The rendering canvas element
  36536. * @returns The loading screen
  36537. */
  36538. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  36539. /**
  36540. * Method called to create the default rescale post process on each engine.
  36541. */
  36542. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  36543. /**
  36544. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  36545. **/
  36546. enableOfflineSupport: boolean;
  36547. /**
  36548. * 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)
  36549. **/
  36550. disableManifestCheck: boolean;
  36551. /**
  36552. * Gets the list of created scenes
  36553. */
  36554. scenes: Scene[];
  36555. /**
  36556. * Event raised when a new scene is created
  36557. */
  36558. onNewSceneAddedObservable: Observable<Scene>;
  36559. /**
  36560. * Gets the list of created postprocesses
  36561. */
  36562. postProcesses: PostProcess[];
  36563. /**
  36564. * Gets a boolean indicating if the pointer is currently locked
  36565. */
  36566. isPointerLock: boolean;
  36567. /**
  36568. * Observable event triggered each time the rendering canvas is resized
  36569. */
  36570. onResizeObservable: Observable<Engine>;
  36571. /**
  36572. * Observable event triggered each time the canvas loses focus
  36573. */
  36574. onCanvasBlurObservable: Observable<Engine>;
  36575. /**
  36576. * Observable event triggered each time the canvas gains focus
  36577. */
  36578. onCanvasFocusObservable: Observable<Engine>;
  36579. /**
  36580. * Observable event triggered each time the canvas receives pointerout event
  36581. */
  36582. onCanvasPointerOutObservable: Observable<PointerEvent>;
  36583. /**
  36584. * Observable raised when the engine begins a new frame
  36585. */
  36586. onBeginFrameObservable: Observable<Engine>;
  36587. /**
  36588. * If set, will be used to request the next animation frame for the render loop
  36589. */
  36590. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  36591. /**
  36592. * Observable raised when the engine ends the current frame
  36593. */
  36594. onEndFrameObservable: Observable<Engine>;
  36595. /**
  36596. * Observable raised when the engine is about to compile a shader
  36597. */
  36598. onBeforeShaderCompilationObservable: Observable<Engine>;
  36599. /**
  36600. * Observable raised when the engine has jsut compiled a shader
  36601. */
  36602. onAfterShaderCompilationObservable: Observable<Engine>;
  36603. /**
  36604. * Gets the audio engine
  36605. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36606. * @ignorenaming
  36607. */
  36608. static audioEngine: IAudioEngine;
  36609. /**
  36610. * Default AudioEngine factory responsible of creating the Audio Engine.
  36611. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  36612. */
  36613. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  36614. /**
  36615. * Default offline support factory responsible of creating a tool used to store data locally.
  36616. * By default, this will create a Database object if the workload has been embedded.
  36617. */
  36618. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  36619. private _loadingScreen;
  36620. private _pointerLockRequested;
  36621. private _rescalePostProcess;
  36622. private _deterministicLockstep;
  36623. private _lockstepMaxSteps;
  36624. private _timeStep;
  36625. protected get _supportsHardwareTextureRescaling(): boolean;
  36626. private _fps;
  36627. private _deltaTime;
  36628. /** @hidden */
  36629. _drawCalls: PerfCounter;
  36630. /** 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 */
  36631. canvasTabIndex: number;
  36632. /**
  36633. * Turn this value on if you want to pause FPS computation when in background
  36634. */
  36635. disablePerformanceMonitorInBackground: boolean;
  36636. private _performanceMonitor;
  36637. /**
  36638. * Gets the performance monitor attached to this engine
  36639. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  36640. */
  36641. get performanceMonitor(): PerformanceMonitor;
  36642. private _onFocus;
  36643. private _onBlur;
  36644. private _onCanvasPointerOut;
  36645. private _onCanvasBlur;
  36646. private _onCanvasFocus;
  36647. private _onFullscreenChange;
  36648. private _onPointerLockChange;
  36649. /**
  36650. * Gets the HTML element used to attach event listeners
  36651. * @returns a HTML element
  36652. */
  36653. getInputElement(): Nullable<HTMLElement>;
  36654. /**
  36655. * Creates a new engine
  36656. * @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
  36657. * @param antialias defines enable antialiasing (default: false)
  36658. * @param options defines further options to be sent to the getContext() function
  36659. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36660. */
  36661. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36662. /**
  36663. * Gets current aspect ratio
  36664. * @param viewportOwner defines the camera to use to get the aspect ratio
  36665. * @param useScreen defines if screen size must be used (or the current render target if any)
  36666. * @returns a number defining the aspect ratio
  36667. */
  36668. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  36669. /**
  36670. * Gets current screen aspect ratio
  36671. * @returns a number defining the aspect ratio
  36672. */
  36673. getScreenAspectRatio(): number;
  36674. /**
  36675. * Gets the client rect of the HTML canvas attached with the current webGL context
  36676. * @returns a client rectanglee
  36677. */
  36678. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  36679. /**
  36680. * Gets the client rect of the HTML element used for events
  36681. * @returns a client rectanglee
  36682. */
  36683. getInputElementClientRect(): Nullable<ClientRect>;
  36684. /**
  36685. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  36686. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36687. * @returns true if engine is in deterministic lock step mode
  36688. */
  36689. isDeterministicLockStep(): boolean;
  36690. /**
  36691. * Gets the max steps when engine is running in deterministic lock step
  36692. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36693. * @returns the max steps
  36694. */
  36695. getLockstepMaxSteps(): number;
  36696. /**
  36697. * Returns the time in ms between steps when using deterministic lock step.
  36698. * @returns time step in (ms)
  36699. */
  36700. getTimeStep(): number;
  36701. /**
  36702. * Force the mipmap generation for the given render target texture
  36703. * @param texture defines the render target texture to use
  36704. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  36705. */
  36706. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  36707. /** States */
  36708. /**
  36709. * Set various states to the webGL context
  36710. * @param culling defines backface culling state
  36711. * @param zOffset defines the value to apply to zOffset (0 by default)
  36712. * @param force defines if states must be applied even if cache is up to date
  36713. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  36714. */
  36715. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  36716. /**
  36717. * Set the z offset to apply to current rendering
  36718. * @param value defines the offset to apply
  36719. */
  36720. setZOffset(value: number): void;
  36721. /**
  36722. * Gets the current value of the zOffset
  36723. * @returns the current zOffset state
  36724. */
  36725. getZOffset(): number;
  36726. /**
  36727. * Enable or disable depth buffering
  36728. * @param enable defines the state to set
  36729. */
  36730. setDepthBuffer(enable: boolean): void;
  36731. /**
  36732. * Gets a boolean indicating if depth writing is enabled
  36733. * @returns the current depth writing state
  36734. */
  36735. getDepthWrite(): boolean;
  36736. /**
  36737. * Enable or disable depth writing
  36738. * @param enable defines the state to set
  36739. */
  36740. setDepthWrite(enable: boolean): void;
  36741. /**
  36742. * Gets a boolean indicating if stencil buffer is enabled
  36743. * @returns the current stencil buffer state
  36744. */
  36745. getStencilBuffer(): boolean;
  36746. /**
  36747. * Enable or disable the stencil buffer
  36748. * @param enable defines if the stencil buffer must be enabled or disabled
  36749. */
  36750. setStencilBuffer(enable: boolean): void;
  36751. /**
  36752. * Gets the current stencil mask
  36753. * @returns a number defining the new stencil mask to use
  36754. */
  36755. getStencilMask(): number;
  36756. /**
  36757. * Sets the current stencil mask
  36758. * @param mask defines the new stencil mask to use
  36759. */
  36760. setStencilMask(mask: number): void;
  36761. /**
  36762. * Gets the current stencil function
  36763. * @returns a number defining the stencil function to use
  36764. */
  36765. getStencilFunction(): number;
  36766. /**
  36767. * Gets the current stencil reference value
  36768. * @returns a number defining the stencil reference value to use
  36769. */
  36770. getStencilFunctionReference(): number;
  36771. /**
  36772. * Gets the current stencil mask
  36773. * @returns a number defining the stencil mask to use
  36774. */
  36775. getStencilFunctionMask(): number;
  36776. /**
  36777. * Sets the current stencil function
  36778. * @param stencilFunc defines the new stencil function to use
  36779. */
  36780. setStencilFunction(stencilFunc: number): void;
  36781. /**
  36782. * Sets the current stencil reference
  36783. * @param reference defines the new stencil reference to use
  36784. */
  36785. setStencilFunctionReference(reference: number): void;
  36786. /**
  36787. * Sets the current stencil mask
  36788. * @param mask defines the new stencil mask to use
  36789. */
  36790. setStencilFunctionMask(mask: number): void;
  36791. /**
  36792. * Gets the current stencil operation when stencil fails
  36793. * @returns a number defining stencil operation to use when stencil fails
  36794. */
  36795. getStencilOperationFail(): number;
  36796. /**
  36797. * Gets the current stencil operation when depth fails
  36798. * @returns a number defining stencil operation to use when depth fails
  36799. */
  36800. getStencilOperationDepthFail(): number;
  36801. /**
  36802. * Gets the current stencil operation when stencil passes
  36803. * @returns a number defining stencil operation to use when stencil passes
  36804. */
  36805. getStencilOperationPass(): number;
  36806. /**
  36807. * Sets the stencil operation to use when stencil fails
  36808. * @param operation defines the stencil operation to use when stencil fails
  36809. */
  36810. setStencilOperationFail(operation: number): void;
  36811. /**
  36812. * Sets the stencil operation to use when depth fails
  36813. * @param operation defines the stencil operation to use when depth fails
  36814. */
  36815. setStencilOperationDepthFail(operation: number): void;
  36816. /**
  36817. * Sets the stencil operation to use when stencil passes
  36818. * @param operation defines the stencil operation to use when stencil passes
  36819. */
  36820. setStencilOperationPass(operation: number): void;
  36821. /**
  36822. * Sets a boolean indicating if the dithering state is enabled or disabled
  36823. * @param value defines the dithering state
  36824. */
  36825. setDitheringState(value: boolean): void;
  36826. /**
  36827. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  36828. * @param value defines the rasterizer state
  36829. */
  36830. setRasterizerState(value: boolean): void;
  36831. /**
  36832. * Gets the current depth function
  36833. * @returns a number defining the depth function
  36834. */
  36835. getDepthFunction(): Nullable<number>;
  36836. /**
  36837. * Sets the current depth function
  36838. * @param depthFunc defines the function to use
  36839. */
  36840. setDepthFunction(depthFunc: number): void;
  36841. /**
  36842. * Sets the current depth function to GREATER
  36843. */
  36844. setDepthFunctionToGreater(): void;
  36845. /**
  36846. * Sets the current depth function to GEQUAL
  36847. */
  36848. setDepthFunctionToGreaterOrEqual(): void;
  36849. /**
  36850. * Sets the current depth function to LESS
  36851. */
  36852. setDepthFunctionToLess(): void;
  36853. /**
  36854. * Sets the current depth function to LEQUAL
  36855. */
  36856. setDepthFunctionToLessOrEqual(): void;
  36857. private _cachedStencilBuffer;
  36858. private _cachedStencilFunction;
  36859. private _cachedStencilMask;
  36860. private _cachedStencilOperationPass;
  36861. private _cachedStencilOperationFail;
  36862. private _cachedStencilOperationDepthFail;
  36863. private _cachedStencilReference;
  36864. /**
  36865. * Caches the the state of the stencil buffer
  36866. */
  36867. cacheStencilState(): void;
  36868. /**
  36869. * Restores the state of the stencil buffer
  36870. */
  36871. restoreStencilState(): void;
  36872. /**
  36873. * Directly set the WebGL Viewport
  36874. * @param x defines the x coordinate of the viewport (in screen space)
  36875. * @param y defines the y coordinate of the viewport (in screen space)
  36876. * @param width defines the width of the viewport (in screen space)
  36877. * @param height defines the height of the viewport (in screen space)
  36878. * @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
  36879. */
  36880. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  36881. /**
  36882. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  36883. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36884. * @param y defines the y-coordinate of the corner of the clear rectangle
  36885. * @param width defines the width of the clear rectangle
  36886. * @param height defines the height of the clear rectangle
  36887. * @param clearColor defines the clear color
  36888. */
  36889. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  36890. /**
  36891. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  36892. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36893. * @param y defines the y-coordinate of the corner of the clear rectangle
  36894. * @param width defines the width of the clear rectangle
  36895. * @param height defines the height of the clear rectangle
  36896. */
  36897. enableScissor(x: number, y: number, width: number, height: number): void;
  36898. /**
  36899. * Disable previously set scissor test rectangle
  36900. */
  36901. disableScissor(): void;
  36902. protected _reportDrawCall(): void;
  36903. /**
  36904. * Initializes a webVR display and starts listening to display change events
  36905. * The onVRDisplayChangedObservable will be notified upon these changes
  36906. * @returns The onVRDisplayChangedObservable
  36907. */
  36908. initWebVR(): Observable<IDisplayChangedEventArgs>;
  36909. /** @hidden */
  36910. _prepareVRComponent(): void;
  36911. /** @hidden */
  36912. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  36913. /** @hidden */
  36914. _submitVRFrame(): void;
  36915. /**
  36916. * Call this function to leave webVR mode
  36917. * Will do nothing if webVR is not supported or if there is no webVR device
  36918. * @see http://doc.babylonjs.com/how_to/webvr_camera
  36919. */
  36920. disableVR(): void;
  36921. /**
  36922. * Gets a boolean indicating that the system is in VR mode and is presenting
  36923. * @returns true if VR mode is engaged
  36924. */
  36925. isVRPresenting(): boolean;
  36926. /** @hidden */
  36927. _requestVRFrame(): void;
  36928. /** @hidden */
  36929. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36930. /**
  36931. * Gets the source code of the vertex shader associated with a specific webGL program
  36932. * @param program defines the program to use
  36933. * @returns a string containing the source code of the vertex shader associated with the program
  36934. */
  36935. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  36936. /**
  36937. * Gets the source code of the fragment shader associated with a specific webGL program
  36938. * @param program defines the program to use
  36939. * @returns a string containing the source code of the fragment shader associated with the program
  36940. */
  36941. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  36942. /**
  36943. * Sets a depth stencil texture from a render target to the according uniform.
  36944. * @param channel The texture channel
  36945. * @param uniform The uniform to set
  36946. * @param texture The render target texture containing the depth stencil texture to apply
  36947. */
  36948. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  36949. /**
  36950. * Sets a texture to the webGL context from a postprocess
  36951. * @param channel defines the channel to use
  36952. * @param postProcess defines the source postprocess
  36953. */
  36954. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  36955. /**
  36956. * Binds the output of the passed in post process to the texture channel specified
  36957. * @param channel The channel the texture should be bound to
  36958. * @param postProcess The post process which's output should be bound
  36959. */
  36960. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  36961. protected _rebuildBuffers(): void;
  36962. /** @hidden */
  36963. _renderFrame(): void;
  36964. _renderLoop(): void;
  36965. /** @hidden */
  36966. _renderViews(): boolean;
  36967. /**
  36968. * Toggle full screen mode
  36969. * @param requestPointerLock defines if a pointer lock should be requested from the user
  36970. */
  36971. switchFullscreen(requestPointerLock: boolean): void;
  36972. /**
  36973. * Enters full screen mode
  36974. * @param requestPointerLock defines if a pointer lock should be requested from the user
  36975. */
  36976. enterFullscreen(requestPointerLock: boolean): void;
  36977. /**
  36978. * Exits full screen mode
  36979. */
  36980. exitFullscreen(): void;
  36981. /**
  36982. * Enters Pointerlock mode
  36983. */
  36984. enterPointerlock(): void;
  36985. /**
  36986. * Exits Pointerlock mode
  36987. */
  36988. exitPointerlock(): void;
  36989. /**
  36990. * Begin a new frame
  36991. */
  36992. beginFrame(): void;
  36993. /**
  36994. * Enf the current frame
  36995. */
  36996. endFrame(): void;
  36997. resize(): void;
  36998. /**
  36999. * Force a specific size of the canvas
  37000. * @param width defines the new canvas' width
  37001. * @param height defines the new canvas' height
  37002. */
  37003. setSize(width: number, height: number): void;
  37004. /**
  37005. * Updates a dynamic vertex buffer.
  37006. * @param vertexBuffer the vertex buffer to update
  37007. * @param data the data used to update the vertex buffer
  37008. * @param byteOffset the byte offset of the data
  37009. * @param byteLength the byte length of the data
  37010. */
  37011. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  37012. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  37013. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37014. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37015. _releaseTexture(texture: InternalTexture): void;
  37016. /**
  37017. * @hidden
  37018. * Rescales a texture
  37019. * @param source input texutre
  37020. * @param destination destination texture
  37021. * @param scene scene to use to render the resize
  37022. * @param internalFormat format to use when resizing
  37023. * @param onComplete callback to be called when resize has completed
  37024. */
  37025. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37026. /**
  37027. * Gets the current framerate
  37028. * @returns a number representing the framerate
  37029. */
  37030. getFps(): number;
  37031. /**
  37032. * Gets the time spent between current and previous frame
  37033. * @returns a number representing the delta time in ms
  37034. */
  37035. getDeltaTime(): number;
  37036. private _measureFps;
  37037. /** @hidden */
  37038. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  37039. /**
  37040. * Update a dynamic index buffer
  37041. * @param indexBuffer defines the target index buffer
  37042. * @param indices defines the data to update
  37043. * @param offset defines the offset in the target index buffer where update should start
  37044. */
  37045. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  37046. /**
  37047. * Updates the sample count of a render target texture
  37048. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  37049. * @param texture defines the texture to update
  37050. * @param samples defines the sample count to set
  37051. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  37052. */
  37053. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  37054. /**
  37055. * Updates a depth texture Comparison Mode and Function.
  37056. * If the comparison Function is equal to 0, the mode will be set to none.
  37057. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  37058. * @param texture The texture to set the comparison function for
  37059. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  37060. */
  37061. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  37062. /**
  37063. * Creates a webGL buffer to use with instanciation
  37064. * @param capacity defines the size of the buffer
  37065. * @returns the webGL buffer
  37066. */
  37067. createInstancesBuffer(capacity: number): DataBuffer;
  37068. /**
  37069. * Delete a webGL buffer used with instanciation
  37070. * @param buffer defines the webGL buffer to delete
  37071. */
  37072. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  37073. private _clientWaitAsync;
  37074. /** @hidden */
  37075. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  37076. dispose(): void;
  37077. private _disableTouchAction;
  37078. /**
  37079. * Display the loading screen
  37080. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37081. */
  37082. displayLoadingUI(): void;
  37083. /**
  37084. * Hide the loading screen
  37085. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37086. */
  37087. hideLoadingUI(): void;
  37088. /**
  37089. * Gets the current loading screen object
  37090. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37091. */
  37092. get loadingScreen(): ILoadingScreen;
  37093. /**
  37094. * Sets the current loading screen object
  37095. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37096. */
  37097. set loadingScreen(loadingScreen: ILoadingScreen);
  37098. /**
  37099. * Sets the current loading screen text
  37100. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37101. */
  37102. set loadingUIText(text: string);
  37103. /**
  37104. * Sets the current loading screen background color
  37105. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37106. */
  37107. set loadingUIBackgroundColor(color: string);
  37108. /** Pointerlock and fullscreen */
  37109. /**
  37110. * Ask the browser to promote the current element to pointerlock mode
  37111. * @param element defines the DOM element to promote
  37112. */
  37113. static _RequestPointerlock(element: HTMLElement): void;
  37114. /**
  37115. * Asks the browser to exit pointerlock mode
  37116. */
  37117. static _ExitPointerlock(): void;
  37118. /**
  37119. * Ask the browser to promote the current element to fullscreen rendering mode
  37120. * @param element defines the DOM element to promote
  37121. */
  37122. static _RequestFullscreen(element: HTMLElement): void;
  37123. /**
  37124. * Asks the browser to exit fullscreen mode
  37125. */
  37126. static _ExitFullscreen(): void;
  37127. }
  37128. }
  37129. declare module BABYLON {
  37130. /**
  37131. * The engine store class is responsible to hold all the instances of Engine and Scene created
  37132. * during the life time of the application.
  37133. */
  37134. export class EngineStore {
  37135. /** Gets the list of created engines */
  37136. static Instances: Engine[];
  37137. /** @hidden */
  37138. static _LastCreatedScene: Nullable<Scene>;
  37139. /**
  37140. * Gets the latest created engine
  37141. */
  37142. static get LastCreatedEngine(): Nullable<Engine>;
  37143. /**
  37144. * Gets the latest created scene
  37145. */
  37146. static get LastCreatedScene(): Nullable<Scene>;
  37147. /**
  37148. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  37149. * @ignorenaming
  37150. */
  37151. static UseFallbackTexture: boolean;
  37152. /**
  37153. * Texture content used if a texture cannot loaded
  37154. * @ignorenaming
  37155. */
  37156. static FallbackTexture: string;
  37157. }
  37158. }
  37159. declare module BABYLON {
  37160. /**
  37161. * Helper class that provides a small promise polyfill
  37162. */
  37163. export class PromisePolyfill {
  37164. /**
  37165. * Static function used to check if the polyfill is required
  37166. * If this is the case then the function will inject the polyfill to window.Promise
  37167. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  37168. */
  37169. static Apply(force?: boolean): void;
  37170. }
  37171. }
  37172. declare module BABYLON {
  37173. /**
  37174. * Interface for screenshot methods with describe argument called `size` as object with options
  37175. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  37176. */
  37177. export interface IScreenshotSize {
  37178. /**
  37179. * number in pixels for canvas height
  37180. */
  37181. height?: number;
  37182. /**
  37183. * multiplier allowing render at a higher or lower resolution
  37184. * If value is defined then height and width will be ignored and taken from camera
  37185. */
  37186. precision?: number;
  37187. /**
  37188. * number in pixels for canvas width
  37189. */
  37190. width?: number;
  37191. }
  37192. }
  37193. declare module BABYLON {
  37194. interface IColor4Like {
  37195. r: float;
  37196. g: float;
  37197. b: float;
  37198. a: float;
  37199. }
  37200. /**
  37201. * Class containing a set of static utilities functions
  37202. */
  37203. export class Tools {
  37204. /**
  37205. * Gets or sets the base URL to use to load assets
  37206. */
  37207. static get BaseUrl(): string;
  37208. static set BaseUrl(value: string);
  37209. /**
  37210. * Enable/Disable Custom HTTP Request Headers globally.
  37211. * default = false
  37212. * @see CustomRequestHeaders
  37213. */
  37214. static UseCustomRequestHeaders: boolean;
  37215. /**
  37216. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  37217. * i.e. when loading files, where the server/service expects an Authorization header
  37218. */
  37219. static CustomRequestHeaders: {
  37220. [key: string]: string;
  37221. };
  37222. /**
  37223. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  37224. */
  37225. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  37226. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  37227. /**
  37228. * Default behaviour for cors in the application.
  37229. * It can be a string if the expected behavior is identical in the entire app.
  37230. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  37231. */
  37232. static get CorsBehavior(): string | ((url: string | string[]) => string);
  37233. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  37234. /**
  37235. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  37236. * @ignorenaming
  37237. */
  37238. static get UseFallbackTexture(): boolean;
  37239. static set UseFallbackTexture(value: boolean);
  37240. /**
  37241. * Use this object to register external classes like custom textures or material
  37242. * to allow the laoders to instantiate them
  37243. */
  37244. static get RegisteredExternalClasses(): {
  37245. [key: string]: Object;
  37246. };
  37247. static set RegisteredExternalClasses(classes: {
  37248. [key: string]: Object;
  37249. });
  37250. /**
  37251. * Texture content used if a texture cannot loaded
  37252. * @ignorenaming
  37253. */
  37254. static get fallbackTexture(): string;
  37255. static set fallbackTexture(value: string);
  37256. /**
  37257. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  37258. * @param u defines the coordinate on X axis
  37259. * @param v defines the coordinate on Y axis
  37260. * @param width defines the width of the source data
  37261. * @param height defines the height of the source data
  37262. * @param pixels defines the source byte array
  37263. * @param color defines the output color
  37264. */
  37265. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  37266. /**
  37267. * Interpolates between a and b via alpha
  37268. * @param a The lower value (returned when alpha = 0)
  37269. * @param b The upper value (returned when alpha = 1)
  37270. * @param alpha The interpolation-factor
  37271. * @return The mixed value
  37272. */
  37273. static Mix(a: number, b: number, alpha: number): number;
  37274. /**
  37275. * Tries to instantiate a new object from a given class name
  37276. * @param className defines the class name to instantiate
  37277. * @returns the new object or null if the system was not able to do the instantiation
  37278. */
  37279. static Instantiate(className: string): any;
  37280. /**
  37281. * Provides a slice function that will work even on IE
  37282. * @param data defines the array to slice
  37283. * @param start defines the start of the data (optional)
  37284. * @param end defines the end of the data (optional)
  37285. * @returns the new sliced array
  37286. */
  37287. static Slice<T>(data: T, start?: number, end?: number): T;
  37288. /**
  37289. * Polyfill for setImmediate
  37290. * @param action defines the action to execute after the current execution block
  37291. */
  37292. static SetImmediate(action: () => void): void;
  37293. /**
  37294. * Function indicating if a number is an exponent of 2
  37295. * @param value defines the value to test
  37296. * @returns true if the value is an exponent of 2
  37297. */
  37298. static IsExponentOfTwo(value: number): boolean;
  37299. private static _tmpFloatArray;
  37300. /**
  37301. * Returns the nearest 32-bit single precision float representation of a Number
  37302. * @param value A Number. If the parameter is of a different type, it will get converted
  37303. * to a number or to NaN if it cannot be converted
  37304. * @returns number
  37305. */
  37306. static FloatRound(value: number): number;
  37307. /**
  37308. * Extracts the filename from a path
  37309. * @param path defines the path to use
  37310. * @returns the filename
  37311. */
  37312. static GetFilename(path: string): string;
  37313. /**
  37314. * Extracts the "folder" part of a path (everything before the filename).
  37315. * @param uri The URI to extract the info from
  37316. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  37317. * @returns The "folder" part of the path
  37318. */
  37319. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  37320. /**
  37321. * Extracts text content from a DOM element hierarchy
  37322. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  37323. */
  37324. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  37325. /**
  37326. * Convert an angle in radians to degrees
  37327. * @param angle defines the angle to convert
  37328. * @returns the angle in degrees
  37329. */
  37330. static ToDegrees(angle: number): number;
  37331. /**
  37332. * Convert an angle in degrees to radians
  37333. * @param angle defines the angle to convert
  37334. * @returns the angle in radians
  37335. */
  37336. static ToRadians(angle: number): number;
  37337. /**
  37338. * Returns an array if obj is not an array
  37339. * @param obj defines the object to evaluate as an array
  37340. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  37341. * @returns either obj directly if obj is an array or a new array containing obj
  37342. */
  37343. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  37344. /**
  37345. * Gets the pointer prefix to use
  37346. * @param engine defines the engine we are finding the prefix for
  37347. * @returns "pointer" if touch is enabled. Else returns "mouse"
  37348. */
  37349. static GetPointerPrefix(engine: Engine): string;
  37350. /**
  37351. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  37352. * @param url define the url we are trying
  37353. * @param element define the dom element where to configure the cors policy
  37354. */
  37355. static SetCorsBehavior(url: string | string[], element: {
  37356. crossOrigin: string | null;
  37357. }): void;
  37358. /**
  37359. * Removes unwanted characters from an url
  37360. * @param url defines the url to clean
  37361. * @returns the cleaned url
  37362. */
  37363. static CleanUrl(url: string): string;
  37364. /**
  37365. * Gets or sets a function used to pre-process url before using them to load assets
  37366. */
  37367. static get PreprocessUrl(): (url: string) => string;
  37368. static set PreprocessUrl(processor: (url: string) => string);
  37369. /**
  37370. * Loads an image as an HTMLImageElement.
  37371. * @param input url string, ArrayBuffer, or Blob to load
  37372. * @param onLoad callback called when the image successfully loads
  37373. * @param onError callback called when the image fails to load
  37374. * @param offlineProvider offline provider for caching
  37375. * @param mimeType optional mime type
  37376. * @returns the HTMLImageElement of the loaded image
  37377. */
  37378. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  37379. /**
  37380. * Loads a file from a url
  37381. * @param url url string, ArrayBuffer, or Blob to load
  37382. * @param onSuccess callback called when the file successfully loads
  37383. * @param onProgress callback called while file is loading (if the server supports this mode)
  37384. * @param offlineProvider defines the offline provider for caching
  37385. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37386. * @param onError callback called when the file fails to load
  37387. * @returns a file request object
  37388. */
  37389. 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;
  37390. /**
  37391. * Loads a file from a url
  37392. * @param url the file url to load
  37393. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37394. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  37395. */
  37396. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  37397. /**
  37398. * Load a script (identified by an url). When the url returns, the
  37399. * content of this file is added into a new script element, attached to the DOM (body element)
  37400. * @param scriptUrl defines the url of the script to laod
  37401. * @param onSuccess defines the callback called when the script is loaded
  37402. * @param onError defines the callback to call if an error occurs
  37403. * @param scriptId defines the id of the script element
  37404. */
  37405. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  37406. /**
  37407. * Load an asynchronous script (identified by an url). When the url returns, the
  37408. * content of this file is added into a new script element, attached to the DOM (body element)
  37409. * @param scriptUrl defines the url of the script to laod
  37410. * @param scriptId defines the id of the script element
  37411. * @returns a promise request object
  37412. */
  37413. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  37414. /**
  37415. * Loads a file from a blob
  37416. * @param fileToLoad defines the blob to use
  37417. * @param callback defines the callback to call when data is loaded
  37418. * @param progressCallback defines the callback to call during loading process
  37419. * @returns a file request object
  37420. */
  37421. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  37422. /**
  37423. * Reads a file from a File object
  37424. * @param file defines the file to load
  37425. * @param onSuccess defines the callback to call when data is loaded
  37426. * @param onProgress defines the callback to call during loading process
  37427. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  37428. * @param onError defines the callback to call when an error occurs
  37429. * @returns a file request object
  37430. */
  37431. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37432. /**
  37433. * Creates a data url from a given string content
  37434. * @param content defines the content to convert
  37435. * @returns the new data url link
  37436. */
  37437. static FileAsURL(content: string): string;
  37438. /**
  37439. * Format the given number to a specific decimal format
  37440. * @param value defines the number to format
  37441. * @param decimals defines the number of decimals to use
  37442. * @returns the formatted string
  37443. */
  37444. static Format(value: number, decimals?: number): string;
  37445. /**
  37446. * Tries to copy an object by duplicating every property
  37447. * @param source defines the source object
  37448. * @param destination defines the target object
  37449. * @param doNotCopyList defines a list of properties to avoid
  37450. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  37451. */
  37452. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  37453. /**
  37454. * Gets a boolean indicating if the given object has no own property
  37455. * @param obj defines the object to test
  37456. * @returns true if object has no own property
  37457. */
  37458. static IsEmpty(obj: any): boolean;
  37459. /**
  37460. * Function used to register events at window level
  37461. * @param windowElement defines the Window object to use
  37462. * @param events defines the events to register
  37463. */
  37464. static RegisterTopRootEvents(windowElement: Window, events: {
  37465. name: string;
  37466. handler: Nullable<(e: FocusEvent) => any>;
  37467. }[]): void;
  37468. /**
  37469. * Function used to unregister events from window level
  37470. * @param windowElement defines the Window object to use
  37471. * @param events defines the events to unregister
  37472. */
  37473. static UnregisterTopRootEvents(windowElement: Window, events: {
  37474. name: string;
  37475. handler: Nullable<(e: FocusEvent) => any>;
  37476. }[]): void;
  37477. /**
  37478. * @ignore
  37479. */
  37480. static _ScreenshotCanvas: HTMLCanvasElement;
  37481. /**
  37482. * Dumps the current bound framebuffer
  37483. * @param width defines the rendering width
  37484. * @param height defines the rendering height
  37485. * @param engine defines the hosting engine
  37486. * @param successCallback defines the callback triggered once the data are available
  37487. * @param mimeType defines the mime type of the result
  37488. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  37489. */
  37490. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37491. /**
  37492. * Converts the canvas data to blob.
  37493. * This acts as a polyfill for browsers not supporting the to blob function.
  37494. * @param canvas Defines the canvas to extract the data from
  37495. * @param successCallback Defines the callback triggered once the data are available
  37496. * @param mimeType Defines the mime type of the result
  37497. */
  37498. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  37499. /**
  37500. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  37501. * @param successCallback defines the callback triggered once the data are available
  37502. * @param mimeType defines the mime type of the result
  37503. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  37504. */
  37505. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37506. /**
  37507. * Downloads a blob in the browser
  37508. * @param blob defines the blob to download
  37509. * @param fileName defines the name of the downloaded file
  37510. */
  37511. static Download(blob: Blob, fileName: string): void;
  37512. /**
  37513. * Captures a screenshot of the current rendering
  37514. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37515. * @param engine defines the rendering engine
  37516. * @param camera defines the source camera
  37517. * @param size This parameter can be set to a single number or to an object with the
  37518. * following (optional) properties: precision, width, height. If a single number is passed,
  37519. * it will be used for both width and height. If an object is passed, the screenshot size
  37520. * will be derived from the parameters. The precision property is a multiplier allowing
  37521. * rendering at a higher or lower resolution
  37522. * @param successCallback defines the callback receives a single parameter which contains the
  37523. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37524. * src parameter of an <img> to display it
  37525. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37526. * Check your browser for supported MIME types
  37527. */
  37528. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  37529. /**
  37530. * Captures a screenshot of the current rendering
  37531. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37532. * @param engine defines the rendering engine
  37533. * @param camera defines the source camera
  37534. * @param size This parameter can be set to a single number or to an object with the
  37535. * following (optional) properties: precision, width, height. If a single number is passed,
  37536. * it will be used for both width and height. If an object is passed, the screenshot size
  37537. * will be derived from the parameters. The precision property is a multiplier allowing
  37538. * rendering at a higher or lower resolution
  37539. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37540. * Check your browser for supported MIME types
  37541. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37542. * to the src parameter of an <img> to display it
  37543. */
  37544. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  37545. /**
  37546. * Generates an image screenshot from the specified camera.
  37547. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37548. * @param engine The engine to use for rendering
  37549. * @param camera The camera to use for rendering
  37550. * @param size This parameter can be set to a single number or to an object with the
  37551. * following (optional) properties: precision, width, height. If a single number is passed,
  37552. * it will be used for both width and height. If an object is passed, the screenshot size
  37553. * will be derived from the parameters. The precision property is a multiplier allowing
  37554. * rendering at a higher or lower resolution
  37555. * @param successCallback The callback receives a single parameter which contains the
  37556. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37557. * src parameter of an <img> to display it
  37558. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37559. * Check your browser for supported MIME types
  37560. * @param samples Texture samples (default: 1)
  37561. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37562. * @param fileName A name for for the downloaded file.
  37563. */
  37564. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  37565. /**
  37566. * Generates an image screenshot from the specified camera.
  37567. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37568. * @param engine The engine to use for rendering
  37569. * @param camera The camera to use for rendering
  37570. * @param size This parameter can be set to a single number or to an object with the
  37571. * following (optional) properties: precision, width, height. If a single number is passed,
  37572. * it will be used for both width and height. If an object is passed, the screenshot size
  37573. * will be derived from the parameters. The precision property is a multiplier allowing
  37574. * rendering at a higher or lower resolution
  37575. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37576. * Check your browser for supported MIME types
  37577. * @param samples Texture samples (default: 1)
  37578. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37579. * @param fileName A name for for the downloaded file.
  37580. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37581. * to the src parameter of an <img> to display it
  37582. */
  37583. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  37584. /**
  37585. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  37586. * Be aware Math.random() could cause collisions, but:
  37587. * "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"
  37588. * @returns a pseudo random id
  37589. */
  37590. static RandomId(): string;
  37591. /**
  37592. * Test if the given uri is a base64 string
  37593. * @param uri The uri to test
  37594. * @return True if the uri is a base64 string or false otherwise
  37595. */
  37596. static IsBase64(uri: string): boolean;
  37597. /**
  37598. * Decode the given base64 uri.
  37599. * @param uri The uri to decode
  37600. * @return The decoded base64 data.
  37601. */
  37602. static DecodeBase64(uri: string): ArrayBuffer;
  37603. /**
  37604. * Gets the absolute url.
  37605. * @param url the input url
  37606. * @return the absolute url
  37607. */
  37608. static GetAbsoluteUrl(url: string): string;
  37609. /**
  37610. * No log
  37611. */
  37612. static readonly NoneLogLevel: number;
  37613. /**
  37614. * Only message logs
  37615. */
  37616. static readonly MessageLogLevel: number;
  37617. /**
  37618. * Only warning logs
  37619. */
  37620. static readonly WarningLogLevel: number;
  37621. /**
  37622. * Only error logs
  37623. */
  37624. static readonly ErrorLogLevel: number;
  37625. /**
  37626. * All logs
  37627. */
  37628. static readonly AllLogLevel: number;
  37629. /**
  37630. * Gets a value indicating the number of loading errors
  37631. * @ignorenaming
  37632. */
  37633. static get errorsCount(): number;
  37634. /**
  37635. * Callback called when a new log is added
  37636. */
  37637. static OnNewCacheEntry: (entry: string) => void;
  37638. /**
  37639. * Log a message to the console
  37640. * @param message defines the message to log
  37641. */
  37642. static Log(message: string): void;
  37643. /**
  37644. * Write a warning message to the console
  37645. * @param message defines the message to log
  37646. */
  37647. static Warn(message: string): void;
  37648. /**
  37649. * Write an error message to the console
  37650. * @param message defines the message to log
  37651. */
  37652. static Error(message: string): void;
  37653. /**
  37654. * Gets current log cache (list of logs)
  37655. */
  37656. static get LogCache(): string;
  37657. /**
  37658. * Clears the log cache
  37659. */
  37660. static ClearLogCache(): void;
  37661. /**
  37662. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  37663. */
  37664. static set LogLevels(level: number);
  37665. /**
  37666. * Checks if the window object exists
  37667. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  37668. */
  37669. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  37670. /**
  37671. * No performance log
  37672. */
  37673. static readonly PerformanceNoneLogLevel: number;
  37674. /**
  37675. * Use user marks to log performance
  37676. */
  37677. static readonly PerformanceUserMarkLogLevel: number;
  37678. /**
  37679. * Log performance to the console
  37680. */
  37681. static readonly PerformanceConsoleLogLevel: number;
  37682. private static _performance;
  37683. /**
  37684. * Sets the current performance log level
  37685. */
  37686. static set PerformanceLogLevel(level: number);
  37687. private static _StartPerformanceCounterDisabled;
  37688. private static _EndPerformanceCounterDisabled;
  37689. private static _StartUserMark;
  37690. private static _EndUserMark;
  37691. private static _StartPerformanceConsole;
  37692. private static _EndPerformanceConsole;
  37693. /**
  37694. * Starts a performance counter
  37695. */
  37696. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37697. /**
  37698. * Ends a specific performance coutner
  37699. */
  37700. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37701. /**
  37702. * Gets either window.performance.now() if supported or Date.now() else
  37703. */
  37704. static get Now(): number;
  37705. /**
  37706. * This method will return the name of the class used to create the instance of the given object.
  37707. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  37708. * @param object the object to get the class name from
  37709. * @param isType defines if the object is actually a type
  37710. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  37711. */
  37712. static GetClassName(object: any, isType?: boolean): string;
  37713. /**
  37714. * Gets the first element of an array satisfying a given predicate
  37715. * @param array defines the array to browse
  37716. * @param predicate defines the predicate to use
  37717. * @returns null if not found or the element
  37718. */
  37719. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  37720. /**
  37721. * This method will return the name of the full name of the class, including its owning module (if any).
  37722. * 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).
  37723. * @param object the object to get the class name from
  37724. * @param isType defines if the object is actually a type
  37725. * @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.
  37726. * @ignorenaming
  37727. */
  37728. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  37729. /**
  37730. * Returns a promise that resolves after the given amount of time.
  37731. * @param delay Number of milliseconds to delay
  37732. * @returns Promise that resolves after the given amount of time
  37733. */
  37734. static DelayAsync(delay: number): Promise<void>;
  37735. /**
  37736. * Utility function to detect if the current user agent is Safari
  37737. * @returns whether or not the current user agent is safari
  37738. */
  37739. static IsSafari(): boolean;
  37740. }
  37741. /**
  37742. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  37743. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  37744. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  37745. * @param name The name of the class, case should be preserved
  37746. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  37747. */
  37748. export function className(name: string, module?: string): (target: Object) => void;
  37749. /**
  37750. * An implementation of a loop for asynchronous functions.
  37751. */
  37752. export class AsyncLoop {
  37753. /**
  37754. * Defines the number of iterations for the loop
  37755. */
  37756. iterations: number;
  37757. /**
  37758. * Defines the current index of the loop.
  37759. */
  37760. index: number;
  37761. private _done;
  37762. private _fn;
  37763. private _successCallback;
  37764. /**
  37765. * Constructor.
  37766. * @param iterations the number of iterations.
  37767. * @param func the function to run each iteration
  37768. * @param successCallback the callback that will be called upon succesful execution
  37769. * @param offset starting offset.
  37770. */
  37771. constructor(
  37772. /**
  37773. * Defines the number of iterations for the loop
  37774. */
  37775. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  37776. /**
  37777. * Execute the next iteration. Must be called after the last iteration was finished.
  37778. */
  37779. executeNext(): void;
  37780. /**
  37781. * Break the loop and run the success callback.
  37782. */
  37783. breakLoop(): void;
  37784. /**
  37785. * Create and run an async loop.
  37786. * @param iterations the number of iterations.
  37787. * @param fn the function to run each iteration
  37788. * @param successCallback the callback that will be called upon succesful execution
  37789. * @param offset starting offset.
  37790. * @returns the created async loop object
  37791. */
  37792. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  37793. /**
  37794. * A for-loop that will run a given number of iterations synchronous and the rest async.
  37795. * @param iterations total number of iterations
  37796. * @param syncedIterations number of synchronous iterations in each async iteration.
  37797. * @param fn the function to call each iteration.
  37798. * @param callback a success call back that will be called when iterating stops.
  37799. * @param breakFunction a break condition (optional)
  37800. * @param timeout timeout settings for the setTimeout function. default - 0.
  37801. * @returns the created async loop object
  37802. */
  37803. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  37804. }
  37805. }
  37806. declare module BABYLON {
  37807. /**
  37808. * This class implement a typical dictionary using a string as key and the generic type T as value.
  37809. * The underlying implementation relies on an associative array to ensure the best performances.
  37810. * The value can be anything including 'null' but except 'undefined'
  37811. */
  37812. export class StringDictionary<T> {
  37813. /**
  37814. * This will clear this dictionary and copy the content from the 'source' one.
  37815. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  37816. * @param source the dictionary to take the content from and copy to this dictionary
  37817. */
  37818. copyFrom(source: StringDictionary<T>): void;
  37819. /**
  37820. * Get a value based from its key
  37821. * @param key the given key to get the matching value from
  37822. * @return the value if found, otherwise undefined is returned
  37823. */
  37824. get(key: string): T | undefined;
  37825. /**
  37826. * Get a value from its key or add it if it doesn't exist.
  37827. * This method will ensure you that a given key/data will be present in the dictionary.
  37828. * @param key the given key to get the matching value from
  37829. * @param factory the factory that will create the value if the key is not present in the dictionary.
  37830. * The factory will only be invoked if there's no data for the given key.
  37831. * @return the value corresponding to the key.
  37832. */
  37833. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  37834. /**
  37835. * Get a value from its key if present in the dictionary otherwise add it
  37836. * @param key the key to get the value from
  37837. * @param val if there's no such key/value pair in the dictionary add it with this value
  37838. * @return the value corresponding to the key
  37839. */
  37840. getOrAdd(key: string, val: T): T;
  37841. /**
  37842. * Check if there's a given key in the dictionary
  37843. * @param key the key to check for
  37844. * @return true if the key is present, false otherwise
  37845. */
  37846. contains(key: string): boolean;
  37847. /**
  37848. * Add a new key and its corresponding value
  37849. * @param key the key to add
  37850. * @param value the value corresponding to the key
  37851. * @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
  37852. */
  37853. add(key: string, value: T): boolean;
  37854. /**
  37855. * Update a specific value associated to a key
  37856. * @param key defines the key to use
  37857. * @param value defines the value to store
  37858. * @returns true if the value was updated (or false if the key was not found)
  37859. */
  37860. set(key: string, value: T): boolean;
  37861. /**
  37862. * Get the element of the given key and remove it from the dictionary
  37863. * @param key defines the key to search
  37864. * @returns the value associated with the key or null if not found
  37865. */
  37866. getAndRemove(key: string): Nullable<T>;
  37867. /**
  37868. * Remove a key/value from the dictionary.
  37869. * @param key the key to remove
  37870. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  37871. */
  37872. remove(key: string): boolean;
  37873. /**
  37874. * Clear the whole content of the dictionary
  37875. */
  37876. clear(): void;
  37877. /**
  37878. * Gets the current count
  37879. */
  37880. get count(): number;
  37881. /**
  37882. * Execute a callback on each key/val of the dictionary.
  37883. * Note that you can remove any element in this dictionary in the callback implementation
  37884. * @param callback the callback to execute on a given key/value pair
  37885. */
  37886. forEach(callback: (key: string, val: T) => void): void;
  37887. /**
  37888. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  37889. * If the callback returns null or undefined the method will iterate to the next key/value pair
  37890. * Note that you can remove any element in this dictionary in the callback implementation
  37891. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  37892. * @returns the first item
  37893. */
  37894. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  37895. private _count;
  37896. private _data;
  37897. }
  37898. }
  37899. declare module BABYLON {
  37900. /** @hidden */
  37901. export interface ICollisionCoordinator {
  37902. createCollider(): Collider;
  37903. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37904. init(scene: Scene): void;
  37905. }
  37906. /** @hidden */
  37907. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  37908. private _scene;
  37909. private _scaledPosition;
  37910. private _scaledVelocity;
  37911. private _finalPosition;
  37912. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37913. createCollider(): Collider;
  37914. init(scene: Scene): void;
  37915. private _collideWithWorld;
  37916. }
  37917. }
  37918. declare module BABYLON {
  37919. /**
  37920. * Class used to manage all inputs for the scene.
  37921. */
  37922. export class InputManager {
  37923. /** The distance in pixel that you have to move to prevent some events */
  37924. static DragMovementThreshold: number;
  37925. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  37926. static LongPressDelay: number;
  37927. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  37928. static DoubleClickDelay: number;
  37929. /** If you need to check double click without raising a single click at first click, enable this flag */
  37930. static ExclusiveDoubleClickMode: boolean;
  37931. private _wheelEventName;
  37932. private _onPointerMove;
  37933. private _onPointerDown;
  37934. private _onPointerUp;
  37935. private _initClickEvent;
  37936. private _initActionManager;
  37937. private _delayedSimpleClick;
  37938. private _delayedSimpleClickTimeout;
  37939. private _previousDelayedSimpleClickTimeout;
  37940. private _meshPickProceed;
  37941. private _previousButtonPressed;
  37942. private _currentPickResult;
  37943. private _previousPickResult;
  37944. private _totalPointersPressed;
  37945. private _doubleClickOccured;
  37946. private _pointerOverMesh;
  37947. private _pickedDownMesh;
  37948. private _pickedUpMesh;
  37949. private _pointerX;
  37950. private _pointerY;
  37951. private _unTranslatedPointerX;
  37952. private _unTranslatedPointerY;
  37953. private _startingPointerPosition;
  37954. private _previousStartingPointerPosition;
  37955. private _startingPointerTime;
  37956. private _previousStartingPointerTime;
  37957. private _pointerCaptures;
  37958. private _onKeyDown;
  37959. private _onKeyUp;
  37960. private _onCanvasFocusObserver;
  37961. private _onCanvasBlurObserver;
  37962. private _scene;
  37963. /**
  37964. * Creates a new InputManager
  37965. * @param scene defines the hosting scene
  37966. */
  37967. constructor(scene: Scene);
  37968. /**
  37969. * Gets the mesh that is currently under the pointer
  37970. */
  37971. get meshUnderPointer(): Nullable<AbstractMesh>;
  37972. /**
  37973. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  37974. */
  37975. get unTranslatedPointer(): Vector2;
  37976. /**
  37977. * Gets or sets the current on-screen X position of the pointer
  37978. */
  37979. get pointerX(): number;
  37980. set pointerX(value: number);
  37981. /**
  37982. * Gets or sets the current on-screen Y position of the pointer
  37983. */
  37984. get pointerY(): number;
  37985. set pointerY(value: number);
  37986. private _updatePointerPosition;
  37987. private _processPointerMove;
  37988. private _setRayOnPointerInfo;
  37989. private _checkPrePointerObservable;
  37990. /**
  37991. * Use this method to simulate a pointer move on a mesh
  37992. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37993. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37994. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37995. */
  37996. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  37997. /**
  37998. * Use this method to simulate a pointer down on a mesh
  37999. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38000. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38001. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38002. */
  38003. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38004. private _processPointerDown;
  38005. /** @hidden */
  38006. _isPointerSwiping(): boolean;
  38007. /**
  38008. * Use this method to simulate a pointer up on a mesh
  38009. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38010. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38011. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38012. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  38013. */
  38014. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  38015. private _processPointerUp;
  38016. /**
  38017. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  38018. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  38019. * @returns true if the pointer was captured
  38020. */
  38021. isPointerCaptured(pointerId?: number): boolean;
  38022. /**
  38023. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  38024. * @param attachUp defines if you want to attach events to pointerup
  38025. * @param attachDown defines if you want to attach events to pointerdown
  38026. * @param attachMove defines if you want to attach events to pointermove
  38027. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  38028. */
  38029. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  38030. /**
  38031. * Detaches all event handlers
  38032. */
  38033. detachControl(): void;
  38034. /**
  38035. * Force the value of meshUnderPointer
  38036. * @param mesh defines the mesh to use
  38037. */
  38038. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  38039. /**
  38040. * Gets the mesh under the pointer
  38041. * @returns a Mesh or null if no mesh is under the pointer
  38042. */
  38043. getPointerOverMesh(): Nullable<AbstractMesh>;
  38044. }
  38045. }
  38046. declare module BABYLON {
  38047. /**
  38048. * This class defines the direct association between an animation and a target
  38049. */
  38050. export class TargetedAnimation {
  38051. /**
  38052. * Animation to perform
  38053. */
  38054. animation: Animation;
  38055. /**
  38056. * Target to animate
  38057. */
  38058. target: any;
  38059. /**
  38060. * Returns the string "TargetedAnimation"
  38061. * @returns "TargetedAnimation"
  38062. */
  38063. getClassName(): string;
  38064. /**
  38065. * Serialize the object
  38066. * @returns the JSON object representing the current entity
  38067. */
  38068. serialize(): any;
  38069. }
  38070. /**
  38071. * Use this class to create coordinated animations on multiple targets
  38072. */
  38073. export class AnimationGroup implements IDisposable {
  38074. /** The name of the animation group */
  38075. name: string;
  38076. private _scene;
  38077. private _targetedAnimations;
  38078. private _animatables;
  38079. private _from;
  38080. private _to;
  38081. private _isStarted;
  38082. private _isPaused;
  38083. private _speedRatio;
  38084. private _loopAnimation;
  38085. private _isAdditive;
  38086. /**
  38087. * Gets or sets the unique id of the node
  38088. */
  38089. uniqueId: number;
  38090. /**
  38091. * This observable will notify when one animation have ended
  38092. */
  38093. onAnimationEndObservable: Observable<TargetedAnimation>;
  38094. /**
  38095. * Observer raised when one animation loops
  38096. */
  38097. onAnimationLoopObservable: Observable<TargetedAnimation>;
  38098. /**
  38099. * Observer raised when all animations have looped
  38100. */
  38101. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  38102. /**
  38103. * This observable will notify when all animations have ended.
  38104. */
  38105. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  38106. /**
  38107. * This observable will notify when all animations have paused.
  38108. */
  38109. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  38110. /**
  38111. * This observable will notify when all animations are playing.
  38112. */
  38113. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  38114. /**
  38115. * Gets the first frame
  38116. */
  38117. get from(): number;
  38118. /**
  38119. * Gets the last frame
  38120. */
  38121. get to(): number;
  38122. /**
  38123. * Define if the animations are started
  38124. */
  38125. get isStarted(): boolean;
  38126. /**
  38127. * Gets a value indicating that the current group is playing
  38128. */
  38129. get isPlaying(): boolean;
  38130. /**
  38131. * Gets or sets the speed ratio to use for all animations
  38132. */
  38133. get speedRatio(): number;
  38134. /**
  38135. * Gets or sets the speed ratio to use for all animations
  38136. */
  38137. set speedRatio(value: number);
  38138. /**
  38139. * Gets or sets if all animations should loop or not
  38140. */
  38141. get loopAnimation(): boolean;
  38142. set loopAnimation(value: boolean);
  38143. /**
  38144. * Gets or sets if all animations should be evaluated additively
  38145. */
  38146. get isAdditive(): boolean;
  38147. set isAdditive(value: boolean);
  38148. /**
  38149. * Gets the targeted animations for this animation group
  38150. */
  38151. get targetedAnimations(): Array<TargetedAnimation>;
  38152. /**
  38153. * returning the list of animatables controlled by this animation group.
  38154. */
  38155. get animatables(): Array<Animatable>;
  38156. /**
  38157. * Gets the list of target animations
  38158. */
  38159. get children(): TargetedAnimation[];
  38160. /**
  38161. * Instantiates a new Animation Group.
  38162. * This helps managing several animations at once.
  38163. * @see http://doc.babylonjs.com/how_to/group
  38164. * @param name Defines the name of the group
  38165. * @param scene Defines the scene the group belongs to
  38166. */
  38167. constructor(
  38168. /** The name of the animation group */
  38169. name: string, scene?: Nullable<Scene>);
  38170. /**
  38171. * Add an animation (with its target) in the group
  38172. * @param animation defines the animation we want to add
  38173. * @param target defines the target of the animation
  38174. * @returns the TargetedAnimation object
  38175. */
  38176. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  38177. /**
  38178. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  38179. * It can add constant keys at begin or end
  38180. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  38181. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  38182. * @returns the animation group
  38183. */
  38184. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  38185. private _animationLoopCount;
  38186. private _animationLoopFlags;
  38187. private _processLoop;
  38188. /**
  38189. * Start all animations on given targets
  38190. * @param loop defines if animations must loop
  38191. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  38192. * @param from defines the from key (optional)
  38193. * @param to defines the to key (optional)
  38194. * @param isAdditive defines the additive state for the resulting animatables (optional)
  38195. * @returns the current animation group
  38196. */
  38197. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  38198. /**
  38199. * Pause all animations
  38200. * @returns the animation group
  38201. */
  38202. pause(): AnimationGroup;
  38203. /**
  38204. * Play all animations to initial state
  38205. * This function will start() the animations if they were not started or will restart() them if they were paused
  38206. * @param loop defines if animations must loop
  38207. * @returns the animation group
  38208. */
  38209. play(loop?: boolean): AnimationGroup;
  38210. /**
  38211. * Reset all animations to initial state
  38212. * @returns the animation group
  38213. */
  38214. reset(): AnimationGroup;
  38215. /**
  38216. * Restart animations from key 0
  38217. * @returns the animation group
  38218. */
  38219. restart(): AnimationGroup;
  38220. /**
  38221. * Stop all animations
  38222. * @returns the animation group
  38223. */
  38224. stop(): AnimationGroup;
  38225. /**
  38226. * Set animation weight for all animatables
  38227. * @param weight defines the weight to use
  38228. * @return the animationGroup
  38229. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  38230. */
  38231. setWeightForAllAnimatables(weight: number): AnimationGroup;
  38232. /**
  38233. * Synchronize and normalize all animatables with a source animatable
  38234. * @param root defines the root animatable to synchronize with
  38235. * @return the animationGroup
  38236. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  38237. */
  38238. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  38239. /**
  38240. * Goes to a specific frame in this animation group
  38241. * @param frame the frame number to go to
  38242. * @return the animationGroup
  38243. */
  38244. goToFrame(frame: number): AnimationGroup;
  38245. /**
  38246. * Dispose all associated resources
  38247. */
  38248. dispose(): void;
  38249. private _checkAnimationGroupEnded;
  38250. /**
  38251. * Clone the current animation group and returns a copy
  38252. * @param newName defines the name of the new group
  38253. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  38254. * @returns the new aniamtion group
  38255. */
  38256. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  38257. /**
  38258. * Serializes the animationGroup to an object
  38259. * @returns Serialized object
  38260. */
  38261. serialize(): any;
  38262. /**
  38263. * Returns a new AnimationGroup object parsed from the source provided.
  38264. * @param parsedAnimationGroup defines the source
  38265. * @param scene defines the scene that will receive the animationGroup
  38266. * @returns a new AnimationGroup
  38267. */
  38268. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  38269. /**
  38270. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  38271. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  38272. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  38273. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  38274. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  38275. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  38276. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  38277. */
  38278. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  38279. /**
  38280. * Returns the string "AnimationGroup"
  38281. * @returns "AnimationGroup"
  38282. */
  38283. getClassName(): string;
  38284. /**
  38285. * Creates a detailled string about the object
  38286. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  38287. * @returns a string representing the object
  38288. */
  38289. toString(fullDetails?: boolean): string;
  38290. }
  38291. }
  38292. declare module BABYLON {
  38293. /**
  38294. * Define an interface for all classes that will hold resources
  38295. */
  38296. export interface IDisposable {
  38297. /**
  38298. * Releases all held resources
  38299. */
  38300. dispose(): void;
  38301. }
  38302. /** Interface defining initialization parameters for Scene class */
  38303. export interface SceneOptions {
  38304. /**
  38305. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  38306. * It will improve performance when the number of geometries becomes important.
  38307. */
  38308. useGeometryUniqueIdsMap?: boolean;
  38309. /**
  38310. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  38311. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38312. */
  38313. useMaterialMeshMap?: boolean;
  38314. /**
  38315. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  38316. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38317. */
  38318. useClonedMeshMap?: boolean;
  38319. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  38320. virtual?: boolean;
  38321. }
  38322. /**
  38323. * Represents a scene to be rendered by the engine.
  38324. * @see http://doc.babylonjs.com/features/scene
  38325. */
  38326. export class Scene extends AbstractScene implements IAnimatable {
  38327. /** The fog is deactivated */
  38328. static readonly FOGMODE_NONE: number;
  38329. /** The fog density is following an exponential function */
  38330. static readonly FOGMODE_EXP: number;
  38331. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  38332. static readonly FOGMODE_EXP2: number;
  38333. /** The fog density is following a linear function. */
  38334. static readonly FOGMODE_LINEAR: number;
  38335. /**
  38336. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  38337. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38338. */
  38339. static MinDeltaTime: number;
  38340. /**
  38341. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  38342. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38343. */
  38344. static MaxDeltaTime: number;
  38345. /**
  38346. * Factory used to create the default material.
  38347. * @param name The name of the material to create
  38348. * @param scene The scene to create the material for
  38349. * @returns The default material
  38350. */
  38351. static DefaultMaterialFactory(scene: Scene): Material;
  38352. /**
  38353. * Factory used to create the a collision coordinator.
  38354. * @returns The collision coordinator
  38355. */
  38356. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  38357. /** @hidden */
  38358. _inputManager: InputManager;
  38359. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  38360. cameraToUseForPointers: Nullable<Camera>;
  38361. /** @hidden */
  38362. readonly _isScene: boolean;
  38363. /** @hidden */
  38364. _blockEntityCollection: boolean;
  38365. /**
  38366. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  38367. */
  38368. autoClear: boolean;
  38369. /**
  38370. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  38371. */
  38372. autoClearDepthAndStencil: boolean;
  38373. /**
  38374. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  38375. */
  38376. clearColor: Color4;
  38377. /**
  38378. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  38379. */
  38380. ambientColor: Color3;
  38381. /**
  38382. * This is use to store the default BRDF lookup for PBR materials in your scene.
  38383. * It should only be one of the following (if not the default embedded one):
  38384. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  38385. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  38386. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  38387. * The material properties need to be setup according to the type of texture in use.
  38388. */
  38389. environmentBRDFTexture: BaseTexture;
  38390. /** @hidden */
  38391. protected _environmentTexture: Nullable<BaseTexture>;
  38392. /**
  38393. * Texture used in all pbr material as the reflection texture.
  38394. * As in the majority of the scene they are the same (exception for multi room and so on),
  38395. * this is easier to reference from here than from all the materials.
  38396. */
  38397. get environmentTexture(): Nullable<BaseTexture>;
  38398. /**
  38399. * Texture used in all pbr material as the reflection texture.
  38400. * As in the majority of the scene they are the same (exception for multi room and so on),
  38401. * this is easier to set here than in all the materials.
  38402. */
  38403. set environmentTexture(value: Nullable<BaseTexture>);
  38404. /** @hidden */
  38405. protected _environmentIntensity: number;
  38406. /**
  38407. * Intensity of the environment in all pbr material.
  38408. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38409. * As in the majority of the scene they are the same (exception for multi room and so on),
  38410. * this is easier to reference from here than from all the materials.
  38411. */
  38412. get environmentIntensity(): number;
  38413. /**
  38414. * Intensity of the environment in all pbr material.
  38415. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38416. * As in the majority of the scene they are the same (exception for multi room and so on),
  38417. * this is easier to set here than in all the materials.
  38418. */
  38419. set environmentIntensity(value: number);
  38420. /** @hidden */
  38421. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38422. /**
  38423. * Default image processing configuration used either in the rendering
  38424. * Forward main pass or through the imageProcessingPostProcess if present.
  38425. * As in the majority of the scene they are the same (exception for multi camera),
  38426. * this is easier to reference from here than from all the materials and post process.
  38427. *
  38428. * No setter as we it is a shared configuration, you can set the values instead.
  38429. */
  38430. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  38431. private _forceWireframe;
  38432. /**
  38433. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  38434. */
  38435. set forceWireframe(value: boolean);
  38436. get forceWireframe(): boolean;
  38437. private _skipFrustumClipping;
  38438. /**
  38439. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  38440. */
  38441. set skipFrustumClipping(value: boolean);
  38442. get skipFrustumClipping(): boolean;
  38443. private _forcePointsCloud;
  38444. /**
  38445. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  38446. */
  38447. set forcePointsCloud(value: boolean);
  38448. get forcePointsCloud(): boolean;
  38449. /**
  38450. * Gets or sets the active clipplane 1
  38451. */
  38452. clipPlane: Nullable<Plane>;
  38453. /**
  38454. * Gets or sets the active clipplane 2
  38455. */
  38456. clipPlane2: Nullable<Plane>;
  38457. /**
  38458. * Gets or sets the active clipplane 3
  38459. */
  38460. clipPlane3: Nullable<Plane>;
  38461. /**
  38462. * Gets or sets the active clipplane 4
  38463. */
  38464. clipPlane4: Nullable<Plane>;
  38465. /**
  38466. * Gets or sets the active clipplane 5
  38467. */
  38468. clipPlane5: Nullable<Plane>;
  38469. /**
  38470. * Gets or sets the active clipplane 6
  38471. */
  38472. clipPlane6: Nullable<Plane>;
  38473. /**
  38474. * Gets or sets a boolean indicating if animations are enabled
  38475. */
  38476. animationsEnabled: boolean;
  38477. private _animationPropertiesOverride;
  38478. /**
  38479. * Gets or sets the animation properties override
  38480. */
  38481. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  38482. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  38483. /**
  38484. * Gets or sets a boolean indicating if a constant deltatime has to be used
  38485. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  38486. */
  38487. useConstantAnimationDeltaTime: boolean;
  38488. /**
  38489. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  38490. * Please note that it requires to run a ray cast through the scene on every frame
  38491. */
  38492. constantlyUpdateMeshUnderPointer: boolean;
  38493. /**
  38494. * Defines the HTML cursor to use when hovering over interactive elements
  38495. */
  38496. hoverCursor: string;
  38497. /**
  38498. * Defines the HTML default cursor to use (empty by default)
  38499. */
  38500. defaultCursor: string;
  38501. /**
  38502. * Defines whether cursors are handled by the scene.
  38503. */
  38504. doNotHandleCursors: boolean;
  38505. /**
  38506. * This is used to call preventDefault() on pointer down
  38507. * in order to block unwanted artifacts like system double clicks
  38508. */
  38509. preventDefaultOnPointerDown: boolean;
  38510. /**
  38511. * This is used to call preventDefault() on pointer up
  38512. * in order to block unwanted artifacts like system double clicks
  38513. */
  38514. preventDefaultOnPointerUp: boolean;
  38515. /**
  38516. * Gets or sets user defined metadata
  38517. */
  38518. metadata: any;
  38519. /**
  38520. * For internal use only. Please do not use.
  38521. */
  38522. reservedDataStore: any;
  38523. /**
  38524. * Gets the name of the plugin used to load this scene (null by default)
  38525. */
  38526. loadingPluginName: string;
  38527. /**
  38528. * Use this array to add regular expressions used to disable offline support for specific urls
  38529. */
  38530. disableOfflineSupportExceptionRules: RegExp[];
  38531. /**
  38532. * An event triggered when the scene is disposed.
  38533. */
  38534. onDisposeObservable: Observable<Scene>;
  38535. private _onDisposeObserver;
  38536. /** Sets a function to be executed when this scene is disposed. */
  38537. set onDispose(callback: () => void);
  38538. /**
  38539. * An event triggered before rendering the scene (right after animations and physics)
  38540. */
  38541. onBeforeRenderObservable: Observable<Scene>;
  38542. private _onBeforeRenderObserver;
  38543. /** Sets a function to be executed before rendering this scene */
  38544. set beforeRender(callback: Nullable<() => void>);
  38545. /**
  38546. * An event triggered after rendering the scene
  38547. */
  38548. onAfterRenderObservable: Observable<Scene>;
  38549. /**
  38550. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  38551. */
  38552. onAfterRenderCameraObservable: Observable<Camera>;
  38553. private _onAfterRenderObserver;
  38554. /** Sets a function to be executed after rendering this scene */
  38555. set afterRender(callback: Nullable<() => void>);
  38556. /**
  38557. * An event triggered before animating the scene
  38558. */
  38559. onBeforeAnimationsObservable: Observable<Scene>;
  38560. /**
  38561. * An event triggered after animations processing
  38562. */
  38563. onAfterAnimationsObservable: Observable<Scene>;
  38564. /**
  38565. * An event triggered before draw calls are ready to be sent
  38566. */
  38567. onBeforeDrawPhaseObservable: Observable<Scene>;
  38568. /**
  38569. * An event triggered after draw calls have been sent
  38570. */
  38571. onAfterDrawPhaseObservable: Observable<Scene>;
  38572. /**
  38573. * An event triggered when the scene is ready
  38574. */
  38575. onReadyObservable: Observable<Scene>;
  38576. /**
  38577. * An event triggered before rendering a camera
  38578. */
  38579. onBeforeCameraRenderObservable: Observable<Camera>;
  38580. private _onBeforeCameraRenderObserver;
  38581. /** Sets a function to be executed before rendering a camera*/
  38582. set beforeCameraRender(callback: () => void);
  38583. /**
  38584. * An event triggered after rendering a camera
  38585. */
  38586. onAfterCameraRenderObservable: Observable<Camera>;
  38587. private _onAfterCameraRenderObserver;
  38588. /** Sets a function to be executed after rendering a camera*/
  38589. set afterCameraRender(callback: () => void);
  38590. /**
  38591. * An event triggered when active meshes evaluation is about to start
  38592. */
  38593. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  38594. /**
  38595. * An event triggered when active meshes evaluation is done
  38596. */
  38597. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  38598. /**
  38599. * An event triggered when particles rendering is about to start
  38600. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38601. */
  38602. onBeforeParticlesRenderingObservable: Observable<Scene>;
  38603. /**
  38604. * An event triggered when particles rendering is done
  38605. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38606. */
  38607. onAfterParticlesRenderingObservable: Observable<Scene>;
  38608. /**
  38609. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  38610. */
  38611. onDataLoadedObservable: Observable<Scene>;
  38612. /**
  38613. * An event triggered when a camera is created
  38614. */
  38615. onNewCameraAddedObservable: Observable<Camera>;
  38616. /**
  38617. * An event triggered when a camera is removed
  38618. */
  38619. onCameraRemovedObservable: Observable<Camera>;
  38620. /**
  38621. * An event triggered when a light is created
  38622. */
  38623. onNewLightAddedObservable: Observable<Light>;
  38624. /**
  38625. * An event triggered when a light is removed
  38626. */
  38627. onLightRemovedObservable: Observable<Light>;
  38628. /**
  38629. * An event triggered when a geometry is created
  38630. */
  38631. onNewGeometryAddedObservable: Observable<Geometry>;
  38632. /**
  38633. * An event triggered when a geometry is removed
  38634. */
  38635. onGeometryRemovedObservable: Observable<Geometry>;
  38636. /**
  38637. * An event triggered when a transform node is created
  38638. */
  38639. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  38640. /**
  38641. * An event triggered when a transform node is removed
  38642. */
  38643. onTransformNodeRemovedObservable: Observable<TransformNode>;
  38644. /**
  38645. * An event triggered when a mesh is created
  38646. */
  38647. onNewMeshAddedObservable: Observable<AbstractMesh>;
  38648. /**
  38649. * An event triggered when a mesh is removed
  38650. */
  38651. onMeshRemovedObservable: Observable<AbstractMesh>;
  38652. /**
  38653. * An event triggered when a skeleton is created
  38654. */
  38655. onNewSkeletonAddedObservable: Observable<Skeleton>;
  38656. /**
  38657. * An event triggered when a skeleton is removed
  38658. */
  38659. onSkeletonRemovedObservable: Observable<Skeleton>;
  38660. /**
  38661. * An event triggered when a material is created
  38662. */
  38663. onNewMaterialAddedObservable: Observable<Material>;
  38664. /**
  38665. * An event triggered when a material is removed
  38666. */
  38667. onMaterialRemovedObservable: Observable<Material>;
  38668. /**
  38669. * An event triggered when a texture is created
  38670. */
  38671. onNewTextureAddedObservable: Observable<BaseTexture>;
  38672. /**
  38673. * An event triggered when a texture is removed
  38674. */
  38675. onTextureRemovedObservable: Observable<BaseTexture>;
  38676. /**
  38677. * An event triggered when render targets are about to be rendered
  38678. * Can happen multiple times per frame.
  38679. */
  38680. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  38681. /**
  38682. * An event triggered when render targets were rendered.
  38683. * Can happen multiple times per frame.
  38684. */
  38685. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  38686. /**
  38687. * An event triggered before calculating deterministic simulation step
  38688. */
  38689. onBeforeStepObservable: Observable<Scene>;
  38690. /**
  38691. * An event triggered after calculating deterministic simulation step
  38692. */
  38693. onAfterStepObservable: Observable<Scene>;
  38694. /**
  38695. * An event triggered when the activeCamera property is updated
  38696. */
  38697. onActiveCameraChanged: Observable<Scene>;
  38698. /**
  38699. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  38700. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38701. * 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)
  38702. */
  38703. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38704. /**
  38705. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  38706. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38707. * 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)
  38708. */
  38709. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38710. /**
  38711. * This Observable will when a mesh has been imported into the scene.
  38712. */
  38713. onMeshImportedObservable: Observable<AbstractMesh>;
  38714. /**
  38715. * This Observable will when an animation file has been imported into the scene.
  38716. */
  38717. onAnimationFileImportedObservable: Observable<Scene>;
  38718. /**
  38719. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  38720. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  38721. */
  38722. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  38723. /** @hidden */
  38724. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  38725. /**
  38726. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  38727. */
  38728. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  38729. /**
  38730. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  38731. */
  38732. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  38733. /**
  38734. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  38735. */
  38736. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  38737. /** Callback called when a pointer move is detected */
  38738. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38739. /** Callback called when a pointer down is detected */
  38740. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38741. /** Callback called when a pointer up is detected */
  38742. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  38743. /** Callback called when a pointer pick is detected */
  38744. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  38745. /**
  38746. * 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).
  38747. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  38748. */
  38749. onPrePointerObservable: Observable<PointerInfoPre>;
  38750. /**
  38751. * Observable event triggered each time an input event is received from the rendering canvas
  38752. */
  38753. onPointerObservable: Observable<PointerInfo>;
  38754. /**
  38755. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  38756. */
  38757. get unTranslatedPointer(): Vector2;
  38758. /**
  38759. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  38760. */
  38761. static get DragMovementThreshold(): number;
  38762. static set DragMovementThreshold(value: number);
  38763. /**
  38764. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  38765. */
  38766. static get LongPressDelay(): number;
  38767. static set LongPressDelay(value: number);
  38768. /**
  38769. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  38770. */
  38771. static get DoubleClickDelay(): number;
  38772. static set DoubleClickDelay(value: number);
  38773. /** If you need to check double click without raising a single click at first click, enable this flag */
  38774. static get ExclusiveDoubleClickMode(): boolean;
  38775. static set ExclusiveDoubleClickMode(value: boolean);
  38776. /** @hidden */
  38777. _mirroredCameraPosition: Nullable<Vector3>;
  38778. /**
  38779. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  38780. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  38781. */
  38782. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  38783. /**
  38784. * Observable event triggered each time an keyboard event is received from the hosting window
  38785. */
  38786. onKeyboardObservable: Observable<KeyboardInfo>;
  38787. private _useRightHandedSystem;
  38788. /**
  38789. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  38790. */
  38791. set useRightHandedSystem(value: boolean);
  38792. get useRightHandedSystem(): boolean;
  38793. private _timeAccumulator;
  38794. private _currentStepId;
  38795. private _currentInternalStep;
  38796. /**
  38797. * Sets the step Id used by deterministic lock step
  38798. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38799. * @param newStepId defines the step Id
  38800. */
  38801. setStepId(newStepId: number): void;
  38802. /**
  38803. * Gets the step Id used by deterministic lock step
  38804. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38805. * @returns the step Id
  38806. */
  38807. getStepId(): number;
  38808. /**
  38809. * Gets the internal step used by deterministic lock step
  38810. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38811. * @returns the internal step
  38812. */
  38813. getInternalStep(): number;
  38814. private _fogEnabled;
  38815. /**
  38816. * Gets or sets a boolean indicating if fog is enabled on this scene
  38817. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38818. * (Default is true)
  38819. */
  38820. set fogEnabled(value: boolean);
  38821. get fogEnabled(): boolean;
  38822. private _fogMode;
  38823. /**
  38824. * Gets or sets the fog mode to use
  38825. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38826. * | mode | value |
  38827. * | --- | --- |
  38828. * | FOGMODE_NONE | 0 |
  38829. * | FOGMODE_EXP | 1 |
  38830. * | FOGMODE_EXP2 | 2 |
  38831. * | FOGMODE_LINEAR | 3 |
  38832. */
  38833. set fogMode(value: number);
  38834. get fogMode(): number;
  38835. /**
  38836. * Gets or sets the fog color to use
  38837. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38838. * (Default is Color3(0.2, 0.2, 0.3))
  38839. */
  38840. fogColor: Color3;
  38841. /**
  38842. * Gets or sets the fog density to use
  38843. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38844. * (Default is 0.1)
  38845. */
  38846. fogDensity: number;
  38847. /**
  38848. * Gets or sets the fog start distance to use
  38849. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38850. * (Default is 0)
  38851. */
  38852. fogStart: number;
  38853. /**
  38854. * Gets or sets the fog end distance to use
  38855. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38856. * (Default is 1000)
  38857. */
  38858. fogEnd: number;
  38859. private _shadowsEnabled;
  38860. /**
  38861. * Gets or sets a boolean indicating if shadows are enabled on this scene
  38862. */
  38863. set shadowsEnabled(value: boolean);
  38864. get shadowsEnabled(): boolean;
  38865. private _lightsEnabled;
  38866. /**
  38867. * Gets or sets a boolean indicating if lights are enabled on this scene
  38868. */
  38869. set lightsEnabled(value: boolean);
  38870. get lightsEnabled(): boolean;
  38871. /** All of the active cameras added to this scene. */
  38872. activeCameras: Camera[];
  38873. /** @hidden */
  38874. _activeCamera: Nullable<Camera>;
  38875. /** Gets or sets the current active camera */
  38876. get activeCamera(): Nullable<Camera>;
  38877. set activeCamera(value: Nullable<Camera>);
  38878. private _defaultMaterial;
  38879. /** The default material used on meshes when no material is affected */
  38880. get defaultMaterial(): Material;
  38881. /** The default material used on meshes when no material is affected */
  38882. set defaultMaterial(value: Material);
  38883. private _texturesEnabled;
  38884. /**
  38885. * Gets or sets a boolean indicating if textures are enabled on this scene
  38886. */
  38887. set texturesEnabled(value: boolean);
  38888. get texturesEnabled(): boolean;
  38889. /**
  38890. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  38891. */
  38892. physicsEnabled: boolean;
  38893. /**
  38894. * Gets or sets a boolean indicating if particles are enabled on this scene
  38895. */
  38896. particlesEnabled: boolean;
  38897. /**
  38898. * Gets or sets a boolean indicating if sprites are enabled on this scene
  38899. */
  38900. spritesEnabled: boolean;
  38901. private _skeletonsEnabled;
  38902. /**
  38903. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  38904. */
  38905. set skeletonsEnabled(value: boolean);
  38906. get skeletonsEnabled(): boolean;
  38907. /**
  38908. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  38909. */
  38910. lensFlaresEnabled: boolean;
  38911. /**
  38912. * Gets or sets a boolean indicating if collisions are enabled on this scene
  38913. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38914. */
  38915. collisionsEnabled: boolean;
  38916. private _collisionCoordinator;
  38917. /** @hidden */
  38918. get collisionCoordinator(): ICollisionCoordinator;
  38919. /**
  38920. * Defines the gravity applied to this scene (used only for collisions)
  38921. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38922. */
  38923. gravity: Vector3;
  38924. /**
  38925. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  38926. */
  38927. postProcessesEnabled: boolean;
  38928. /**
  38929. * The list of postprocesses added to the scene
  38930. */
  38931. postProcesses: PostProcess[];
  38932. /**
  38933. * Gets the current postprocess manager
  38934. */
  38935. postProcessManager: PostProcessManager;
  38936. /**
  38937. * Gets or sets a boolean indicating if render targets are enabled on this scene
  38938. */
  38939. renderTargetsEnabled: boolean;
  38940. /**
  38941. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  38942. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  38943. */
  38944. dumpNextRenderTargets: boolean;
  38945. /**
  38946. * The list of user defined render targets added to the scene
  38947. */
  38948. customRenderTargets: RenderTargetTexture[];
  38949. /**
  38950. * Defines if texture loading must be delayed
  38951. * If true, textures will only be loaded when they need to be rendered
  38952. */
  38953. useDelayedTextureLoading: boolean;
  38954. /**
  38955. * Gets the list of meshes imported to the scene through SceneLoader
  38956. */
  38957. importedMeshesFiles: String[];
  38958. /**
  38959. * Gets or sets a boolean indicating if probes are enabled on this scene
  38960. */
  38961. probesEnabled: boolean;
  38962. /**
  38963. * Gets or sets the current offline provider to use to store scene data
  38964. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  38965. */
  38966. offlineProvider: IOfflineProvider;
  38967. /**
  38968. * Gets or sets the action manager associated with the scene
  38969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38970. */
  38971. actionManager: AbstractActionManager;
  38972. private _meshesForIntersections;
  38973. /**
  38974. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  38975. */
  38976. proceduralTexturesEnabled: boolean;
  38977. private _engine;
  38978. private _totalVertices;
  38979. /** @hidden */
  38980. _activeIndices: PerfCounter;
  38981. /** @hidden */
  38982. _activeParticles: PerfCounter;
  38983. /** @hidden */
  38984. _activeBones: PerfCounter;
  38985. private _animationRatio;
  38986. /** @hidden */
  38987. _animationTimeLast: number;
  38988. /** @hidden */
  38989. _animationTime: number;
  38990. /**
  38991. * Gets or sets a general scale for animation speed
  38992. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  38993. */
  38994. animationTimeScale: number;
  38995. /** @hidden */
  38996. _cachedMaterial: Nullable<Material>;
  38997. /** @hidden */
  38998. _cachedEffect: Nullable<Effect>;
  38999. /** @hidden */
  39000. _cachedVisibility: Nullable<number>;
  39001. private _renderId;
  39002. private _frameId;
  39003. private _executeWhenReadyTimeoutId;
  39004. private _intermediateRendering;
  39005. private _viewUpdateFlag;
  39006. private _projectionUpdateFlag;
  39007. /** @hidden */
  39008. _toBeDisposed: Nullable<IDisposable>[];
  39009. private _activeRequests;
  39010. /** @hidden */
  39011. _pendingData: any[];
  39012. private _isDisposed;
  39013. /**
  39014. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  39015. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  39016. */
  39017. dispatchAllSubMeshesOfActiveMeshes: boolean;
  39018. private _activeMeshes;
  39019. private _processedMaterials;
  39020. private _renderTargets;
  39021. /** @hidden */
  39022. _activeParticleSystems: SmartArray<IParticleSystem>;
  39023. private _activeSkeletons;
  39024. private _softwareSkinnedMeshes;
  39025. private _renderingManager;
  39026. /** @hidden */
  39027. _activeAnimatables: Animatable[];
  39028. private _transformMatrix;
  39029. private _sceneUbo;
  39030. /** @hidden */
  39031. _viewMatrix: Matrix;
  39032. private _projectionMatrix;
  39033. /** @hidden */
  39034. _forcedViewPosition: Nullable<Vector3>;
  39035. /** @hidden */
  39036. _frustumPlanes: Plane[];
  39037. /**
  39038. * Gets the list of frustum planes (built from the active camera)
  39039. */
  39040. get frustumPlanes(): Plane[];
  39041. /**
  39042. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  39043. * This is useful if there are more lights that the maximum simulteanous authorized
  39044. */
  39045. requireLightSorting: boolean;
  39046. /** @hidden */
  39047. readonly useMaterialMeshMap: boolean;
  39048. /** @hidden */
  39049. readonly useClonedMeshMap: boolean;
  39050. private _externalData;
  39051. private _uid;
  39052. /**
  39053. * @hidden
  39054. * Backing store of defined scene components.
  39055. */
  39056. _components: ISceneComponent[];
  39057. /**
  39058. * @hidden
  39059. * Backing store of defined scene components.
  39060. */
  39061. _serializableComponents: ISceneSerializableComponent[];
  39062. /**
  39063. * List of components to register on the next registration step.
  39064. */
  39065. private _transientComponents;
  39066. /**
  39067. * Registers the transient components if needed.
  39068. */
  39069. private _registerTransientComponents;
  39070. /**
  39071. * @hidden
  39072. * Add a component to the scene.
  39073. * Note that the ccomponent could be registered on th next frame if this is called after
  39074. * the register component stage.
  39075. * @param component Defines the component to add to the scene
  39076. */
  39077. _addComponent(component: ISceneComponent): void;
  39078. /**
  39079. * @hidden
  39080. * Gets a component from the scene.
  39081. * @param name defines the name of the component to retrieve
  39082. * @returns the component or null if not present
  39083. */
  39084. _getComponent(name: string): Nullable<ISceneComponent>;
  39085. /**
  39086. * @hidden
  39087. * Defines the actions happening before camera updates.
  39088. */
  39089. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  39090. /**
  39091. * @hidden
  39092. * Defines the actions happening before clear the canvas.
  39093. */
  39094. _beforeClearStage: Stage<SimpleStageAction>;
  39095. /**
  39096. * @hidden
  39097. * Defines the actions when collecting render targets for the frame.
  39098. */
  39099. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  39100. /**
  39101. * @hidden
  39102. * Defines the actions happening for one camera in the frame.
  39103. */
  39104. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  39105. /**
  39106. * @hidden
  39107. * Defines the actions happening during the per mesh ready checks.
  39108. */
  39109. _isReadyForMeshStage: Stage<MeshStageAction>;
  39110. /**
  39111. * @hidden
  39112. * Defines the actions happening before evaluate active mesh checks.
  39113. */
  39114. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  39115. /**
  39116. * @hidden
  39117. * Defines the actions happening during the evaluate sub mesh checks.
  39118. */
  39119. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  39120. /**
  39121. * @hidden
  39122. * Defines the actions happening during the active mesh stage.
  39123. */
  39124. _activeMeshStage: Stage<ActiveMeshStageAction>;
  39125. /**
  39126. * @hidden
  39127. * Defines the actions happening during the per camera render target step.
  39128. */
  39129. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  39130. /**
  39131. * @hidden
  39132. * Defines the actions happening just before the active camera is drawing.
  39133. */
  39134. _beforeCameraDrawStage: Stage<CameraStageAction>;
  39135. /**
  39136. * @hidden
  39137. * Defines the actions happening just before a render target is drawing.
  39138. */
  39139. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  39140. /**
  39141. * @hidden
  39142. * Defines the actions happening just before a rendering group is drawing.
  39143. */
  39144. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  39145. /**
  39146. * @hidden
  39147. * Defines the actions happening just before a mesh is drawing.
  39148. */
  39149. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  39150. /**
  39151. * @hidden
  39152. * Defines the actions happening just after a mesh has been drawn.
  39153. */
  39154. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  39155. /**
  39156. * @hidden
  39157. * Defines the actions happening just after a rendering group has been drawn.
  39158. */
  39159. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  39160. /**
  39161. * @hidden
  39162. * Defines the actions happening just after the active camera has been drawn.
  39163. */
  39164. _afterCameraDrawStage: Stage<CameraStageAction>;
  39165. /**
  39166. * @hidden
  39167. * Defines the actions happening just after a render target has been drawn.
  39168. */
  39169. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  39170. /**
  39171. * @hidden
  39172. * Defines the actions happening just after rendering all cameras and computing intersections.
  39173. */
  39174. _afterRenderStage: Stage<SimpleStageAction>;
  39175. /**
  39176. * @hidden
  39177. * Defines the actions happening when a pointer move event happens.
  39178. */
  39179. _pointerMoveStage: Stage<PointerMoveStageAction>;
  39180. /**
  39181. * @hidden
  39182. * Defines the actions happening when a pointer down event happens.
  39183. */
  39184. _pointerDownStage: Stage<PointerUpDownStageAction>;
  39185. /**
  39186. * @hidden
  39187. * Defines the actions happening when a pointer up event happens.
  39188. */
  39189. _pointerUpStage: Stage<PointerUpDownStageAction>;
  39190. /**
  39191. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  39192. */
  39193. private geometriesByUniqueId;
  39194. /**
  39195. * Creates a new Scene
  39196. * @param engine defines the engine to use to render this scene
  39197. * @param options defines the scene options
  39198. */
  39199. constructor(engine: Engine, options?: SceneOptions);
  39200. /**
  39201. * Gets a string idenfifying the name of the class
  39202. * @returns "Scene" string
  39203. */
  39204. getClassName(): string;
  39205. private _defaultMeshCandidates;
  39206. /**
  39207. * @hidden
  39208. */
  39209. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  39210. private _defaultSubMeshCandidates;
  39211. /**
  39212. * @hidden
  39213. */
  39214. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  39215. /**
  39216. * Sets the default candidate providers for the scene.
  39217. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  39218. * and getCollidingSubMeshCandidates to their default function
  39219. */
  39220. setDefaultCandidateProviders(): void;
  39221. /**
  39222. * Gets the mesh that is currently under the pointer
  39223. */
  39224. get meshUnderPointer(): Nullable<AbstractMesh>;
  39225. /**
  39226. * Gets or sets the current on-screen X position of the pointer
  39227. */
  39228. get pointerX(): number;
  39229. set pointerX(value: number);
  39230. /**
  39231. * Gets or sets the current on-screen Y position of the pointer
  39232. */
  39233. get pointerY(): number;
  39234. set pointerY(value: number);
  39235. /**
  39236. * Gets the cached material (ie. the latest rendered one)
  39237. * @returns the cached material
  39238. */
  39239. getCachedMaterial(): Nullable<Material>;
  39240. /**
  39241. * Gets the cached effect (ie. the latest rendered one)
  39242. * @returns the cached effect
  39243. */
  39244. getCachedEffect(): Nullable<Effect>;
  39245. /**
  39246. * Gets the cached visibility state (ie. the latest rendered one)
  39247. * @returns the cached visibility state
  39248. */
  39249. getCachedVisibility(): Nullable<number>;
  39250. /**
  39251. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  39252. * @param material defines the current material
  39253. * @param effect defines the current effect
  39254. * @param visibility defines the current visibility state
  39255. * @returns true if one parameter is not cached
  39256. */
  39257. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  39258. /**
  39259. * Gets the engine associated with the scene
  39260. * @returns an Engine
  39261. */
  39262. getEngine(): Engine;
  39263. /**
  39264. * Gets the total number of vertices rendered per frame
  39265. * @returns the total number of vertices rendered per frame
  39266. */
  39267. getTotalVertices(): number;
  39268. /**
  39269. * Gets the performance counter for total vertices
  39270. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39271. */
  39272. get totalVerticesPerfCounter(): PerfCounter;
  39273. /**
  39274. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  39275. * @returns the total number of active indices rendered per frame
  39276. */
  39277. getActiveIndices(): number;
  39278. /**
  39279. * Gets the performance counter for active indices
  39280. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39281. */
  39282. get totalActiveIndicesPerfCounter(): PerfCounter;
  39283. /**
  39284. * Gets the total number of active particles rendered per frame
  39285. * @returns the total number of active particles rendered per frame
  39286. */
  39287. getActiveParticles(): number;
  39288. /**
  39289. * Gets the performance counter for active particles
  39290. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39291. */
  39292. get activeParticlesPerfCounter(): PerfCounter;
  39293. /**
  39294. * Gets the total number of active bones rendered per frame
  39295. * @returns the total number of active bones rendered per frame
  39296. */
  39297. getActiveBones(): number;
  39298. /**
  39299. * Gets the performance counter for active bones
  39300. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39301. */
  39302. get activeBonesPerfCounter(): PerfCounter;
  39303. /**
  39304. * Gets the array of active meshes
  39305. * @returns an array of AbstractMesh
  39306. */
  39307. getActiveMeshes(): SmartArray<AbstractMesh>;
  39308. /**
  39309. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  39310. * @returns a number
  39311. */
  39312. getAnimationRatio(): number;
  39313. /**
  39314. * Gets an unique Id for the current render phase
  39315. * @returns a number
  39316. */
  39317. getRenderId(): number;
  39318. /**
  39319. * Gets an unique Id for the current frame
  39320. * @returns a number
  39321. */
  39322. getFrameId(): number;
  39323. /** Call this function if you want to manually increment the render Id*/
  39324. incrementRenderId(): void;
  39325. private _createUbo;
  39326. /**
  39327. * Use this method to simulate a pointer move on a mesh
  39328. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39329. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39330. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39331. * @returns the current scene
  39332. */
  39333. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39334. /**
  39335. * Use this method to simulate a pointer down on a mesh
  39336. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39337. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39338. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39339. * @returns the current scene
  39340. */
  39341. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39342. /**
  39343. * Use this method to simulate a pointer up on a mesh
  39344. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39345. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39346. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39347. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39348. * @returns the current scene
  39349. */
  39350. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  39351. /**
  39352. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39353. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39354. * @returns true if the pointer was captured
  39355. */
  39356. isPointerCaptured(pointerId?: number): boolean;
  39357. /**
  39358. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39359. * @param attachUp defines if you want to attach events to pointerup
  39360. * @param attachDown defines if you want to attach events to pointerdown
  39361. * @param attachMove defines if you want to attach events to pointermove
  39362. */
  39363. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  39364. /** Detaches all event handlers*/
  39365. detachControl(): void;
  39366. /**
  39367. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  39368. * Delay loaded resources are not taking in account
  39369. * @return true if all required resources are ready
  39370. */
  39371. isReady(): boolean;
  39372. /** Resets all cached information relative to material (including effect and visibility) */
  39373. resetCachedMaterial(): void;
  39374. /**
  39375. * Registers a function to be called before every frame render
  39376. * @param func defines the function to register
  39377. */
  39378. registerBeforeRender(func: () => void): void;
  39379. /**
  39380. * Unregisters a function called before every frame render
  39381. * @param func defines the function to unregister
  39382. */
  39383. unregisterBeforeRender(func: () => void): void;
  39384. /**
  39385. * Registers a function to be called after every frame render
  39386. * @param func defines the function to register
  39387. */
  39388. registerAfterRender(func: () => void): void;
  39389. /**
  39390. * Unregisters a function called after every frame render
  39391. * @param func defines the function to unregister
  39392. */
  39393. unregisterAfterRender(func: () => void): void;
  39394. private _executeOnceBeforeRender;
  39395. /**
  39396. * The provided function will run before render once and will be disposed afterwards.
  39397. * A timeout delay can be provided so that the function will be executed in N ms.
  39398. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  39399. * @param func The function to be executed.
  39400. * @param timeout optional delay in ms
  39401. */
  39402. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  39403. /** @hidden */
  39404. _addPendingData(data: any): void;
  39405. /** @hidden */
  39406. _removePendingData(data: any): void;
  39407. /**
  39408. * Returns the number of items waiting to be loaded
  39409. * @returns the number of items waiting to be loaded
  39410. */
  39411. getWaitingItemsCount(): number;
  39412. /**
  39413. * Returns a boolean indicating if the scene is still loading data
  39414. */
  39415. get isLoading(): boolean;
  39416. /**
  39417. * Registers a function to be executed when the scene is ready
  39418. * @param {Function} func - the function to be executed
  39419. */
  39420. executeWhenReady(func: () => void): void;
  39421. /**
  39422. * Returns a promise that resolves when the scene is ready
  39423. * @returns A promise that resolves when the scene is ready
  39424. */
  39425. whenReadyAsync(): Promise<void>;
  39426. /** @hidden */
  39427. _checkIsReady(): void;
  39428. /**
  39429. * Gets all animatable attached to the scene
  39430. */
  39431. get animatables(): Animatable[];
  39432. /**
  39433. * Resets the last animation time frame.
  39434. * Useful to override when animations start running when loading a scene for the first time.
  39435. */
  39436. resetLastAnimationTimeFrame(): void;
  39437. /**
  39438. * Gets the current view matrix
  39439. * @returns a Matrix
  39440. */
  39441. getViewMatrix(): Matrix;
  39442. /**
  39443. * Gets the current projection matrix
  39444. * @returns a Matrix
  39445. */
  39446. getProjectionMatrix(): Matrix;
  39447. /**
  39448. * Gets the current transform matrix
  39449. * @returns a Matrix made of View * Projection
  39450. */
  39451. getTransformMatrix(): Matrix;
  39452. /**
  39453. * Sets the current transform matrix
  39454. * @param viewL defines the View matrix to use
  39455. * @param projectionL defines the Projection matrix to use
  39456. * @param viewR defines the right View matrix to use (if provided)
  39457. * @param projectionR defines the right Projection matrix to use (if provided)
  39458. */
  39459. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  39460. /**
  39461. * Gets the uniform buffer used to store scene data
  39462. * @returns a UniformBuffer
  39463. */
  39464. getSceneUniformBuffer(): UniformBuffer;
  39465. /**
  39466. * Gets an unique (relatively to the current scene) Id
  39467. * @returns an unique number for the scene
  39468. */
  39469. getUniqueId(): number;
  39470. /**
  39471. * Add a mesh to the list of scene's meshes
  39472. * @param newMesh defines the mesh to add
  39473. * @param recursive if all child meshes should also be added to the scene
  39474. */
  39475. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  39476. /**
  39477. * Remove a mesh for the list of scene's meshes
  39478. * @param toRemove defines the mesh to remove
  39479. * @param recursive if all child meshes should also be removed from the scene
  39480. * @returns the index where the mesh was in the mesh list
  39481. */
  39482. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  39483. /**
  39484. * Add a transform node to the list of scene's transform nodes
  39485. * @param newTransformNode defines the transform node to add
  39486. */
  39487. addTransformNode(newTransformNode: TransformNode): void;
  39488. /**
  39489. * Remove a transform node for the list of scene's transform nodes
  39490. * @param toRemove defines the transform node to remove
  39491. * @returns the index where the transform node was in the transform node list
  39492. */
  39493. removeTransformNode(toRemove: TransformNode): number;
  39494. /**
  39495. * Remove a skeleton for the list of scene's skeletons
  39496. * @param toRemove defines the skeleton to remove
  39497. * @returns the index where the skeleton was in the skeleton list
  39498. */
  39499. removeSkeleton(toRemove: Skeleton): number;
  39500. /**
  39501. * Remove a morph target for the list of scene's morph targets
  39502. * @param toRemove defines the morph target to remove
  39503. * @returns the index where the morph target was in the morph target list
  39504. */
  39505. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  39506. /**
  39507. * Remove a light for the list of scene's lights
  39508. * @param toRemove defines the light to remove
  39509. * @returns the index where the light was in the light list
  39510. */
  39511. removeLight(toRemove: Light): number;
  39512. /**
  39513. * Remove a camera for the list of scene's cameras
  39514. * @param toRemove defines the camera to remove
  39515. * @returns the index where the camera was in the camera list
  39516. */
  39517. removeCamera(toRemove: Camera): number;
  39518. /**
  39519. * Remove a particle system for the list of scene's particle systems
  39520. * @param toRemove defines the particle system to remove
  39521. * @returns the index where the particle system was in the particle system list
  39522. */
  39523. removeParticleSystem(toRemove: IParticleSystem): number;
  39524. /**
  39525. * Remove a animation for the list of scene's animations
  39526. * @param toRemove defines the animation to remove
  39527. * @returns the index where the animation was in the animation list
  39528. */
  39529. removeAnimation(toRemove: Animation): number;
  39530. /**
  39531. * Will stop the animation of the given target
  39532. * @param target - the target
  39533. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  39534. * @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)
  39535. */
  39536. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  39537. /**
  39538. * Removes the given animation group from this scene.
  39539. * @param toRemove The animation group to remove
  39540. * @returns The index of the removed animation group
  39541. */
  39542. removeAnimationGroup(toRemove: AnimationGroup): number;
  39543. /**
  39544. * Removes the given multi-material from this scene.
  39545. * @param toRemove The multi-material to remove
  39546. * @returns The index of the removed multi-material
  39547. */
  39548. removeMultiMaterial(toRemove: MultiMaterial): number;
  39549. /**
  39550. * Removes the given material from this scene.
  39551. * @param toRemove The material to remove
  39552. * @returns The index of the removed material
  39553. */
  39554. removeMaterial(toRemove: Material): number;
  39555. /**
  39556. * Removes the given action manager from this scene.
  39557. * @param toRemove The action manager to remove
  39558. * @returns The index of the removed action manager
  39559. */
  39560. removeActionManager(toRemove: AbstractActionManager): number;
  39561. /**
  39562. * Removes the given texture from this scene.
  39563. * @param toRemove The texture to remove
  39564. * @returns The index of the removed texture
  39565. */
  39566. removeTexture(toRemove: BaseTexture): number;
  39567. /**
  39568. * Adds the given light to this scene
  39569. * @param newLight The light to add
  39570. */
  39571. addLight(newLight: Light): void;
  39572. /**
  39573. * Sorts the list list based on light priorities
  39574. */
  39575. sortLightsByPriority(): void;
  39576. /**
  39577. * Adds the given camera to this scene
  39578. * @param newCamera The camera to add
  39579. */
  39580. addCamera(newCamera: Camera): void;
  39581. /**
  39582. * Adds the given skeleton to this scene
  39583. * @param newSkeleton The skeleton to add
  39584. */
  39585. addSkeleton(newSkeleton: Skeleton): void;
  39586. /**
  39587. * Adds the given particle system to this scene
  39588. * @param newParticleSystem The particle system to add
  39589. */
  39590. addParticleSystem(newParticleSystem: IParticleSystem): void;
  39591. /**
  39592. * Adds the given animation to this scene
  39593. * @param newAnimation The animation to add
  39594. */
  39595. addAnimation(newAnimation: Animation): void;
  39596. /**
  39597. * Adds the given animation group to this scene.
  39598. * @param newAnimationGroup The animation group to add
  39599. */
  39600. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  39601. /**
  39602. * Adds the given multi-material to this scene
  39603. * @param newMultiMaterial The multi-material to add
  39604. */
  39605. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  39606. /**
  39607. * Adds the given material to this scene
  39608. * @param newMaterial The material to add
  39609. */
  39610. addMaterial(newMaterial: Material): void;
  39611. /**
  39612. * Adds the given morph target to this scene
  39613. * @param newMorphTargetManager The morph target to add
  39614. */
  39615. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  39616. /**
  39617. * Adds the given geometry to this scene
  39618. * @param newGeometry The geometry to add
  39619. */
  39620. addGeometry(newGeometry: Geometry): void;
  39621. /**
  39622. * Adds the given action manager to this scene
  39623. * @param newActionManager The action manager to add
  39624. */
  39625. addActionManager(newActionManager: AbstractActionManager): void;
  39626. /**
  39627. * Adds the given texture to this scene.
  39628. * @param newTexture The texture to add
  39629. */
  39630. addTexture(newTexture: BaseTexture): void;
  39631. /**
  39632. * Switch active camera
  39633. * @param newCamera defines the new active camera
  39634. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  39635. */
  39636. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  39637. /**
  39638. * sets the active camera of the scene using its ID
  39639. * @param id defines the camera's ID
  39640. * @return the new active camera or null if none found.
  39641. */
  39642. setActiveCameraByID(id: string): Nullable<Camera>;
  39643. /**
  39644. * sets the active camera of the scene using its name
  39645. * @param name defines the camera's name
  39646. * @returns the new active camera or null if none found.
  39647. */
  39648. setActiveCameraByName(name: string): Nullable<Camera>;
  39649. /**
  39650. * get an animation group using its name
  39651. * @param name defines the material's name
  39652. * @return the animation group or null if none found.
  39653. */
  39654. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  39655. /**
  39656. * Get a material using its unique id
  39657. * @param uniqueId defines the material's unique id
  39658. * @return the material or null if none found.
  39659. */
  39660. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  39661. /**
  39662. * get a material using its id
  39663. * @param id defines the material's ID
  39664. * @return the material or null if none found.
  39665. */
  39666. getMaterialByID(id: string): Nullable<Material>;
  39667. /**
  39668. * Gets a the last added material using a given id
  39669. * @param id defines the material's ID
  39670. * @return the last material with the given id or null if none found.
  39671. */
  39672. getLastMaterialByID(id: string): Nullable<Material>;
  39673. /**
  39674. * Gets a material using its name
  39675. * @param name defines the material's name
  39676. * @return the material or null if none found.
  39677. */
  39678. getMaterialByName(name: string): Nullable<Material>;
  39679. /**
  39680. * Get a texture using its unique id
  39681. * @param uniqueId defines the texture's unique id
  39682. * @return the texture or null if none found.
  39683. */
  39684. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  39685. /**
  39686. * Gets a camera using its id
  39687. * @param id defines the id to look for
  39688. * @returns the camera or null if not found
  39689. */
  39690. getCameraByID(id: string): Nullable<Camera>;
  39691. /**
  39692. * Gets a camera using its unique id
  39693. * @param uniqueId defines the unique id to look for
  39694. * @returns the camera or null if not found
  39695. */
  39696. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  39697. /**
  39698. * Gets a camera using its name
  39699. * @param name defines the camera's name
  39700. * @return the camera or null if none found.
  39701. */
  39702. getCameraByName(name: string): Nullable<Camera>;
  39703. /**
  39704. * Gets a bone using its id
  39705. * @param id defines the bone's id
  39706. * @return the bone or null if not found
  39707. */
  39708. getBoneByID(id: string): Nullable<Bone>;
  39709. /**
  39710. * Gets a bone using its id
  39711. * @param name defines the bone's name
  39712. * @return the bone or null if not found
  39713. */
  39714. getBoneByName(name: string): Nullable<Bone>;
  39715. /**
  39716. * Gets a light node using its name
  39717. * @param name defines the the light's name
  39718. * @return the light or null if none found.
  39719. */
  39720. getLightByName(name: string): Nullable<Light>;
  39721. /**
  39722. * Gets a light node using its id
  39723. * @param id defines the light's id
  39724. * @return the light or null if none found.
  39725. */
  39726. getLightByID(id: string): Nullable<Light>;
  39727. /**
  39728. * Gets a light node using its scene-generated unique ID
  39729. * @param uniqueId defines the light's unique id
  39730. * @return the light or null if none found.
  39731. */
  39732. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  39733. /**
  39734. * Gets a particle system by id
  39735. * @param id defines the particle system id
  39736. * @return the corresponding system or null if none found
  39737. */
  39738. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  39739. /**
  39740. * Gets a geometry using its ID
  39741. * @param id defines the geometry's id
  39742. * @return the geometry or null if none found.
  39743. */
  39744. getGeometryByID(id: string): Nullable<Geometry>;
  39745. private _getGeometryByUniqueID;
  39746. /**
  39747. * Add a new geometry to this scene
  39748. * @param geometry defines the geometry to be added to the scene.
  39749. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  39750. * @return a boolean defining if the geometry was added or not
  39751. */
  39752. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  39753. /**
  39754. * Removes an existing geometry
  39755. * @param geometry defines the geometry to be removed from the scene
  39756. * @return a boolean defining if the geometry was removed or not
  39757. */
  39758. removeGeometry(geometry: Geometry): boolean;
  39759. /**
  39760. * Gets the list of geometries attached to the scene
  39761. * @returns an array of Geometry
  39762. */
  39763. getGeometries(): Geometry[];
  39764. /**
  39765. * Gets the first added mesh found of a given ID
  39766. * @param id defines the id to search for
  39767. * @return the mesh found or null if not found at all
  39768. */
  39769. getMeshByID(id: string): Nullable<AbstractMesh>;
  39770. /**
  39771. * Gets a list of meshes using their id
  39772. * @param id defines the id to search for
  39773. * @returns a list of meshes
  39774. */
  39775. getMeshesByID(id: string): Array<AbstractMesh>;
  39776. /**
  39777. * Gets the first added transform node found of a given ID
  39778. * @param id defines the id to search for
  39779. * @return the found transform node or null if not found at all.
  39780. */
  39781. getTransformNodeByID(id: string): Nullable<TransformNode>;
  39782. /**
  39783. * Gets a transform node with its auto-generated unique id
  39784. * @param uniqueId efines the unique id to search for
  39785. * @return the found transform node or null if not found at all.
  39786. */
  39787. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  39788. /**
  39789. * Gets a list of transform nodes using their id
  39790. * @param id defines the id to search for
  39791. * @returns a list of transform nodes
  39792. */
  39793. getTransformNodesByID(id: string): Array<TransformNode>;
  39794. /**
  39795. * Gets a mesh with its auto-generated unique id
  39796. * @param uniqueId defines the unique id to search for
  39797. * @return the found mesh or null if not found at all.
  39798. */
  39799. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  39800. /**
  39801. * Gets a the last added mesh using a given id
  39802. * @param id defines the id to search for
  39803. * @return the found mesh or null if not found at all.
  39804. */
  39805. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  39806. /**
  39807. * Gets a the last added node (Mesh, Camera, Light) using a given id
  39808. * @param id defines the id to search for
  39809. * @return the found node or null if not found at all
  39810. */
  39811. getLastEntryByID(id: string): Nullable<Node>;
  39812. /**
  39813. * Gets a node (Mesh, Camera, Light) using a given id
  39814. * @param id defines the id to search for
  39815. * @return the found node or null if not found at all
  39816. */
  39817. getNodeByID(id: string): Nullable<Node>;
  39818. /**
  39819. * Gets a node (Mesh, Camera, Light) using a given name
  39820. * @param name defines the name to search for
  39821. * @return the found node or null if not found at all.
  39822. */
  39823. getNodeByName(name: string): Nullable<Node>;
  39824. /**
  39825. * Gets a mesh using a given name
  39826. * @param name defines the name to search for
  39827. * @return the found mesh or null if not found at all.
  39828. */
  39829. getMeshByName(name: string): Nullable<AbstractMesh>;
  39830. /**
  39831. * Gets a transform node using a given name
  39832. * @param name defines the name to search for
  39833. * @return the found transform node or null if not found at all.
  39834. */
  39835. getTransformNodeByName(name: string): Nullable<TransformNode>;
  39836. /**
  39837. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  39838. * @param id defines the id to search for
  39839. * @return the found skeleton or null if not found at all.
  39840. */
  39841. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  39842. /**
  39843. * Gets a skeleton using a given auto generated unique id
  39844. * @param uniqueId defines the unique id to search for
  39845. * @return the found skeleton or null if not found at all.
  39846. */
  39847. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  39848. /**
  39849. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  39850. * @param id defines the id to search for
  39851. * @return the found skeleton or null if not found at all.
  39852. */
  39853. getSkeletonById(id: string): Nullable<Skeleton>;
  39854. /**
  39855. * Gets a skeleton using a given name
  39856. * @param name defines the name to search for
  39857. * @return the found skeleton or null if not found at all.
  39858. */
  39859. getSkeletonByName(name: string): Nullable<Skeleton>;
  39860. /**
  39861. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  39862. * @param id defines the id to search for
  39863. * @return the found morph target manager or null if not found at all.
  39864. */
  39865. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  39866. /**
  39867. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  39868. * @param id defines the id to search for
  39869. * @return the found morph target or null if not found at all.
  39870. */
  39871. getMorphTargetById(id: string): Nullable<MorphTarget>;
  39872. /**
  39873. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  39874. * @param name defines the name to search for
  39875. * @return the found morph target or null if not found at all.
  39876. */
  39877. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  39878. /**
  39879. * Gets a boolean indicating if the given mesh is active
  39880. * @param mesh defines the mesh to look for
  39881. * @returns true if the mesh is in the active list
  39882. */
  39883. isActiveMesh(mesh: AbstractMesh): boolean;
  39884. /**
  39885. * Return a unique id as a string which can serve as an identifier for the scene
  39886. */
  39887. get uid(): string;
  39888. /**
  39889. * Add an externaly attached data from its key.
  39890. * This method call will fail and return false, if such key already exists.
  39891. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  39892. * @param key the unique key that identifies the data
  39893. * @param data the data object to associate to the key for this Engine instance
  39894. * @return true if no such key were already present and the data was added successfully, false otherwise
  39895. */
  39896. addExternalData<T>(key: string, data: T): boolean;
  39897. /**
  39898. * Get an externaly attached data from its key
  39899. * @param key the unique key that identifies the data
  39900. * @return the associated data, if present (can be null), or undefined if not present
  39901. */
  39902. getExternalData<T>(key: string): Nullable<T>;
  39903. /**
  39904. * Get an externaly attached data from its key, create it using a factory if it's not already present
  39905. * @param key the unique key that identifies the data
  39906. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  39907. * @return the associated data, can be null if the factory returned null.
  39908. */
  39909. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  39910. /**
  39911. * Remove an externaly attached data from the Engine instance
  39912. * @param key the unique key that identifies the data
  39913. * @return true if the data was successfully removed, false if it doesn't exist
  39914. */
  39915. removeExternalData(key: string): boolean;
  39916. private _evaluateSubMesh;
  39917. /**
  39918. * Clear the processed materials smart array preventing retention point in material dispose.
  39919. */
  39920. freeProcessedMaterials(): void;
  39921. private _preventFreeActiveMeshesAndRenderingGroups;
  39922. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  39923. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  39924. * when disposing several meshes in a row or a hierarchy of meshes.
  39925. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  39926. */
  39927. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  39928. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  39929. /**
  39930. * Clear the active meshes smart array preventing retention point in mesh dispose.
  39931. */
  39932. freeActiveMeshes(): void;
  39933. /**
  39934. * Clear the info related to rendering groups preventing retention points during dispose.
  39935. */
  39936. freeRenderingGroups(): void;
  39937. /** @hidden */
  39938. _isInIntermediateRendering(): boolean;
  39939. /**
  39940. * Lambda returning the list of potentially active meshes.
  39941. */
  39942. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  39943. /**
  39944. * Lambda returning the list of potentially active sub meshes.
  39945. */
  39946. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  39947. /**
  39948. * Lambda returning the list of potentially intersecting sub meshes.
  39949. */
  39950. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  39951. /**
  39952. * Lambda returning the list of potentially colliding sub meshes.
  39953. */
  39954. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  39955. private _activeMeshesFrozen;
  39956. private _skipEvaluateActiveMeshesCompletely;
  39957. /**
  39958. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  39959. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  39960. * @returns the current scene
  39961. */
  39962. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  39963. /**
  39964. * Use this function to restart evaluating active meshes on every frame
  39965. * @returns the current scene
  39966. */
  39967. unfreezeActiveMeshes(): Scene;
  39968. private _evaluateActiveMeshes;
  39969. private _activeMesh;
  39970. /**
  39971. * Update the transform matrix to update from the current active camera
  39972. * @param force defines a boolean used to force the update even if cache is up to date
  39973. */
  39974. updateTransformMatrix(force?: boolean): void;
  39975. private _bindFrameBuffer;
  39976. /** @hidden */
  39977. _allowPostProcessClearColor: boolean;
  39978. /** @hidden */
  39979. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  39980. private _processSubCameras;
  39981. private _checkIntersections;
  39982. /** @hidden */
  39983. _advancePhysicsEngineStep(step: number): void;
  39984. /**
  39985. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  39986. */
  39987. getDeterministicFrameTime: () => number;
  39988. /** @hidden */
  39989. _animate(): void;
  39990. /** Execute all animations (for a frame) */
  39991. animate(): void;
  39992. /**
  39993. * Render the scene
  39994. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  39995. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  39996. */
  39997. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  39998. /**
  39999. * Freeze all materials
  40000. * A frozen material will not be updatable but should be faster to render
  40001. */
  40002. freezeMaterials(): void;
  40003. /**
  40004. * Unfreeze all materials
  40005. * A frozen material will not be updatable but should be faster to render
  40006. */
  40007. unfreezeMaterials(): void;
  40008. /**
  40009. * Releases all held ressources
  40010. */
  40011. dispose(): void;
  40012. /**
  40013. * Gets if the scene is already disposed
  40014. */
  40015. get isDisposed(): boolean;
  40016. /**
  40017. * Call this function to reduce memory footprint of the scene.
  40018. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  40019. */
  40020. clearCachedVertexData(): void;
  40021. /**
  40022. * This function will remove the local cached buffer data from texture.
  40023. * It will save memory but will prevent the texture from being rebuilt
  40024. */
  40025. cleanCachedTextureBuffer(): void;
  40026. /**
  40027. * Get the world extend vectors with an optional filter
  40028. *
  40029. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  40030. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  40031. */
  40032. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  40033. min: Vector3;
  40034. max: Vector3;
  40035. };
  40036. /**
  40037. * Creates a ray that can be used to pick in the scene
  40038. * @param x defines the x coordinate of the origin (on-screen)
  40039. * @param y defines the y coordinate of the origin (on-screen)
  40040. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  40041. * @param camera defines the camera to use for the picking
  40042. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  40043. * @returns a Ray
  40044. */
  40045. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  40046. /**
  40047. * Creates a ray that can be used to pick in the scene
  40048. * @param x defines the x coordinate of the origin (on-screen)
  40049. * @param y defines the y coordinate of the origin (on-screen)
  40050. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  40051. * @param result defines the ray where to store the picking ray
  40052. * @param camera defines the camera to use for the picking
  40053. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  40054. * @returns the current scene
  40055. */
  40056. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  40057. /**
  40058. * Creates a ray that can be used to pick in the scene
  40059. * @param x defines the x coordinate of the origin (on-screen)
  40060. * @param y defines the y coordinate of the origin (on-screen)
  40061. * @param camera defines the camera to use for the picking
  40062. * @returns a Ray
  40063. */
  40064. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  40065. /**
  40066. * Creates a ray that can be used to pick in the scene
  40067. * @param x defines the x coordinate of the origin (on-screen)
  40068. * @param y defines the y coordinate of the origin (on-screen)
  40069. * @param result defines the ray where to store the picking ray
  40070. * @param camera defines the camera to use for the picking
  40071. * @returns the current scene
  40072. */
  40073. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  40074. /** Launch a ray to try to pick a mesh in the scene
  40075. * @param x position on screen
  40076. * @param y position on screen
  40077. * @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
  40078. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40079. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40080. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40081. * @returns a PickingInfo
  40082. */
  40083. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  40084. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  40085. * @param x position on screen
  40086. * @param y position on screen
  40087. * @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
  40088. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40089. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40090. * @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)
  40091. */
  40092. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  40093. /** Use the given ray to pick a mesh in the scene
  40094. * @param ray The ray to use to pick meshes
  40095. * @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
  40096. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40097. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40098. * @returns a PickingInfo
  40099. */
  40100. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  40101. /**
  40102. * Launch a ray to try to pick a mesh in the scene
  40103. * @param x X position on screen
  40104. * @param y Y position on screen
  40105. * @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
  40106. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40107. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40108. * @returns an array of PickingInfo
  40109. */
  40110. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  40111. /**
  40112. * Launch a ray to try to pick a mesh in the scene
  40113. * @param ray Ray to use
  40114. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  40115. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40116. * @returns an array of PickingInfo
  40117. */
  40118. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  40119. /**
  40120. * Force the value of meshUnderPointer
  40121. * @param mesh defines the mesh to use
  40122. */
  40123. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  40124. /**
  40125. * Gets the mesh under the pointer
  40126. * @returns a Mesh or null if no mesh is under the pointer
  40127. */
  40128. getPointerOverMesh(): Nullable<AbstractMesh>;
  40129. /** @hidden */
  40130. _rebuildGeometries(): void;
  40131. /** @hidden */
  40132. _rebuildTextures(): void;
  40133. private _getByTags;
  40134. /**
  40135. * Get a list of meshes by tags
  40136. * @param tagsQuery defines the tags query to use
  40137. * @param forEach defines a predicate used to filter results
  40138. * @returns an array of Mesh
  40139. */
  40140. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  40141. /**
  40142. * Get a list of cameras by tags
  40143. * @param tagsQuery defines the tags query to use
  40144. * @param forEach defines a predicate used to filter results
  40145. * @returns an array of Camera
  40146. */
  40147. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  40148. /**
  40149. * Get a list of lights by tags
  40150. * @param tagsQuery defines the tags query to use
  40151. * @param forEach defines a predicate used to filter results
  40152. * @returns an array of Light
  40153. */
  40154. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  40155. /**
  40156. * Get a list of materials by tags
  40157. * @param tagsQuery defines the tags query to use
  40158. * @param forEach defines a predicate used to filter results
  40159. * @returns an array of Material
  40160. */
  40161. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  40162. /**
  40163. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  40164. * This allowed control for front to back rendering or reversly depending of the special needs.
  40165. *
  40166. * @param renderingGroupId The rendering group id corresponding to its index
  40167. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  40168. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  40169. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  40170. */
  40171. 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;
  40172. /**
  40173. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  40174. *
  40175. * @param renderingGroupId The rendering group id corresponding to its index
  40176. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  40177. * @param depth Automatically clears depth between groups if true and autoClear is true.
  40178. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  40179. */
  40180. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  40181. /**
  40182. * Gets the current auto clear configuration for one rendering group of the rendering
  40183. * manager.
  40184. * @param index the rendering group index to get the information for
  40185. * @returns The auto clear setup for the requested rendering group
  40186. */
  40187. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  40188. private _blockMaterialDirtyMechanism;
  40189. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  40190. get blockMaterialDirtyMechanism(): boolean;
  40191. set blockMaterialDirtyMechanism(value: boolean);
  40192. /**
  40193. * Will flag all materials as dirty to trigger new shader compilation
  40194. * @param flag defines the flag used to specify which material part must be marked as dirty
  40195. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  40196. */
  40197. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  40198. /** @hidden */
  40199. _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;
  40200. /** @hidden */
  40201. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40202. /** @hidden */
  40203. _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;
  40204. /** @hidden */
  40205. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  40206. /** @hidden */
  40207. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  40208. /** @hidden */
  40209. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40210. }
  40211. }
  40212. declare module BABYLON {
  40213. /**
  40214. * Set of assets to keep when moving a scene into an asset container.
  40215. */
  40216. export class KeepAssets extends AbstractScene {
  40217. }
  40218. /**
  40219. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  40220. */
  40221. export class InstantiatedEntries {
  40222. /**
  40223. * List of new root nodes (eg. nodes with no parent)
  40224. */
  40225. rootNodes: TransformNode[];
  40226. /**
  40227. * List of new skeletons
  40228. */
  40229. skeletons: Skeleton[];
  40230. /**
  40231. * List of new animation groups
  40232. */
  40233. animationGroups: AnimationGroup[];
  40234. }
  40235. /**
  40236. * Container with a set of assets that can be added or removed from a scene.
  40237. */
  40238. export class AssetContainer extends AbstractScene {
  40239. private _wasAddedToScene;
  40240. /**
  40241. * The scene the AssetContainer belongs to.
  40242. */
  40243. scene: Scene;
  40244. /**
  40245. * Instantiates an AssetContainer.
  40246. * @param scene The scene the AssetContainer belongs to.
  40247. */
  40248. constructor(scene: Scene);
  40249. /**
  40250. * Instantiate or clone all meshes and add the new ones to the scene.
  40251. * Skeletons and animation groups will all be cloned
  40252. * @param nameFunction defines an optional function used to get new names for clones
  40253. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  40254. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  40255. */
  40256. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  40257. /**
  40258. * Adds all the assets from the container to the scene.
  40259. */
  40260. addAllToScene(): void;
  40261. /**
  40262. * Removes all the assets in the container from the scene
  40263. */
  40264. removeAllFromScene(): void;
  40265. /**
  40266. * Disposes all the assets in the container
  40267. */
  40268. dispose(): void;
  40269. private _moveAssets;
  40270. /**
  40271. * Removes all the assets contained in the scene and adds them to the container.
  40272. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  40273. */
  40274. moveAllFromScene(keepAssets?: KeepAssets): void;
  40275. /**
  40276. * 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.
  40277. * @returns the root mesh
  40278. */
  40279. createRootMesh(): Mesh;
  40280. /**
  40281. * Merge animations (direct and animation groups) from this asset container into a scene
  40282. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  40283. * @param animatables set of animatables to retarget to a node from the scene
  40284. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  40285. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  40286. */
  40287. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  40288. }
  40289. }
  40290. declare module BABYLON {
  40291. /**
  40292. * Defines how the parser contract is defined.
  40293. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  40294. */
  40295. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  40296. /**
  40297. * Defines how the individual parser contract is defined.
  40298. * These parser can parse an individual asset
  40299. */
  40300. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  40301. /**
  40302. * Base class of the scene acting as a container for the different elements composing a scene.
  40303. * This class is dynamically extended by the different components of the scene increasing
  40304. * flexibility and reducing coupling
  40305. */
  40306. export abstract class AbstractScene {
  40307. /**
  40308. * Stores the list of available parsers in the application.
  40309. */
  40310. private static _BabylonFileParsers;
  40311. /**
  40312. * Stores the list of available individual parsers in the application.
  40313. */
  40314. private static _IndividualBabylonFileParsers;
  40315. /**
  40316. * Adds a parser in the list of available ones
  40317. * @param name Defines the name of the parser
  40318. * @param parser Defines the parser to add
  40319. */
  40320. static AddParser(name: string, parser: BabylonFileParser): void;
  40321. /**
  40322. * Gets a general parser from the list of avaialble ones
  40323. * @param name Defines the name of the parser
  40324. * @returns the requested parser or null
  40325. */
  40326. static GetParser(name: string): Nullable<BabylonFileParser>;
  40327. /**
  40328. * Adds n individual parser in the list of available ones
  40329. * @param name Defines the name of the parser
  40330. * @param parser Defines the parser to add
  40331. */
  40332. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  40333. /**
  40334. * Gets an individual parser from the list of avaialble ones
  40335. * @param name Defines the name of the parser
  40336. * @returns the requested parser or null
  40337. */
  40338. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  40339. /**
  40340. * Parser json data and populate both a scene and its associated container object
  40341. * @param jsonData Defines the data to parse
  40342. * @param scene Defines the scene to parse the data for
  40343. * @param container Defines the container attached to the parsing sequence
  40344. * @param rootUrl Defines the root url of the data
  40345. */
  40346. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  40347. /**
  40348. * Gets the list of root nodes (ie. nodes with no parent)
  40349. */
  40350. rootNodes: Node[];
  40351. /** All of the cameras added to this scene
  40352. * @see http://doc.babylonjs.com/babylon101/cameras
  40353. */
  40354. cameras: Camera[];
  40355. /**
  40356. * All of the lights added to this scene
  40357. * @see http://doc.babylonjs.com/babylon101/lights
  40358. */
  40359. lights: Light[];
  40360. /**
  40361. * All of the (abstract) meshes added to this scene
  40362. */
  40363. meshes: AbstractMesh[];
  40364. /**
  40365. * The list of skeletons added to the scene
  40366. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  40367. */
  40368. skeletons: Skeleton[];
  40369. /**
  40370. * All of the particle systems added to this scene
  40371. * @see http://doc.babylonjs.com/babylon101/particles
  40372. */
  40373. particleSystems: IParticleSystem[];
  40374. /**
  40375. * Gets a list of Animations associated with the scene
  40376. */
  40377. animations: Animation[];
  40378. /**
  40379. * All of the animation groups added to this scene
  40380. * @see http://doc.babylonjs.com/how_to/group
  40381. */
  40382. animationGroups: AnimationGroup[];
  40383. /**
  40384. * All of the multi-materials added to this scene
  40385. * @see http://doc.babylonjs.com/how_to/multi_materials
  40386. */
  40387. multiMaterials: MultiMaterial[];
  40388. /**
  40389. * All of the materials added to this scene
  40390. * In the context of a Scene, it is not supposed to be modified manually.
  40391. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  40392. * Note also that the order of the Material within the array is not significant and might change.
  40393. * @see http://doc.babylonjs.com/babylon101/materials
  40394. */
  40395. materials: Material[];
  40396. /**
  40397. * The list of morph target managers added to the scene
  40398. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  40399. */
  40400. morphTargetManagers: MorphTargetManager[];
  40401. /**
  40402. * The list of geometries used in the scene.
  40403. */
  40404. geometries: Geometry[];
  40405. /**
  40406. * All of the tranform nodes added to this scene
  40407. * In the context of a Scene, it is not supposed to be modified manually.
  40408. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  40409. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  40410. * @see http://doc.babylonjs.com/how_to/transformnode
  40411. */
  40412. transformNodes: TransformNode[];
  40413. /**
  40414. * ActionManagers available on the scene.
  40415. */
  40416. actionManagers: AbstractActionManager[];
  40417. /**
  40418. * Textures to keep.
  40419. */
  40420. textures: BaseTexture[];
  40421. /**
  40422. * Environment texture for the scene
  40423. */
  40424. environmentTexture: Nullable<BaseTexture>;
  40425. /**
  40426. * @returns all meshes, lights, cameras, transformNodes and bones
  40427. */
  40428. getNodes(): Array<Node>;
  40429. }
  40430. }
  40431. declare module BABYLON {
  40432. /**
  40433. * Interface used to define options for Sound class
  40434. */
  40435. export interface ISoundOptions {
  40436. /**
  40437. * Does the sound autoplay once loaded.
  40438. */
  40439. autoplay?: boolean;
  40440. /**
  40441. * Does the sound loop after it finishes playing once.
  40442. */
  40443. loop?: boolean;
  40444. /**
  40445. * Sound's volume
  40446. */
  40447. volume?: number;
  40448. /**
  40449. * Is it a spatial sound?
  40450. */
  40451. spatialSound?: boolean;
  40452. /**
  40453. * Maximum distance to hear that sound
  40454. */
  40455. maxDistance?: number;
  40456. /**
  40457. * Uses user defined attenuation function
  40458. */
  40459. useCustomAttenuation?: boolean;
  40460. /**
  40461. * Define the roll off factor of spatial sounds.
  40462. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40463. */
  40464. rolloffFactor?: number;
  40465. /**
  40466. * Define the reference distance the sound should be heard perfectly.
  40467. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40468. */
  40469. refDistance?: number;
  40470. /**
  40471. * Define the distance attenuation model the sound will follow.
  40472. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40473. */
  40474. distanceModel?: string;
  40475. /**
  40476. * Defines the playback speed (1 by default)
  40477. */
  40478. playbackRate?: number;
  40479. /**
  40480. * Defines if the sound is from a streaming source
  40481. */
  40482. streaming?: boolean;
  40483. /**
  40484. * Defines an optional length (in seconds) inside the sound file
  40485. */
  40486. length?: number;
  40487. /**
  40488. * Defines an optional offset (in seconds) inside the sound file
  40489. */
  40490. offset?: number;
  40491. /**
  40492. * If true, URLs will not be required to state the audio file codec to use.
  40493. */
  40494. skipCodecCheck?: boolean;
  40495. }
  40496. /**
  40497. * Defines a sound that can be played in the application.
  40498. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  40499. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40500. */
  40501. export class Sound {
  40502. /**
  40503. * The name of the sound in the scene.
  40504. */
  40505. name: string;
  40506. /**
  40507. * Does the sound autoplay once loaded.
  40508. */
  40509. autoplay: boolean;
  40510. /**
  40511. * Does the sound loop after it finishes playing once.
  40512. */
  40513. loop: boolean;
  40514. /**
  40515. * Does the sound use a custom attenuation curve to simulate the falloff
  40516. * happening when the source gets further away from the camera.
  40517. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40518. */
  40519. useCustomAttenuation: boolean;
  40520. /**
  40521. * The sound track id this sound belongs to.
  40522. */
  40523. soundTrackId: number;
  40524. /**
  40525. * Is this sound currently played.
  40526. */
  40527. isPlaying: boolean;
  40528. /**
  40529. * Is this sound currently paused.
  40530. */
  40531. isPaused: boolean;
  40532. /**
  40533. * Does this sound enables spatial sound.
  40534. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40535. */
  40536. spatialSound: boolean;
  40537. /**
  40538. * Define the reference distance the sound should be heard perfectly.
  40539. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40540. */
  40541. refDistance: number;
  40542. /**
  40543. * Define the roll off factor of spatial sounds.
  40544. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40545. */
  40546. rolloffFactor: number;
  40547. /**
  40548. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  40549. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40550. */
  40551. maxDistance: number;
  40552. /**
  40553. * Define the distance attenuation model the sound will follow.
  40554. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40555. */
  40556. distanceModel: string;
  40557. /**
  40558. * @hidden
  40559. * Back Compat
  40560. **/
  40561. onended: () => any;
  40562. /**
  40563. * Gets or sets an object used to store user defined information for the sound.
  40564. */
  40565. metadata: any;
  40566. /**
  40567. * Observable event when the current playing sound finishes.
  40568. */
  40569. onEndedObservable: Observable<Sound>;
  40570. private _panningModel;
  40571. private _playbackRate;
  40572. private _streaming;
  40573. private _startTime;
  40574. private _startOffset;
  40575. private _position;
  40576. /** @hidden */
  40577. _positionInEmitterSpace: boolean;
  40578. private _localDirection;
  40579. private _volume;
  40580. private _isReadyToPlay;
  40581. private _isDirectional;
  40582. private _readyToPlayCallback;
  40583. private _audioBuffer;
  40584. private _soundSource;
  40585. private _streamingSource;
  40586. private _soundPanner;
  40587. private _soundGain;
  40588. private _inputAudioNode;
  40589. private _outputAudioNode;
  40590. private _coneInnerAngle;
  40591. private _coneOuterAngle;
  40592. private _coneOuterGain;
  40593. private _scene;
  40594. private _connectedTransformNode;
  40595. private _customAttenuationFunction;
  40596. private _registerFunc;
  40597. private _isOutputConnected;
  40598. private _htmlAudioElement;
  40599. private _urlType;
  40600. private _length?;
  40601. private _offset?;
  40602. /** @hidden */
  40603. static _SceneComponentInitialization: (scene: Scene) => void;
  40604. /**
  40605. * Create a sound and attach it to a scene
  40606. * @param name Name of your sound
  40607. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  40608. * @param scene defines the scene the sound belongs to
  40609. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  40610. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  40611. */
  40612. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  40613. /**
  40614. * Release the sound and its associated resources
  40615. */
  40616. dispose(): void;
  40617. /**
  40618. * Gets if the sounds is ready to be played or not.
  40619. * @returns true if ready, otherwise false
  40620. */
  40621. isReady(): boolean;
  40622. private _soundLoaded;
  40623. /**
  40624. * Sets the data of the sound from an audiobuffer
  40625. * @param audioBuffer The audioBuffer containing the data
  40626. */
  40627. setAudioBuffer(audioBuffer: AudioBuffer): void;
  40628. /**
  40629. * Updates the current sounds options such as maxdistance, loop...
  40630. * @param options A JSON object containing values named as the object properties
  40631. */
  40632. updateOptions(options: ISoundOptions): void;
  40633. private _createSpatialParameters;
  40634. private _updateSpatialParameters;
  40635. /**
  40636. * Switch the panning model to HRTF:
  40637. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  40638. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40639. */
  40640. switchPanningModelToHRTF(): void;
  40641. /**
  40642. * Switch the panning model to Equal Power:
  40643. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  40644. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40645. */
  40646. switchPanningModelToEqualPower(): void;
  40647. private _switchPanningModel;
  40648. /**
  40649. * Connect this sound to a sound track audio node like gain...
  40650. * @param soundTrackAudioNode the sound track audio node to connect to
  40651. */
  40652. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  40653. /**
  40654. * Transform this sound into a directional source
  40655. * @param coneInnerAngle Size of the inner cone in degree
  40656. * @param coneOuterAngle Size of the outer cone in degree
  40657. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  40658. */
  40659. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  40660. /**
  40661. * Gets or sets the inner angle for the directional cone.
  40662. */
  40663. get directionalConeInnerAngle(): number;
  40664. /**
  40665. * Gets or sets the inner angle for the directional cone.
  40666. */
  40667. set directionalConeInnerAngle(value: number);
  40668. /**
  40669. * Gets or sets the outer angle for the directional cone.
  40670. */
  40671. get directionalConeOuterAngle(): number;
  40672. /**
  40673. * Gets or sets the outer angle for the directional cone.
  40674. */
  40675. set directionalConeOuterAngle(value: number);
  40676. /**
  40677. * Sets the position of the emitter if spatial sound is enabled
  40678. * @param newPosition Defines the new posisiton
  40679. */
  40680. setPosition(newPosition: Vector3): void;
  40681. /**
  40682. * Sets the local direction of the emitter if spatial sound is enabled
  40683. * @param newLocalDirection Defines the new local direction
  40684. */
  40685. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  40686. private _updateDirection;
  40687. /** @hidden */
  40688. updateDistanceFromListener(): void;
  40689. /**
  40690. * Sets a new custom attenuation function for the sound.
  40691. * @param callback Defines the function used for the attenuation
  40692. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40693. */
  40694. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  40695. /**
  40696. * Play the sound
  40697. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  40698. * @param offset (optional) Start the sound at a specific time in seconds
  40699. * @param length (optional) Sound duration (in seconds)
  40700. */
  40701. play(time?: number, offset?: number, length?: number): void;
  40702. private _onended;
  40703. /**
  40704. * Stop the sound
  40705. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  40706. */
  40707. stop(time?: number): void;
  40708. /**
  40709. * Put the sound in pause
  40710. */
  40711. pause(): void;
  40712. /**
  40713. * Sets a dedicated volume for this sounds
  40714. * @param newVolume Define the new volume of the sound
  40715. * @param time Define time for gradual change to new volume
  40716. */
  40717. setVolume(newVolume: number, time?: number): void;
  40718. /**
  40719. * Set the sound play back rate
  40720. * @param newPlaybackRate Define the playback rate the sound should be played at
  40721. */
  40722. setPlaybackRate(newPlaybackRate: number): void;
  40723. /**
  40724. * Gets the volume of the sound.
  40725. * @returns the volume of the sound
  40726. */
  40727. getVolume(): number;
  40728. /**
  40729. * Attach the sound to a dedicated mesh
  40730. * @param transformNode The transform node to connect the sound with
  40731. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40732. */
  40733. attachToMesh(transformNode: TransformNode): void;
  40734. /**
  40735. * Detach the sound from the previously attached mesh
  40736. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40737. */
  40738. detachFromMesh(): void;
  40739. private _onRegisterAfterWorldMatrixUpdate;
  40740. /**
  40741. * Clone the current sound in the scene.
  40742. * @returns the new sound clone
  40743. */
  40744. clone(): Nullable<Sound>;
  40745. /**
  40746. * Gets the current underlying audio buffer containing the data
  40747. * @returns the audio buffer
  40748. */
  40749. getAudioBuffer(): Nullable<AudioBuffer>;
  40750. /**
  40751. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  40752. * @returns the source node
  40753. */
  40754. getSoundSource(): Nullable<AudioBufferSourceNode>;
  40755. /**
  40756. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  40757. * @returns the gain node
  40758. */
  40759. getSoundGain(): Nullable<GainNode>;
  40760. /**
  40761. * Serializes the Sound in a JSON representation
  40762. * @returns the JSON representation of the sound
  40763. */
  40764. serialize(): any;
  40765. /**
  40766. * Parse a JSON representation of a sound to innstantiate in a given scene
  40767. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  40768. * @param scene Define the scene the new parsed sound should be created in
  40769. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  40770. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  40771. * @returns the newly parsed sound
  40772. */
  40773. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  40774. }
  40775. }
  40776. declare module BABYLON {
  40777. /**
  40778. * This defines an action helpful to play a defined sound on a triggered action.
  40779. */
  40780. export class PlaySoundAction extends Action {
  40781. private _sound;
  40782. /**
  40783. * Instantiate the action
  40784. * @param triggerOptions defines the trigger options
  40785. * @param sound defines the sound to play
  40786. * @param condition defines the trigger related conditions
  40787. */
  40788. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40789. /** @hidden */
  40790. _prepare(): void;
  40791. /**
  40792. * Execute the action and play the sound.
  40793. */
  40794. execute(): void;
  40795. /**
  40796. * Serializes the actions and its related information.
  40797. * @param parent defines the object to serialize in
  40798. * @returns the serialized object
  40799. */
  40800. serialize(parent: any): any;
  40801. }
  40802. /**
  40803. * This defines an action helpful to stop a defined sound on a triggered action.
  40804. */
  40805. export class StopSoundAction extends Action {
  40806. private _sound;
  40807. /**
  40808. * Instantiate the action
  40809. * @param triggerOptions defines the trigger options
  40810. * @param sound defines the sound to stop
  40811. * @param condition defines the trigger related conditions
  40812. */
  40813. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40814. /** @hidden */
  40815. _prepare(): void;
  40816. /**
  40817. * Execute the action and stop the sound.
  40818. */
  40819. execute(): void;
  40820. /**
  40821. * Serializes the actions and its related information.
  40822. * @param parent defines the object to serialize in
  40823. * @returns the serialized object
  40824. */
  40825. serialize(parent: any): any;
  40826. }
  40827. }
  40828. declare module BABYLON {
  40829. /**
  40830. * This defines an action responsible to change the value of a property
  40831. * by interpolating between its current value and the newly set one once triggered.
  40832. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  40833. */
  40834. export class InterpolateValueAction extends Action {
  40835. /**
  40836. * Defines the path of the property where the value should be interpolated
  40837. */
  40838. propertyPath: string;
  40839. /**
  40840. * Defines the target value at the end of the interpolation.
  40841. */
  40842. value: any;
  40843. /**
  40844. * Defines the time it will take for the property to interpolate to the value.
  40845. */
  40846. duration: number;
  40847. /**
  40848. * Defines if the other scene animations should be stopped when the action has been triggered
  40849. */
  40850. stopOtherAnimations?: boolean;
  40851. /**
  40852. * Defines a callback raised once the interpolation animation has been done.
  40853. */
  40854. onInterpolationDone?: () => void;
  40855. /**
  40856. * Observable triggered once the interpolation animation has been done.
  40857. */
  40858. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  40859. private _target;
  40860. private _effectiveTarget;
  40861. private _property;
  40862. /**
  40863. * Instantiate the action
  40864. * @param triggerOptions defines the trigger options
  40865. * @param target defines the object containing the value to interpolate
  40866. * @param propertyPath defines the path to the property in the target object
  40867. * @param value defines the target value at the end of the interpolation
  40868. * @param duration deines the time it will take for the property to interpolate to the value.
  40869. * @param condition defines the trigger related conditions
  40870. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  40871. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  40872. */
  40873. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  40874. /** @hidden */
  40875. _prepare(): void;
  40876. /**
  40877. * Execute the action starts the value interpolation.
  40878. */
  40879. execute(): void;
  40880. /**
  40881. * Serializes the actions and its related information.
  40882. * @param parent defines the object to serialize in
  40883. * @returns the serialized object
  40884. */
  40885. serialize(parent: any): any;
  40886. }
  40887. }
  40888. declare module BABYLON {
  40889. /**
  40890. * Options allowed during the creation of a sound track.
  40891. */
  40892. export interface ISoundTrackOptions {
  40893. /**
  40894. * The volume the sound track should take during creation
  40895. */
  40896. volume?: number;
  40897. /**
  40898. * Define if the sound track is the main sound track of the scene
  40899. */
  40900. mainTrack?: boolean;
  40901. }
  40902. /**
  40903. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  40904. * It will be also used in a future release to apply effects on a specific track.
  40905. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40906. */
  40907. export class SoundTrack {
  40908. /**
  40909. * The unique identifier of the sound track in the scene.
  40910. */
  40911. id: number;
  40912. /**
  40913. * The list of sounds included in the sound track.
  40914. */
  40915. soundCollection: Array<Sound>;
  40916. private _outputAudioNode;
  40917. private _scene;
  40918. private _connectedAnalyser;
  40919. private _options;
  40920. private _isInitialized;
  40921. /**
  40922. * Creates a new sound track.
  40923. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40924. * @param scene Define the scene the sound track belongs to
  40925. * @param options
  40926. */
  40927. constructor(scene: Scene, options?: ISoundTrackOptions);
  40928. private _initializeSoundTrackAudioGraph;
  40929. /**
  40930. * Release the sound track and its associated resources
  40931. */
  40932. dispose(): void;
  40933. /**
  40934. * Adds a sound to this sound track
  40935. * @param sound define the cound to add
  40936. * @ignoreNaming
  40937. */
  40938. AddSound(sound: Sound): void;
  40939. /**
  40940. * Removes a sound to this sound track
  40941. * @param sound define the cound to remove
  40942. * @ignoreNaming
  40943. */
  40944. RemoveSound(sound: Sound): void;
  40945. /**
  40946. * Set a global volume for the full sound track.
  40947. * @param newVolume Define the new volume of the sound track
  40948. */
  40949. setVolume(newVolume: number): void;
  40950. /**
  40951. * Switch the panning model to HRTF:
  40952. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  40953. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40954. */
  40955. switchPanningModelToHRTF(): void;
  40956. /**
  40957. * Switch the panning model to Equal Power:
  40958. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  40959. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40960. */
  40961. switchPanningModelToEqualPower(): void;
  40962. /**
  40963. * Connect the sound track to an audio analyser allowing some amazing
  40964. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  40965. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  40966. * @param analyser The analyser to connect to the engine
  40967. */
  40968. connectToAnalyser(analyser: Analyser): void;
  40969. }
  40970. }
  40971. declare module BABYLON {
  40972. interface AbstractScene {
  40973. /**
  40974. * The list of sounds used in the scene.
  40975. */
  40976. sounds: Nullable<Array<Sound>>;
  40977. }
  40978. interface Scene {
  40979. /**
  40980. * @hidden
  40981. * Backing field
  40982. */
  40983. _mainSoundTrack: SoundTrack;
  40984. /**
  40985. * The main sound track played by the scene.
  40986. * It cotains your primary collection of sounds.
  40987. */
  40988. mainSoundTrack: SoundTrack;
  40989. /**
  40990. * The list of sound tracks added to the scene
  40991. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40992. */
  40993. soundTracks: Nullable<Array<SoundTrack>>;
  40994. /**
  40995. * Gets a sound using a given name
  40996. * @param name defines the name to search for
  40997. * @return the found sound or null if not found at all.
  40998. */
  40999. getSoundByName(name: string): Nullable<Sound>;
  41000. /**
  41001. * Gets or sets if audio support is enabled
  41002. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  41003. */
  41004. audioEnabled: boolean;
  41005. /**
  41006. * Gets or sets if audio will be output to headphones
  41007. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  41008. */
  41009. headphone: boolean;
  41010. /**
  41011. * Gets or sets custom audio listener position provider
  41012. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  41013. */
  41014. audioListenerPositionProvider: Nullable<() => Vector3>;
  41015. /**
  41016. * Gets or sets a refresh rate when using 3D audio positioning
  41017. */
  41018. audioPositioningRefreshRate: number;
  41019. }
  41020. /**
  41021. * Defines the sound scene component responsible to manage any sounds
  41022. * in a given scene.
  41023. */
  41024. export class AudioSceneComponent implements ISceneSerializableComponent {
  41025. /**
  41026. * The component name helpfull to identify the component in the list of scene components.
  41027. */
  41028. readonly name: string;
  41029. /**
  41030. * The scene the component belongs to.
  41031. */
  41032. scene: Scene;
  41033. private _audioEnabled;
  41034. /**
  41035. * Gets whether audio is enabled or not.
  41036. * Please use related enable/disable method to switch state.
  41037. */
  41038. get audioEnabled(): boolean;
  41039. private _headphone;
  41040. /**
  41041. * Gets whether audio is outputing to headphone or not.
  41042. * Please use the according Switch methods to change output.
  41043. */
  41044. get headphone(): boolean;
  41045. /**
  41046. * Gets or sets a refresh rate when using 3D audio positioning
  41047. */
  41048. audioPositioningRefreshRate: number;
  41049. private _audioListenerPositionProvider;
  41050. /**
  41051. * Gets the current audio listener position provider
  41052. */
  41053. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  41054. /**
  41055. * Sets a custom listener position for all sounds in the scene
  41056. * By default, this is the position of the first active camera
  41057. */
  41058. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  41059. /**
  41060. * Creates a new instance of the component for the given scene
  41061. * @param scene Defines the scene to register the component in
  41062. */
  41063. constructor(scene: Scene);
  41064. /**
  41065. * Registers the component in a given scene
  41066. */
  41067. register(): void;
  41068. /**
  41069. * Rebuilds the elements related to this component in case of
  41070. * context lost for instance.
  41071. */
  41072. rebuild(): void;
  41073. /**
  41074. * Serializes the component data to the specified json object
  41075. * @param serializationObject The object to serialize to
  41076. */
  41077. serialize(serializationObject: any): void;
  41078. /**
  41079. * Adds all the elements from the container to the scene
  41080. * @param container the container holding the elements
  41081. */
  41082. addFromContainer(container: AbstractScene): void;
  41083. /**
  41084. * Removes all the elements in the container from the scene
  41085. * @param container contains the elements to remove
  41086. * @param dispose if the removed element should be disposed (default: false)
  41087. */
  41088. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  41089. /**
  41090. * Disposes the component and the associated ressources.
  41091. */
  41092. dispose(): void;
  41093. /**
  41094. * Disables audio in the associated scene.
  41095. */
  41096. disableAudio(): void;
  41097. /**
  41098. * Enables audio in the associated scene.
  41099. */
  41100. enableAudio(): void;
  41101. /**
  41102. * Switch audio to headphone output.
  41103. */
  41104. switchAudioModeForHeadphones(): void;
  41105. /**
  41106. * Switch audio to normal speakers.
  41107. */
  41108. switchAudioModeForNormalSpeakers(): void;
  41109. private _cachedCameraDirection;
  41110. private _cachedCameraPosition;
  41111. private _lastCheck;
  41112. private _afterRender;
  41113. }
  41114. }
  41115. declare module BABYLON {
  41116. /**
  41117. * Wraps one or more Sound objects and selects one with random weight for playback.
  41118. */
  41119. export class WeightedSound {
  41120. /** When true a Sound will be selected and played when the current playing Sound completes. */
  41121. loop: boolean;
  41122. private _coneInnerAngle;
  41123. private _coneOuterAngle;
  41124. private _volume;
  41125. /** A Sound is currently playing. */
  41126. isPlaying: boolean;
  41127. /** A Sound is currently paused. */
  41128. isPaused: boolean;
  41129. private _sounds;
  41130. private _weights;
  41131. private _currentIndex?;
  41132. /**
  41133. * Creates a new WeightedSound from the list of sounds given.
  41134. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  41135. * @param sounds Array of Sounds that will be selected from.
  41136. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  41137. */
  41138. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  41139. /**
  41140. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  41141. */
  41142. get directionalConeInnerAngle(): number;
  41143. /**
  41144. * The size of cone in degress for a directional sound in which there will be no attenuation.
  41145. */
  41146. set directionalConeInnerAngle(value: number);
  41147. /**
  41148. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  41149. * Listener angles between innerAngle and outerAngle will falloff linearly.
  41150. */
  41151. get directionalConeOuterAngle(): number;
  41152. /**
  41153. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  41154. * Listener angles between innerAngle and outerAngle will falloff linearly.
  41155. */
  41156. set directionalConeOuterAngle(value: number);
  41157. /**
  41158. * Playback volume.
  41159. */
  41160. get volume(): number;
  41161. /**
  41162. * Playback volume.
  41163. */
  41164. set volume(value: number);
  41165. private _onended;
  41166. /**
  41167. * Suspend playback
  41168. */
  41169. pause(): void;
  41170. /**
  41171. * Stop playback
  41172. */
  41173. stop(): void;
  41174. /**
  41175. * Start playback.
  41176. * @param startOffset Position the clip head at a specific time in seconds.
  41177. */
  41178. play(startOffset?: number): void;
  41179. }
  41180. }
  41181. declare module BABYLON {
  41182. /**
  41183. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  41184. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41185. */
  41186. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  41187. /**
  41188. * Gets the name of the behavior.
  41189. */
  41190. get name(): string;
  41191. /**
  41192. * The easing function used by animations
  41193. */
  41194. static EasingFunction: BackEase;
  41195. /**
  41196. * The easing mode used by animations
  41197. */
  41198. static EasingMode: number;
  41199. /**
  41200. * The duration of the animation, in milliseconds
  41201. */
  41202. transitionDuration: number;
  41203. /**
  41204. * Length of the distance animated by the transition when lower radius is reached
  41205. */
  41206. lowerRadiusTransitionRange: number;
  41207. /**
  41208. * Length of the distance animated by the transition when upper radius is reached
  41209. */
  41210. upperRadiusTransitionRange: number;
  41211. private _autoTransitionRange;
  41212. /**
  41213. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  41214. */
  41215. get autoTransitionRange(): boolean;
  41216. /**
  41217. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  41218. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  41219. */
  41220. set autoTransitionRange(value: boolean);
  41221. private _attachedCamera;
  41222. private _onAfterCheckInputsObserver;
  41223. private _onMeshTargetChangedObserver;
  41224. /**
  41225. * Initializes the behavior.
  41226. */
  41227. init(): void;
  41228. /**
  41229. * Attaches the behavior to its arc rotate camera.
  41230. * @param camera Defines the camera to attach the behavior to
  41231. */
  41232. attach(camera: ArcRotateCamera): void;
  41233. /**
  41234. * Detaches the behavior from its current arc rotate camera.
  41235. */
  41236. detach(): void;
  41237. private _radiusIsAnimating;
  41238. private _radiusBounceTransition;
  41239. private _animatables;
  41240. private _cachedWheelPrecision;
  41241. /**
  41242. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  41243. * @param radiusLimit The limit to check against.
  41244. * @return Bool to indicate if at limit.
  41245. */
  41246. private _isRadiusAtLimit;
  41247. /**
  41248. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  41249. * @param radiusDelta The delta by which to animate to. Can be negative.
  41250. */
  41251. private _applyBoundRadiusAnimation;
  41252. /**
  41253. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  41254. */
  41255. protected _clearAnimationLocks(): void;
  41256. /**
  41257. * Stops and removes all animations that have been applied to the camera
  41258. */
  41259. stopAllAnimations(): void;
  41260. }
  41261. }
  41262. declare module BABYLON {
  41263. /**
  41264. * 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.
  41265. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41266. */
  41267. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  41268. /**
  41269. * Gets the name of the behavior.
  41270. */
  41271. get name(): string;
  41272. private _mode;
  41273. private _radiusScale;
  41274. private _positionScale;
  41275. private _defaultElevation;
  41276. private _elevationReturnTime;
  41277. private _elevationReturnWaitTime;
  41278. private _zoomStopsAnimation;
  41279. private _framingTime;
  41280. /**
  41281. * The easing function used by animations
  41282. */
  41283. static EasingFunction: ExponentialEase;
  41284. /**
  41285. * The easing mode used by animations
  41286. */
  41287. static EasingMode: number;
  41288. /**
  41289. * Sets the current mode used by the behavior
  41290. */
  41291. set mode(mode: number);
  41292. /**
  41293. * Gets current mode used by the behavior.
  41294. */
  41295. get mode(): number;
  41296. /**
  41297. * Sets the scale applied to the radius (1 by default)
  41298. */
  41299. set radiusScale(radius: number);
  41300. /**
  41301. * Gets the scale applied to the radius
  41302. */
  41303. get radiusScale(): number;
  41304. /**
  41305. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41306. */
  41307. set positionScale(scale: number);
  41308. /**
  41309. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41310. */
  41311. get positionScale(): number;
  41312. /**
  41313. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41314. * behaviour is triggered, in radians.
  41315. */
  41316. set defaultElevation(elevation: number);
  41317. /**
  41318. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41319. * behaviour is triggered, in radians.
  41320. */
  41321. get defaultElevation(): number;
  41322. /**
  41323. * Sets the time (in milliseconds) taken to return to the default beta position.
  41324. * Negative value indicates camera should not return to default.
  41325. */
  41326. set elevationReturnTime(speed: number);
  41327. /**
  41328. * Gets the time (in milliseconds) taken to return to the default beta position.
  41329. * Negative value indicates camera should not return to default.
  41330. */
  41331. get elevationReturnTime(): number;
  41332. /**
  41333. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41334. */
  41335. set elevationReturnWaitTime(time: number);
  41336. /**
  41337. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41338. */
  41339. get elevationReturnWaitTime(): number;
  41340. /**
  41341. * Sets the flag that indicates if user zooming should stop animation.
  41342. */
  41343. set zoomStopsAnimation(flag: boolean);
  41344. /**
  41345. * Gets the flag that indicates if user zooming should stop animation.
  41346. */
  41347. get zoomStopsAnimation(): boolean;
  41348. /**
  41349. * Sets the transition time when framing the mesh, in milliseconds
  41350. */
  41351. set framingTime(time: number);
  41352. /**
  41353. * Gets the transition time when framing the mesh, in milliseconds
  41354. */
  41355. get framingTime(): number;
  41356. /**
  41357. * Define if the behavior should automatically change the configured
  41358. * camera limits and sensibilities.
  41359. */
  41360. autoCorrectCameraLimitsAndSensibility: boolean;
  41361. private _onPrePointerObservableObserver;
  41362. private _onAfterCheckInputsObserver;
  41363. private _onMeshTargetChangedObserver;
  41364. private _attachedCamera;
  41365. private _isPointerDown;
  41366. private _lastInteractionTime;
  41367. /**
  41368. * Initializes the behavior.
  41369. */
  41370. init(): void;
  41371. /**
  41372. * Attaches the behavior to its arc rotate camera.
  41373. * @param camera Defines the camera to attach the behavior to
  41374. */
  41375. attach(camera: ArcRotateCamera): void;
  41376. /**
  41377. * Detaches the behavior from its current arc rotate camera.
  41378. */
  41379. detach(): void;
  41380. private _animatables;
  41381. private _betaIsAnimating;
  41382. private _betaTransition;
  41383. private _radiusTransition;
  41384. private _vectorTransition;
  41385. /**
  41386. * Targets the given mesh and updates zoom level accordingly.
  41387. * @param mesh The mesh to target.
  41388. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41389. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41390. */
  41391. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41392. /**
  41393. * Targets the given mesh with its children and updates zoom level accordingly.
  41394. * @param mesh The mesh to target.
  41395. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41396. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41397. */
  41398. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41399. /**
  41400. * Targets the given meshes with their children and updates zoom level accordingly.
  41401. * @param meshes The mesh to target.
  41402. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41403. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41404. */
  41405. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41406. /**
  41407. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  41408. * @param minimumWorld Determines the smaller position of the bounding box extend
  41409. * @param maximumWorld Determines the bigger position of the bounding box extend
  41410. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41411. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41412. */
  41413. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41414. /**
  41415. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  41416. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  41417. * frustum width.
  41418. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  41419. * to fully enclose the mesh in the viewing frustum.
  41420. */
  41421. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  41422. /**
  41423. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  41424. * is automatically returned to its default position (expected to be above ground plane).
  41425. */
  41426. private _maintainCameraAboveGround;
  41427. /**
  41428. * Returns the frustum slope based on the canvas ratio and camera FOV
  41429. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  41430. */
  41431. private _getFrustumSlope;
  41432. /**
  41433. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  41434. */
  41435. private _clearAnimationLocks;
  41436. /**
  41437. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  41438. */
  41439. private _applyUserInteraction;
  41440. /**
  41441. * Stops and removes all animations that have been applied to the camera
  41442. */
  41443. stopAllAnimations(): void;
  41444. /**
  41445. * Gets a value indicating if the user is moving the camera
  41446. */
  41447. get isUserIsMoving(): boolean;
  41448. /**
  41449. * The camera can move all the way towards the mesh.
  41450. */
  41451. static IgnoreBoundsSizeMode: number;
  41452. /**
  41453. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  41454. */
  41455. static FitFrustumSidesMode: number;
  41456. }
  41457. }
  41458. declare module BABYLON {
  41459. /**
  41460. * Base class for Camera Pointer Inputs.
  41461. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  41462. * for example usage.
  41463. */
  41464. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  41465. /**
  41466. * Defines the camera the input is attached to.
  41467. */
  41468. abstract camera: Camera;
  41469. /**
  41470. * Whether keyboard modifier keys are pressed at time of last mouse event.
  41471. */
  41472. protected _altKey: boolean;
  41473. protected _ctrlKey: boolean;
  41474. protected _metaKey: boolean;
  41475. protected _shiftKey: boolean;
  41476. /**
  41477. * Which mouse buttons were pressed at time of last mouse event.
  41478. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  41479. */
  41480. protected _buttonsPressed: number;
  41481. /**
  41482. * Defines the buttons associated with the input to handle camera move.
  41483. */
  41484. buttons: number[];
  41485. /**
  41486. * Attach the input controls to a specific dom element to get the input from.
  41487. * @param element Defines the element the controls should be listened from
  41488. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41489. */
  41490. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41491. /**
  41492. * Detach the current controls from the specified dom element.
  41493. * @param element Defines the element to stop listening the inputs from
  41494. */
  41495. detachControl(element: Nullable<HTMLElement>): void;
  41496. /**
  41497. * Gets the class name of the current input.
  41498. * @returns the class name
  41499. */
  41500. getClassName(): string;
  41501. /**
  41502. * Get the friendly name associated with the input class.
  41503. * @returns the input friendly name
  41504. */
  41505. getSimpleName(): string;
  41506. /**
  41507. * Called on pointer POINTERDOUBLETAP event.
  41508. * Override this method to provide functionality on POINTERDOUBLETAP event.
  41509. */
  41510. protected onDoubleTap(type: string): void;
  41511. /**
  41512. * Called on pointer POINTERMOVE event if only a single touch is active.
  41513. * Override this method to provide functionality.
  41514. */
  41515. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41516. /**
  41517. * Called on pointer POINTERMOVE event if multiple touches are active.
  41518. * Override this method to provide functionality.
  41519. */
  41520. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41521. /**
  41522. * Called on JS contextmenu event.
  41523. * Override this method to provide functionality.
  41524. */
  41525. protected onContextMenu(evt: PointerEvent): void;
  41526. /**
  41527. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41528. * press.
  41529. * Override this method to provide functionality.
  41530. */
  41531. protected onButtonDown(evt: PointerEvent): void;
  41532. /**
  41533. * Called each time a new POINTERUP event occurs. Ie, for each button
  41534. * release.
  41535. * Override this method to provide functionality.
  41536. */
  41537. protected onButtonUp(evt: PointerEvent): void;
  41538. /**
  41539. * Called when window becomes inactive.
  41540. * Override this method to provide functionality.
  41541. */
  41542. protected onLostFocus(): void;
  41543. private _pointerInput;
  41544. private _observer;
  41545. private _onLostFocus;
  41546. private pointA;
  41547. private pointB;
  41548. }
  41549. }
  41550. declare module BABYLON {
  41551. /**
  41552. * Manage the pointers inputs to control an arc rotate camera.
  41553. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41554. */
  41555. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  41556. /**
  41557. * Defines the camera the input is attached to.
  41558. */
  41559. camera: ArcRotateCamera;
  41560. /**
  41561. * Gets the class name of the current input.
  41562. * @returns the class name
  41563. */
  41564. getClassName(): string;
  41565. /**
  41566. * Defines the buttons associated with the input to handle camera move.
  41567. */
  41568. buttons: number[];
  41569. /**
  41570. * Defines the pointer angular sensibility along the X axis or how fast is
  41571. * the camera rotating.
  41572. */
  41573. angularSensibilityX: number;
  41574. /**
  41575. * Defines the pointer angular sensibility along the Y axis or how fast is
  41576. * the camera rotating.
  41577. */
  41578. angularSensibilityY: number;
  41579. /**
  41580. * Defines the pointer pinch precision or how fast is the camera zooming.
  41581. */
  41582. pinchPrecision: number;
  41583. /**
  41584. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41585. * from 0.
  41586. * It defines the percentage of current camera.radius to use as delta when
  41587. * pinch zoom is used.
  41588. */
  41589. pinchDeltaPercentage: number;
  41590. /**
  41591. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  41592. * that any object in the plane at the camera's target point will scale
  41593. * perfectly with finger motion.
  41594. * Overrides pinchDeltaPercentage and pinchPrecision.
  41595. */
  41596. useNaturalPinchZoom: boolean;
  41597. /**
  41598. * Defines the pointer panning sensibility or how fast is the camera moving.
  41599. */
  41600. panningSensibility: number;
  41601. /**
  41602. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  41603. */
  41604. multiTouchPanning: boolean;
  41605. /**
  41606. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  41607. * zoom (pinch) through multitouch.
  41608. */
  41609. multiTouchPanAndZoom: boolean;
  41610. /**
  41611. * Revers pinch action direction.
  41612. */
  41613. pinchInwards: boolean;
  41614. private _isPanClick;
  41615. private _twoFingerActivityCount;
  41616. private _isPinching;
  41617. /**
  41618. * Called on pointer POINTERMOVE event if only a single touch is active.
  41619. */
  41620. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41621. /**
  41622. * Called on pointer POINTERDOUBLETAP event.
  41623. */
  41624. protected onDoubleTap(type: string): void;
  41625. /**
  41626. * Called on pointer POINTERMOVE event if multiple touches are active.
  41627. */
  41628. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41629. /**
  41630. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41631. * press.
  41632. */
  41633. protected onButtonDown(evt: PointerEvent): void;
  41634. /**
  41635. * Called each time a new POINTERUP event occurs. Ie, for each button
  41636. * release.
  41637. */
  41638. protected onButtonUp(evt: PointerEvent): void;
  41639. /**
  41640. * Called when window becomes inactive.
  41641. */
  41642. protected onLostFocus(): void;
  41643. }
  41644. }
  41645. declare module BABYLON {
  41646. /**
  41647. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  41648. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41649. */
  41650. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  41651. /**
  41652. * Defines the camera the input is attached to.
  41653. */
  41654. camera: ArcRotateCamera;
  41655. /**
  41656. * Defines the list of key codes associated with the up action (increase alpha)
  41657. */
  41658. keysUp: number[];
  41659. /**
  41660. * Defines the list of key codes associated with the down action (decrease alpha)
  41661. */
  41662. keysDown: number[];
  41663. /**
  41664. * Defines the list of key codes associated with the left action (increase beta)
  41665. */
  41666. keysLeft: number[];
  41667. /**
  41668. * Defines the list of key codes associated with the right action (decrease beta)
  41669. */
  41670. keysRight: number[];
  41671. /**
  41672. * Defines the list of key codes associated with the reset action.
  41673. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  41674. */
  41675. keysReset: number[];
  41676. /**
  41677. * Defines the panning sensibility of the inputs.
  41678. * (How fast is the camera panning)
  41679. */
  41680. panningSensibility: number;
  41681. /**
  41682. * Defines the zooming sensibility of the inputs.
  41683. * (How fast is the camera zooming)
  41684. */
  41685. zoomingSensibility: number;
  41686. /**
  41687. * Defines whether maintaining the alt key down switch the movement mode from
  41688. * orientation to zoom.
  41689. */
  41690. useAltToZoom: boolean;
  41691. /**
  41692. * Rotation speed of the camera
  41693. */
  41694. angularSpeed: number;
  41695. private _keys;
  41696. private _ctrlPressed;
  41697. private _altPressed;
  41698. private _onCanvasBlurObserver;
  41699. private _onKeyboardObserver;
  41700. private _engine;
  41701. private _scene;
  41702. /**
  41703. * Attach the input controls to a specific dom element to get the input from.
  41704. * @param element Defines the element the controls should be listened from
  41705. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41706. */
  41707. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41708. /**
  41709. * Detach the current controls from the specified dom element.
  41710. * @param element Defines the element to stop listening the inputs from
  41711. */
  41712. detachControl(element: Nullable<HTMLElement>): void;
  41713. /**
  41714. * Update the current camera state depending on the inputs that have been used this frame.
  41715. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41716. */
  41717. checkInputs(): void;
  41718. /**
  41719. * Gets the class name of the current intput.
  41720. * @returns the class name
  41721. */
  41722. getClassName(): string;
  41723. /**
  41724. * Get the friendly name associated with the input class.
  41725. * @returns the input friendly name
  41726. */
  41727. getSimpleName(): string;
  41728. }
  41729. }
  41730. declare module BABYLON {
  41731. /**
  41732. * Manage the mouse wheel inputs to control an arc rotate camera.
  41733. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41734. */
  41735. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  41736. /**
  41737. * Defines the camera the input is attached to.
  41738. */
  41739. camera: ArcRotateCamera;
  41740. /**
  41741. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41742. */
  41743. wheelPrecision: number;
  41744. /**
  41745. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41746. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41747. */
  41748. wheelDeltaPercentage: number;
  41749. private _wheel;
  41750. private _observer;
  41751. private computeDeltaFromMouseWheelLegacyEvent;
  41752. /**
  41753. * Attach the input controls to a specific dom element to get the input from.
  41754. * @param element Defines the element the controls should be listened from
  41755. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41756. */
  41757. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41758. /**
  41759. * Detach the current controls from the specified dom element.
  41760. * @param element Defines the element to stop listening the inputs from
  41761. */
  41762. detachControl(element: Nullable<HTMLElement>): void;
  41763. /**
  41764. * Gets the class name of the current intput.
  41765. * @returns the class name
  41766. */
  41767. getClassName(): string;
  41768. /**
  41769. * Get the friendly name associated with the input class.
  41770. * @returns the input friendly name
  41771. */
  41772. getSimpleName(): string;
  41773. }
  41774. }
  41775. declare module BABYLON {
  41776. /**
  41777. * Default Inputs manager for the ArcRotateCamera.
  41778. * It groups all the default supported inputs for ease of use.
  41779. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41780. */
  41781. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  41782. /**
  41783. * Instantiates a new ArcRotateCameraInputsManager.
  41784. * @param camera Defines the camera the inputs belong to
  41785. */
  41786. constructor(camera: ArcRotateCamera);
  41787. /**
  41788. * Add mouse wheel input support to the input manager.
  41789. * @returns the current input manager
  41790. */
  41791. addMouseWheel(): ArcRotateCameraInputsManager;
  41792. /**
  41793. * Add pointers input support to the input manager.
  41794. * @returns the current input manager
  41795. */
  41796. addPointers(): ArcRotateCameraInputsManager;
  41797. /**
  41798. * Add keyboard input support to the input manager.
  41799. * @returns the current input manager
  41800. */
  41801. addKeyboard(): ArcRotateCameraInputsManager;
  41802. }
  41803. }
  41804. declare module BABYLON {
  41805. /**
  41806. * This represents an orbital type of camera.
  41807. *
  41808. * 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.
  41809. * 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.
  41810. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  41811. */
  41812. export class ArcRotateCamera extends TargetCamera {
  41813. /**
  41814. * Defines the rotation angle of the camera along the longitudinal axis.
  41815. */
  41816. alpha: number;
  41817. /**
  41818. * Defines the rotation angle of the camera along the latitudinal axis.
  41819. */
  41820. beta: number;
  41821. /**
  41822. * Defines the radius of the camera from it s target point.
  41823. */
  41824. radius: number;
  41825. protected _target: Vector3;
  41826. protected _targetHost: Nullable<AbstractMesh>;
  41827. /**
  41828. * Defines the target point of the camera.
  41829. * The camera looks towards it form the radius distance.
  41830. */
  41831. get target(): Vector3;
  41832. set target(value: Vector3);
  41833. /**
  41834. * Define the current local position of the camera in the scene
  41835. */
  41836. get position(): Vector3;
  41837. set position(newPosition: Vector3);
  41838. protected _upVector: Vector3;
  41839. protected _upToYMatrix: Matrix;
  41840. protected _YToUpMatrix: Matrix;
  41841. /**
  41842. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  41843. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  41844. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  41845. */
  41846. set upVector(vec: Vector3);
  41847. get upVector(): Vector3;
  41848. /**
  41849. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  41850. */
  41851. setMatUp(): void;
  41852. /**
  41853. * Current inertia value on the longitudinal axis.
  41854. * The bigger this number the longer it will take for the camera to stop.
  41855. */
  41856. inertialAlphaOffset: number;
  41857. /**
  41858. * Current inertia value on the latitudinal axis.
  41859. * The bigger this number the longer it will take for the camera to stop.
  41860. */
  41861. inertialBetaOffset: number;
  41862. /**
  41863. * Current inertia value on the radius axis.
  41864. * The bigger this number the longer it will take for the camera to stop.
  41865. */
  41866. inertialRadiusOffset: number;
  41867. /**
  41868. * Minimum allowed angle on the longitudinal axis.
  41869. * This can help limiting how the Camera is able to move in the scene.
  41870. */
  41871. lowerAlphaLimit: Nullable<number>;
  41872. /**
  41873. * Maximum allowed angle on the longitudinal axis.
  41874. * This can help limiting how the Camera is able to move in the scene.
  41875. */
  41876. upperAlphaLimit: Nullable<number>;
  41877. /**
  41878. * Minimum allowed angle on the latitudinal axis.
  41879. * This can help limiting how the Camera is able to move in the scene.
  41880. */
  41881. lowerBetaLimit: number;
  41882. /**
  41883. * Maximum allowed angle on the latitudinal axis.
  41884. * This can help limiting how the Camera is able to move in the scene.
  41885. */
  41886. upperBetaLimit: number;
  41887. /**
  41888. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  41889. * This can help limiting how the Camera is able to move in the scene.
  41890. */
  41891. lowerRadiusLimit: Nullable<number>;
  41892. /**
  41893. * Maximum allowed distance of the camera to the target (The camera can not get further).
  41894. * This can help limiting how the Camera is able to move in the scene.
  41895. */
  41896. upperRadiusLimit: Nullable<number>;
  41897. /**
  41898. * Defines the current inertia value used during panning of the camera along the X axis.
  41899. */
  41900. inertialPanningX: number;
  41901. /**
  41902. * Defines the current inertia value used during panning of the camera along the Y axis.
  41903. */
  41904. inertialPanningY: number;
  41905. /**
  41906. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  41907. * Basically if your fingers moves away from more than this distance you will be considered
  41908. * in pinch mode.
  41909. */
  41910. pinchToPanMaxDistance: number;
  41911. /**
  41912. * Defines the maximum distance the camera can pan.
  41913. * This could help keeping the cammera always in your scene.
  41914. */
  41915. panningDistanceLimit: Nullable<number>;
  41916. /**
  41917. * Defines the target of the camera before paning.
  41918. */
  41919. panningOriginTarget: Vector3;
  41920. /**
  41921. * Defines the value of the inertia used during panning.
  41922. * 0 would mean stop inertia and one would mean no decelleration at all.
  41923. */
  41924. panningInertia: number;
  41925. /**
  41926. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  41927. */
  41928. get angularSensibilityX(): number;
  41929. set angularSensibilityX(value: number);
  41930. /**
  41931. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  41932. */
  41933. get angularSensibilityY(): number;
  41934. set angularSensibilityY(value: number);
  41935. /**
  41936. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  41937. */
  41938. get pinchPrecision(): number;
  41939. set pinchPrecision(value: number);
  41940. /**
  41941. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  41942. * It will be used instead of pinchDeltaPrecision if different from 0.
  41943. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41944. */
  41945. get pinchDeltaPercentage(): number;
  41946. set pinchDeltaPercentage(value: number);
  41947. /**
  41948. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  41949. * and pinch delta percentage.
  41950. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  41951. * that any object in the plane at the camera's target point will scale
  41952. * perfectly with finger motion.
  41953. */
  41954. get useNaturalPinchZoom(): boolean;
  41955. set useNaturalPinchZoom(value: boolean);
  41956. /**
  41957. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  41958. */
  41959. get panningSensibility(): number;
  41960. set panningSensibility(value: number);
  41961. /**
  41962. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  41963. */
  41964. get keysUp(): number[];
  41965. set keysUp(value: number[]);
  41966. /**
  41967. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  41968. */
  41969. get keysDown(): number[];
  41970. set keysDown(value: number[]);
  41971. /**
  41972. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  41973. */
  41974. get keysLeft(): number[];
  41975. set keysLeft(value: number[]);
  41976. /**
  41977. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  41978. */
  41979. get keysRight(): number[];
  41980. set keysRight(value: number[]);
  41981. /**
  41982. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41983. */
  41984. get wheelPrecision(): number;
  41985. set wheelPrecision(value: number);
  41986. /**
  41987. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  41988. * It will be used instead of pinchDeltaPrecision if different from 0.
  41989. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41990. */
  41991. get wheelDeltaPercentage(): number;
  41992. set wheelDeltaPercentage(value: number);
  41993. /**
  41994. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  41995. */
  41996. zoomOnFactor: number;
  41997. /**
  41998. * Defines a screen offset for the camera position.
  41999. */
  42000. targetScreenOffset: Vector2;
  42001. /**
  42002. * Allows the camera to be completely reversed.
  42003. * If false the camera can not arrive upside down.
  42004. */
  42005. allowUpsideDown: boolean;
  42006. /**
  42007. * Define if double tap/click is used to restore the previously saved state of the camera.
  42008. */
  42009. useInputToRestoreState: boolean;
  42010. /** @hidden */
  42011. _viewMatrix: Matrix;
  42012. /** @hidden */
  42013. _useCtrlForPanning: boolean;
  42014. /** @hidden */
  42015. _panningMouseButton: number;
  42016. /**
  42017. * Defines the input associated to the camera.
  42018. */
  42019. inputs: ArcRotateCameraInputsManager;
  42020. /** @hidden */
  42021. _reset: () => void;
  42022. /**
  42023. * Defines the allowed panning axis.
  42024. */
  42025. panningAxis: Vector3;
  42026. protected _localDirection: Vector3;
  42027. protected _transformedDirection: Vector3;
  42028. private _bouncingBehavior;
  42029. /**
  42030. * Gets the bouncing behavior of the camera if it has been enabled.
  42031. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42032. */
  42033. get bouncingBehavior(): Nullable<BouncingBehavior>;
  42034. /**
  42035. * Defines if the bouncing behavior of the camera is enabled on the camera.
  42036. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42037. */
  42038. get useBouncingBehavior(): boolean;
  42039. set useBouncingBehavior(value: boolean);
  42040. private _framingBehavior;
  42041. /**
  42042. * Gets the framing behavior of the camera if it has been enabled.
  42043. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42044. */
  42045. get framingBehavior(): Nullable<FramingBehavior>;
  42046. /**
  42047. * Defines if the framing behavior of the camera is enabled on the camera.
  42048. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42049. */
  42050. get useFramingBehavior(): boolean;
  42051. set useFramingBehavior(value: boolean);
  42052. private _autoRotationBehavior;
  42053. /**
  42054. * Gets the auto rotation behavior of the camera if it has been enabled.
  42055. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42056. */
  42057. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  42058. /**
  42059. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  42060. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42061. */
  42062. get useAutoRotationBehavior(): boolean;
  42063. set useAutoRotationBehavior(value: boolean);
  42064. /**
  42065. * Observable triggered when the mesh target has been changed on the camera.
  42066. */
  42067. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  42068. /**
  42069. * Event raised when the camera is colliding with a mesh.
  42070. */
  42071. onCollide: (collidedMesh: AbstractMesh) => void;
  42072. /**
  42073. * Defines whether the camera should check collision with the objects oh the scene.
  42074. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  42075. */
  42076. checkCollisions: boolean;
  42077. /**
  42078. * Defines the collision radius of the camera.
  42079. * This simulates a sphere around the camera.
  42080. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  42081. */
  42082. collisionRadius: Vector3;
  42083. protected _collider: Collider;
  42084. protected _previousPosition: Vector3;
  42085. protected _collisionVelocity: Vector3;
  42086. protected _newPosition: Vector3;
  42087. protected _previousAlpha: number;
  42088. protected _previousBeta: number;
  42089. protected _previousRadius: number;
  42090. protected _collisionTriggered: boolean;
  42091. protected _targetBoundingCenter: Nullable<Vector3>;
  42092. private _computationVector;
  42093. /**
  42094. * Instantiates a new ArcRotateCamera in a given scene
  42095. * @param name Defines the name of the camera
  42096. * @param alpha Defines the camera rotation along the logitudinal axis
  42097. * @param beta Defines the camera rotation along the latitudinal axis
  42098. * @param radius Defines the camera distance from its target
  42099. * @param target Defines the camera target
  42100. * @param scene Defines the scene the camera belongs to
  42101. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  42102. */
  42103. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  42104. /** @hidden */
  42105. _initCache(): void;
  42106. /** @hidden */
  42107. _updateCache(ignoreParentClass?: boolean): void;
  42108. protected _getTargetPosition(): Vector3;
  42109. private _storedAlpha;
  42110. private _storedBeta;
  42111. private _storedRadius;
  42112. private _storedTarget;
  42113. private _storedTargetScreenOffset;
  42114. /**
  42115. * Stores the current state of the camera (alpha, beta, radius and target)
  42116. * @returns the camera itself
  42117. */
  42118. storeState(): Camera;
  42119. /**
  42120. * @hidden
  42121. * Restored camera state. You must call storeState() first
  42122. */
  42123. _restoreStateValues(): boolean;
  42124. /** @hidden */
  42125. _isSynchronizedViewMatrix(): boolean;
  42126. /**
  42127. * Attached controls to the current camera.
  42128. * @param element Defines the element the controls should be listened from
  42129. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42130. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  42131. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  42132. */
  42133. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  42134. /**
  42135. * Detach the current controls from the camera.
  42136. * The camera will stop reacting to inputs.
  42137. * @param element Defines the element to stop listening the inputs from
  42138. */
  42139. detachControl(element: HTMLElement): void;
  42140. /** @hidden */
  42141. _checkInputs(): void;
  42142. protected _checkLimits(): void;
  42143. /**
  42144. * Rebuilds angles (alpha, beta) and radius from the give position and target
  42145. */
  42146. rebuildAnglesAndRadius(): void;
  42147. /**
  42148. * Use a position to define the current camera related information like alpha, beta and radius
  42149. * @param position Defines the position to set the camera at
  42150. */
  42151. setPosition(position: Vector3): void;
  42152. /**
  42153. * Defines the target the camera should look at.
  42154. * This will automatically adapt alpha beta and radius to fit within the new target.
  42155. * @param target Defines the new target as a Vector or a mesh
  42156. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  42157. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  42158. */
  42159. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  42160. /** @hidden */
  42161. _getViewMatrix(): Matrix;
  42162. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  42163. /**
  42164. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  42165. * @param meshes Defines the mesh to zoom on
  42166. * @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)
  42167. */
  42168. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  42169. /**
  42170. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  42171. * The target will be changed but the radius
  42172. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  42173. * @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)
  42174. */
  42175. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  42176. min: Vector3;
  42177. max: Vector3;
  42178. distance: number;
  42179. }, doNotUpdateMaxZ?: boolean): void;
  42180. /**
  42181. * @override
  42182. * Override Camera.createRigCamera
  42183. */
  42184. createRigCamera(name: string, cameraIndex: number): Camera;
  42185. /**
  42186. * @hidden
  42187. * @override
  42188. * Override Camera._updateRigCameras
  42189. */
  42190. _updateRigCameras(): void;
  42191. /**
  42192. * Destroy the camera and release the current resources hold by it.
  42193. */
  42194. dispose(): void;
  42195. /**
  42196. * Gets the current object class name.
  42197. * @return the class name
  42198. */
  42199. getClassName(): string;
  42200. }
  42201. }
  42202. declare module BABYLON {
  42203. /**
  42204. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  42205. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42206. */
  42207. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  42208. /**
  42209. * Gets the name of the behavior.
  42210. */
  42211. get name(): string;
  42212. private _zoomStopsAnimation;
  42213. private _idleRotationSpeed;
  42214. private _idleRotationWaitTime;
  42215. private _idleRotationSpinupTime;
  42216. /**
  42217. * Sets the flag that indicates if user zooming should stop animation.
  42218. */
  42219. set zoomStopsAnimation(flag: boolean);
  42220. /**
  42221. * Gets the flag that indicates if user zooming should stop animation.
  42222. */
  42223. get zoomStopsAnimation(): boolean;
  42224. /**
  42225. * Sets the default speed at which the camera rotates around the model.
  42226. */
  42227. set idleRotationSpeed(speed: number);
  42228. /**
  42229. * Gets the default speed at which the camera rotates around the model.
  42230. */
  42231. get idleRotationSpeed(): number;
  42232. /**
  42233. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  42234. */
  42235. set idleRotationWaitTime(time: number);
  42236. /**
  42237. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  42238. */
  42239. get idleRotationWaitTime(): number;
  42240. /**
  42241. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  42242. */
  42243. set idleRotationSpinupTime(time: number);
  42244. /**
  42245. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  42246. */
  42247. get idleRotationSpinupTime(): number;
  42248. /**
  42249. * Gets a value indicating if the camera is currently rotating because of this behavior
  42250. */
  42251. get rotationInProgress(): boolean;
  42252. private _onPrePointerObservableObserver;
  42253. private _onAfterCheckInputsObserver;
  42254. private _attachedCamera;
  42255. private _isPointerDown;
  42256. private _lastFrameTime;
  42257. private _lastInteractionTime;
  42258. private _cameraRotationSpeed;
  42259. /**
  42260. * Initializes the behavior.
  42261. */
  42262. init(): void;
  42263. /**
  42264. * Attaches the behavior to its arc rotate camera.
  42265. * @param camera Defines the camera to attach the behavior to
  42266. */
  42267. attach(camera: ArcRotateCamera): void;
  42268. /**
  42269. * Detaches the behavior from its current arc rotate camera.
  42270. */
  42271. detach(): void;
  42272. /**
  42273. * Returns true if user is scrolling.
  42274. * @return true if user is scrolling.
  42275. */
  42276. private _userIsZooming;
  42277. private _lastFrameRadius;
  42278. private _shouldAnimationStopForInteraction;
  42279. /**
  42280. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42281. */
  42282. private _applyUserInteraction;
  42283. private _userIsMoving;
  42284. }
  42285. }
  42286. declare module BABYLON {
  42287. /**
  42288. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  42289. */
  42290. export class AttachToBoxBehavior implements Behavior<Mesh> {
  42291. private ui;
  42292. /**
  42293. * The name of the behavior
  42294. */
  42295. name: string;
  42296. /**
  42297. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  42298. */
  42299. distanceAwayFromFace: number;
  42300. /**
  42301. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  42302. */
  42303. distanceAwayFromBottomOfFace: number;
  42304. private _faceVectors;
  42305. private _target;
  42306. private _scene;
  42307. private _onRenderObserver;
  42308. private _tmpMatrix;
  42309. private _tmpVector;
  42310. /**
  42311. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  42312. * @param ui The transform node that should be attched to the mesh
  42313. */
  42314. constructor(ui: TransformNode);
  42315. /**
  42316. * Initializes the behavior
  42317. */
  42318. init(): void;
  42319. private _closestFace;
  42320. private _zeroVector;
  42321. private _lookAtTmpMatrix;
  42322. private _lookAtToRef;
  42323. /**
  42324. * Attaches the AttachToBoxBehavior to the passed in mesh
  42325. * @param target The mesh that the specified node will be attached to
  42326. */
  42327. attach(target: Mesh): void;
  42328. /**
  42329. * Detaches the behavior from the mesh
  42330. */
  42331. detach(): void;
  42332. }
  42333. }
  42334. declare module BABYLON {
  42335. /**
  42336. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  42337. */
  42338. export class FadeInOutBehavior implements Behavior<Mesh> {
  42339. /**
  42340. * Time in milliseconds to delay before fading in (Default: 0)
  42341. */
  42342. delay: number;
  42343. /**
  42344. * Time in milliseconds for the mesh to fade in (Default: 300)
  42345. */
  42346. fadeInTime: number;
  42347. private _millisecondsPerFrame;
  42348. private _hovered;
  42349. private _hoverValue;
  42350. private _ownerNode;
  42351. /**
  42352. * Instatiates the FadeInOutBehavior
  42353. */
  42354. constructor();
  42355. /**
  42356. * The name of the behavior
  42357. */
  42358. get name(): string;
  42359. /**
  42360. * Initializes the behavior
  42361. */
  42362. init(): void;
  42363. /**
  42364. * Attaches the fade behavior on the passed in mesh
  42365. * @param ownerNode The mesh that will be faded in/out once attached
  42366. */
  42367. attach(ownerNode: Mesh): void;
  42368. /**
  42369. * Detaches the behavior from the mesh
  42370. */
  42371. detach(): void;
  42372. /**
  42373. * Triggers the mesh to begin fading in or out
  42374. * @param value if the object should fade in or out (true to fade in)
  42375. */
  42376. fadeIn(value: boolean): void;
  42377. private _update;
  42378. private _setAllVisibility;
  42379. }
  42380. }
  42381. declare module BABYLON {
  42382. /**
  42383. * Class containing a set of static utilities functions for managing Pivots
  42384. * @hidden
  42385. */
  42386. export class PivotTools {
  42387. private static _PivotCached;
  42388. private static _OldPivotPoint;
  42389. private static _PivotTranslation;
  42390. private static _PivotTmpVector;
  42391. /** @hidden */
  42392. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  42393. /** @hidden */
  42394. static _RestorePivotPoint(mesh: AbstractMesh): void;
  42395. }
  42396. }
  42397. declare module BABYLON {
  42398. /**
  42399. * Class containing static functions to help procedurally build meshes
  42400. */
  42401. export class PlaneBuilder {
  42402. /**
  42403. * Creates a plane mesh
  42404. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  42405. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  42406. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  42407. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42408. * * 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
  42409. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42410. * @param name defines the name of the mesh
  42411. * @param options defines the options used to create the mesh
  42412. * @param scene defines the hosting scene
  42413. * @returns the plane mesh
  42414. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  42415. */
  42416. static CreatePlane(name: string, options: {
  42417. size?: number;
  42418. width?: number;
  42419. height?: number;
  42420. sideOrientation?: number;
  42421. frontUVs?: Vector4;
  42422. backUVs?: Vector4;
  42423. updatable?: boolean;
  42424. sourcePlane?: Plane;
  42425. }, scene?: Nullable<Scene>): Mesh;
  42426. }
  42427. }
  42428. declare module BABYLON {
  42429. /**
  42430. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  42431. */
  42432. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  42433. private static _AnyMouseID;
  42434. /**
  42435. * Abstract mesh the behavior is set on
  42436. */
  42437. attachedNode: AbstractMesh;
  42438. private _dragPlane;
  42439. private _scene;
  42440. private _pointerObserver;
  42441. private _beforeRenderObserver;
  42442. private static _planeScene;
  42443. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  42444. /**
  42445. * 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)
  42446. */
  42447. maxDragAngle: number;
  42448. /**
  42449. * @hidden
  42450. */
  42451. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  42452. /**
  42453. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42454. */
  42455. currentDraggingPointerID: number;
  42456. /**
  42457. * The last position where the pointer hit the drag plane in world space
  42458. */
  42459. lastDragPosition: Vector3;
  42460. /**
  42461. * If the behavior is currently in a dragging state
  42462. */
  42463. dragging: boolean;
  42464. /**
  42465. * 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)
  42466. */
  42467. dragDeltaRatio: number;
  42468. /**
  42469. * If the drag plane orientation should be updated during the dragging (Default: true)
  42470. */
  42471. updateDragPlane: boolean;
  42472. private _debugMode;
  42473. private _moving;
  42474. /**
  42475. * Fires each time the attached mesh is dragged with the pointer
  42476. * * delta between last drag position and current drag position in world space
  42477. * * dragDistance along the drag axis
  42478. * * dragPlaneNormal normal of the current drag plane used during the drag
  42479. * * dragPlanePoint in world space where the drag intersects the drag plane
  42480. */
  42481. onDragObservable: Observable<{
  42482. delta: Vector3;
  42483. dragPlanePoint: Vector3;
  42484. dragPlaneNormal: Vector3;
  42485. dragDistance: number;
  42486. pointerId: number;
  42487. }>;
  42488. /**
  42489. * Fires each time a drag begins (eg. mouse down on mesh)
  42490. */
  42491. onDragStartObservable: Observable<{
  42492. dragPlanePoint: Vector3;
  42493. pointerId: number;
  42494. }>;
  42495. /**
  42496. * Fires each time a drag ends (eg. mouse release after drag)
  42497. */
  42498. onDragEndObservable: Observable<{
  42499. dragPlanePoint: Vector3;
  42500. pointerId: number;
  42501. }>;
  42502. /**
  42503. * If the attached mesh should be moved when dragged
  42504. */
  42505. moveAttached: boolean;
  42506. /**
  42507. * If the drag behavior will react to drag events (Default: true)
  42508. */
  42509. enabled: boolean;
  42510. /**
  42511. * If pointer events should start and release the drag (Default: true)
  42512. */
  42513. startAndReleaseDragOnPointerEvents: boolean;
  42514. /**
  42515. * If camera controls should be detached during the drag
  42516. */
  42517. detachCameraControls: boolean;
  42518. /**
  42519. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  42520. */
  42521. useObjectOrientationForDragging: boolean;
  42522. private _options;
  42523. /**
  42524. * Gets the options used by the behavior
  42525. */
  42526. get options(): {
  42527. dragAxis?: Vector3;
  42528. dragPlaneNormal?: Vector3;
  42529. };
  42530. /**
  42531. * Sets the options used by the behavior
  42532. */
  42533. set options(options: {
  42534. dragAxis?: Vector3;
  42535. dragPlaneNormal?: Vector3;
  42536. });
  42537. /**
  42538. * Creates a pointer drag behavior that can be attached to a mesh
  42539. * @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)
  42540. */
  42541. constructor(options?: {
  42542. dragAxis?: Vector3;
  42543. dragPlaneNormal?: Vector3;
  42544. });
  42545. /**
  42546. * Predicate to determine if it is valid to move the object to a new position when it is moved
  42547. */
  42548. validateDrag: (targetPosition: Vector3) => boolean;
  42549. /**
  42550. * The name of the behavior
  42551. */
  42552. get name(): string;
  42553. /**
  42554. * Initializes the behavior
  42555. */
  42556. init(): void;
  42557. private _tmpVector;
  42558. private _alternatePickedPoint;
  42559. private _worldDragAxis;
  42560. private _targetPosition;
  42561. private _attachedElement;
  42562. /**
  42563. * Attaches the drag behavior the passed in mesh
  42564. * @param ownerNode The mesh that will be dragged around once attached
  42565. * @param predicate Predicate to use for pick filtering
  42566. */
  42567. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  42568. /**
  42569. * Force relase the drag action by code.
  42570. */
  42571. releaseDrag(): void;
  42572. private _startDragRay;
  42573. private _lastPointerRay;
  42574. /**
  42575. * Simulates the start of a pointer drag event on the behavior
  42576. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  42577. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  42578. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  42579. */
  42580. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  42581. private _startDrag;
  42582. private _dragDelta;
  42583. private _moveDrag;
  42584. private _pickWithRayOnDragPlane;
  42585. private _pointA;
  42586. private _pointB;
  42587. private _pointC;
  42588. private _lineA;
  42589. private _lineB;
  42590. private _localAxis;
  42591. private _lookAt;
  42592. private _updateDragPlanePosition;
  42593. /**
  42594. * Detaches the behavior from the mesh
  42595. */
  42596. detach(): void;
  42597. }
  42598. }
  42599. declare module BABYLON {
  42600. /**
  42601. * A behavior that when attached to a mesh will allow the mesh to be scaled
  42602. */
  42603. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  42604. private _dragBehaviorA;
  42605. private _dragBehaviorB;
  42606. private _startDistance;
  42607. private _initialScale;
  42608. private _targetScale;
  42609. private _ownerNode;
  42610. private _sceneRenderObserver;
  42611. /**
  42612. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  42613. */
  42614. constructor();
  42615. /**
  42616. * The name of the behavior
  42617. */
  42618. get name(): string;
  42619. /**
  42620. * Initializes the behavior
  42621. */
  42622. init(): void;
  42623. private _getCurrentDistance;
  42624. /**
  42625. * Attaches the scale behavior the passed in mesh
  42626. * @param ownerNode The mesh that will be scaled around once attached
  42627. */
  42628. attach(ownerNode: Mesh): void;
  42629. /**
  42630. * Detaches the behavior from the mesh
  42631. */
  42632. detach(): void;
  42633. }
  42634. }
  42635. declare module BABYLON {
  42636. /**
  42637. * 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
  42638. */
  42639. export class SixDofDragBehavior implements Behavior<Mesh> {
  42640. private static _virtualScene;
  42641. private _ownerNode;
  42642. private _sceneRenderObserver;
  42643. private _scene;
  42644. private _targetPosition;
  42645. private _virtualOriginMesh;
  42646. private _virtualDragMesh;
  42647. private _pointerObserver;
  42648. private _moving;
  42649. private _startingOrientation;
  42650. private _attachedElement;
  42651. /**
  42652. * 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)
  42653. */
  42654. private zDragFactor;
  42655. /**
  42656. * If the object should rotate to face the drag origin
  42657. */
  42658. rotateDraggedObject: boolean;
  42659. /**
  42660. * If the behavior is currently in a dragging state
  42661. */
  42662. dragging: boolean;
  42663. /**
  42664. * 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)
  42665. */
  42666. dragDeltaRatio: number;
  42667. /**
  42668. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42669. */
  42670. currentDraggingPointerID: number;
  42671. /**
  42672. * If camera controls should be detached during the drag
  42673. */
  42674. detachCameraControls: boolean;
  42675. /**
  42676. * Fires each time a drag starts
  42677. */
  42678. onDragStartObservable: Observable<{}>;
  42679. /**
  42680. * Fires each time a drag ends (eg. mouse release after drag)
  42681. */
  42682. onDragEndObservable: Observable<{}>;
  42683. /**
  42684. * 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
  42685. */
  42686. constructor();
  42687. /**
  42688. * The name of the behavior
  42689. */
  42690. get name(): string;
  42691. /**
  42692. * Initializes the behavior
  42693. */
  42694. init(): void;
  42695. /**
  42696. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  42697. */
  42698. private get _pointerCamera();
  42699. /**
  42700. * Attaches the scale behavior the passed in mesh
  42701. * @param ownerNode The mesh that will be scaled around once attached
  42702. */
  42703. attach(ownerNode: Mesh): void;
  42704. /**
  42705. * Detaches the behavior from the mesh
  42706. */
  42707. detach(): void;
  42708. }
  42709. }
  42710. declare module BABYLON {
  42711. /**
  42712. * Class used to apply inverse kinematics to bones
  42713. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  42714. */
  42715. export class BoneIKController {
  42716. private static _tmpVecs;
  42717. private static _tmpQuat;
  42718. private static _tmpMats;
  42719. /**
  42720. * Gets or sets the target mesh
  42721. */
  42722. targetMesh: AbstractMesh;
  42723. /** Gets or sets the mesh used as pole */
  42724. poleTargetMesh: AbstractMesh;
  42725. /**
  42726. * Gets or sets the bone used as pole
  42727. */
  42728. poleTargetBone: Nullable<Bone>;
  42729. /**
  42730. * Gets or sets the target position
  42731. */
  42732. targetPosition: Vector3;
  42733. /**
  42734. * Gets or sets the pole target position
  42735. */
  42736. poleTargetPosition: Vector3;
  42737. /**
  42738. * Gets or sets the pole target local offset
  42739. */
  42740. poleTargetLocalOffset: Vector3;
  42741. /**
  42742. * Gets or sets the pole angle
  42743. */
  42744. poleAngle: number;
  42745. /**
  42746. * Gets or sets the mesh associated with the controller
  42747. */
  42748. mesh: AbstractMesh;
  42749. /**
  42750. * 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)
  42751. */
  42752. slerpAmount: number;
  42753. private _bone1Quat;
  42754. private _bone1Mat;
  42755. private _bone2Ang;
  42756. private _bone1;
  42757. private _bone2;
  42758. private _bone1Length;
  42759. private _bone2Length;
  42760. private _maxAngle;
  42761. private _maxReach;
  42762. private _rightHandedSystem;
  42763. private _bendAxis;
  42764. private _slerping;
  42765. private _adjustRoll;
  42766. /**
  42767. * Gets or sets maximum allowed angle
  42768. */
  42769. get maxAngle(): number;
  42770. set maxAngle(value: number);
  42771. /**
  42772. * Creates a new BoneIKController
  42773. * @param mesh defines the mesh to control
  42774. * @param bone defines the bone to control
  42775. * @param options defines options to set up the controller
  42776. */
  42777. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  42778. targetMesh?: AbstractMesh;
  42779. poleTargetMesh?: AbstractMesh;
  42780. poleTargetBone?: Bone;
  42781. poleTargetLocalOffset?: Vector3;
  42782. poleAngle?: number;
  42783. bendAxis?: Vector3;
  42784. maxAngle?: number;
  42785. slerpAmount?: number;
  42786. });
  42787. private _setMaxAngle;
  42788. /**
  42789. * Force the controller to update the bones
  42790. */
  42791. update(): void;
  42792. }
  42793. }
  42794. declare module BABYLON {
  42795. /**
  42796. * Class used to make a bone look toward a point in space
  42797. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  42798. */
  42799. export class BoneLookController {
  42800. private static _tmpVecs;
  42801. private static _tmpQuat;
  42802. private static _tmpMats;
  42803. /**
  42804. * The target Vector3 that the bone will look at
  42805. */
  42806. target: Vector3;
  42807. /**
  42808. * The mesh that the bone is attached to
  42809. */
  42810. mesh: AbstractMesh;
  42811. /**
  42812. * The bone that will be looking to the target
  42813. */
  42814. bone: Bone;
  42815. /**
  42816. * The up axis of the coordinate system that is used when the bone is rotated
  42817. */
  42818. upAxis: Vector3;
  42819. /**
  42820. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  42821. */
  42822. upAxisSpace: Space;
  42823. /**
  42824. * Used to make an adjustment to the yaw of the bone
  42825. */
  42826. adjustYaw: number;
  42827. /**
  42828. * Used to make an adjustment to the pitch of the bone
  42829. */
  42830. adjustPitch: number;
  42831. /**
  42832. * Used to make an adjustment to the roll of the bone
  42833. */
  42834. adjustRoll: number;
  42835. /**
  42836. * 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)
  42837. */
  42838. slerpAmount: number;
  42839. private _minYaw;
  42840. private _maxYaw;
  42841. private _minPitch;
  42842. private _maxPitch;
  42843. private _minYawSin;
  42844. private _minYawCos;
  42845. private _maxYawSin;
  42846. private _maxYawCos;
  42847. private _midYawConstraint;
  42848. private _minPitchTan;
  42849. private _maxPitchTan;
  42850. private _boneQuat;
  42851. private _slerping;
  42852. private _transformYawPitch;
  42853. private _transformYawPitchInv;
  42854. private _firstFrameSkipped;
  42855. private _yawRange;
  42856. private _fowardAxis;
  42857. /**
  42858. * Gets or sets the minimum yaw angle that the bone can look to
  42859. */
  42860. get minYaw(): number;
  42861. set minYaw(value: number);
  42862. /**
  42863. * Gets or sets the maximum yaw angle that the bone can look to
  42864. */
  42865. get maxYaw(): number;
  42866. set maxYaw(value: number);
  42867. /**
  42868. * Gets or sets the minimum pitch angle that the bone can look to
  42869. */
  42870. get minPitch(): number;
  42871. set minPitch(value: number);
  42872. /**
  42873. * Gets or sets the maximum pitch angle that the bone can look to
  42874. */
  42875. get maxPitch(): number;
  42876. set maxPitch(value: number);
  42877. /**
  42878. * Create a BoneLookController
  42879. * @param mesh the mesh that the bone belongs to
  42880. * @param bone the bone that will be looking to the target
  42881. * @param target the target Vector3 to look at
  42882. * @param options optional settings:
  42883. * * maxYaw: the maximum angle the bone will yaw to
  42884. * * minYaw: the minimum angle the bone will yaw to
  42885. * * maxPitch: the maximum angle the bone will pitch to
  42886. * * minPitch: the minimum angle the bone will yaw to
  42887. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  42888. * * upAxis: the up axis of the coordinate system
  42889. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  42890. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  42891. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  42892. * * adjustYaw: used to make an adjustment to the yaw of the bone
  42893. * * adjustPitch: used to make an adjustment to the pitch of the bone
  42894. * * adjustRoll: used to make an adjustment to the roll of the bone
  42895. **/
  42896. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  42897. maxYaw?: number;
  42898. minYaw?: number;
  42899. maxPitch?: number;
  42900. minPitch?: number;
  42901. slerpAmount?: number;
  42902. upAxis?: Vector3;
  42903. upAxisSpace?: Space;
  42904. yawAxis?: Vector3;
  42905. pitchAxis?: Vector3;
  42906. adjustYaw?: number;
  42907. adjustPitch?: number;
  42908. adjustRoll?: number;
  42909. });
  42910. /**
  42911. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  42912. */
  42913. update(): void;
  42914. private _getAngleDiff;
  42915. private _getAngleBetween;
  42916. private _isAngleBetween;
  42917. }
  42918. }
  42919. declare module BABYLON {
  42920. /**
  42921. * Manage the gamepad inputs to control an arc rotate camera.
  42922. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42923. */
  42924. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  42925. /**
  42926. * Defines the camera the input is attached to.
  42927. */
  42928. camera: ArcRotateCamera;
  42929. /**
  42930. * Defines the gamepad the input is gathering event from.
  42931. */
  42932. gamepad: Nullable<Gamepad>;
  42933. /**
  42934. * Defines the gamepad rotation sensiblity.
  42935. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42936. */
  42937. gamepadRotationSensibility: number;
  42938. /**
  42939. * Defines the gamepad move sensiblity.
  42940. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42941. */
  42942. gamepadMoveSensibility: number;
  42943. private _yAxisScale;
  42944. /**
  42945. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  42946. */
  42947. get invertYAxis(): boolean;
  42948. set invertYAxis(value: boolean);
  42949. private _onGamepadConnectedObserver;
  42950. private _onGamepadDisconnectedObserver;
  42951. /**
  42952. * Attach the input controls to a specific dom element to get the input from.
  42953. * @param element Defines the element the controls should be listened from
  42954. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42955. */
  42956. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42957. /**
  42958. * Detach the current controls from the specified dom element.
  42959. * @param element Defines the element to stop listening the inputs from
  42960. */
  42961. detachControl(element: Nullable<HTMLElement>): void;
  42962. /**
  42963. * Update the current camera state depending on the inputs that have been used this frame.
  42964. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42965. */
  42966. checkInputs(): void;
  42967. /**
  42968. * Gets the class name of the current intput.
  42969. * @returns the class name
  42970. */
  42971. getClassName(): string;
  42972. /**
  42973. * Get the friendly name associated with the input class.
  42974. * @returns the input friendly name
  42975. */
  42976. getSimpleName(): string;
  42977. }
  42978. }
  42979. declare module BABYLON {
  42980. interface ArcRotateCameraInputsManager {
  42981. /**
  42982. * Add orientation input support to the input manager.
  42983. * @returns the current input manager
  42984. */
  42985. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  42986. }
  42987. /**
  42988. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  42989. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42990. */
  42991. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  42992. /**
  42993. * Defines the camera the input is attached to.
  42994. */
  42995. camera: ArcRotateCamera;
  42996. /**
  42997. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  42998. */
  42999. alphaCorrection: number;
  43000. /**
  43001. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  43002. */
  43003. gammaCorrection: number;
  43004. private _alpha;
  43005. private _gamma;
  43006. private _dirty;
  43007. private _deviceOrientationHandler;
  43008. /**
  43009. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  43010. */
  43011. constructor();
  43012. /**
  43013. * Attach the input controls to a specific dom element to get the input from.
  43014. * @param element Defines the element the controls should be listened from
  43015. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43016. */
  43017. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43018. /** @hidden */
  43019. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  43020. /**
  43021. * Update the current camera state depending on the inputs that have been used this frame.
  43022. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43023. */
  43024. checkInputs(): void;
  43025. /**
  43026. * Detach the current controls from the specified dom element.
  43027. * @param element Defines the element to stop listening the inputs from
  43028. */
  43029. detachControl(element: Nullable<HTMLElement>): void;
  43030. /**
  43031. * Gets the class name of the current intput.
  43032. * @returns the class name
  43033. */
  43034. getClassName(): string;
  43035. /**
  43036. * Get the friendly name associated with the input class.
  43037. * @returns the input friendly name
  43038. */
  43039. getSimpleName(): string;
  43040. }
  43041. }
  43042. declare module BABYLON {
  43043. /**
  43044. * Listen to mouse events to control the camera.
  43045. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43046. */
  43047. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  43048. /**
  43049. * Defines the camera the input is attached to.
  43050. */
  43051. camera: FlyCamera;
  43052. /**
  43053. * Defines if touch is enabled. (Default is true.)
  43054. */
  43055. touchEnabled: boolean;
  43056. /**
  43057. * Defines the buttons associated with the input to handle camera rotation.
  43058. */
  43059. buttons: number[];
  43060. /**
  43061. * Assign buttons for Yaw control.
  43062. */
  43063. buttonsYaw: number[];
  43064. /**
  43065. * Assign buttons for Pitch control.
  43066. */
  43067. buttonsPitch: number[];
  43068. /**
  43069. * Assign buttons for Roll control.
  43070. */
  43071. buttonsRoll: number[];
  43072. /**
  43073. * Detect if any button is being pressed while mouse is moved.
  43074. * -1 = Mouse locked.
  43075. * 0 = Left button.
  43076. * 1 = Middle Button.
  43077. * 2 = Right Button.
  43078. */
  43079. activeButton: number;
  43080. /**
  43081. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  43082. * Higher values reduce its sensitivity.
  43083. */
  43084. angularSensibility: number;
  43085. private _mousemoveCallback;
  43086. private _observer;
  43087. private _rollObserver;
  43088. private previousPosition;
  43089. private noPreventDefault;
  43090. private element;
  43091. /**
  43092. * Listen to mouse events to control the camera.
  43093. * @param touchEnabled Define if touch is enabled. (Default is true.)
  43094. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43095. */
  43096. constructor(touchEnabled?: boolean);
  43097. /**
  43098. * Attach the mouse control to the HTML DOM element.
  43099. * @param element Defines the element that listens to the input events.
  43100. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  43101. */
  43102. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43103. /**
  43104. * Detach the current controls from the specified dom element.
  43105. * @param element Defines the element to stop listening the inputs from
  43106. */
  43107. detachControl(element: Nullable<HTMLElement>): void;
  43108. /**
  43109. * Gets the class name of the current input.
  43110. * @returns the class name.
  43111. */
  43112. getClassName(): string;
  43113. /**
  43114. * Get the friendly name associated with the input class.
  43115. * @returns the input's friendly name.
  43116. */
  43117. getSimpleName(): string;
  43118. private _pointerInput;
  43119. private _onMouseMove;
  43120. /**
  43121. * Rotate camera by mouse offset.
  43122. */
  43123. private rotateCamera;
  43124. }
  43125. }
  43126. declare module BABYLON {
  43127. /**
  43128. * Default Inputs manager for the FlyCamera.
  43129. * It groups all the default supported inputs for ease of use.
  43130. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43131. */
  43132. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  43133. /**
  43134. * Instantiates a new FlyCameraInputsManager.
  43135. * @param camera Defines the camera the inputs belong to.
  43136. */
  43137. constructor(camera: FlyCamera);
  43138. /**
  43139. * Add keyboard input support to the input manager.
  43140. * @returns the new FlyCameraKeyboardMoveInput().
  43141. */
  43142. addKeyboard(): FlyCameraInputsManager;
  43143. /**
  43144. * Add mouse input support to the input manager.
  43145. * @param touchEnabled Enable touch screen support.
  43146. * @returns the new FlyCameraMouseInput().
  43147. */
  43148. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  43149. }
  43150. }
  43151. declare module BABYLON {
  43152. /**
  43153. * This is a flying camera, designed for 3D movement and rotation in all directions,
  43154. * such as in a 3D Space Shooter or a Flight Simulator.
  43155. */
  43156. export class FlyCamera extends TargetCamera {
  43157. /**
  43158. * Define the collision ellipsoid of the camera.
  43159. * This is helpful for simulating a camera body, like a player's body.
  43160. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43161. */
  43162. ellipsoid: Vector3;
  43163. /**
  43164. * Define an offset for the position of the ellipsoid around the camera.
  43165. * This can be helpful if the camera is attached away from the player's body center,
  43166. * such as at its head.
  43167. */
  43168. ellipsoidOffset: Vector3;
  43169. /**
  43170. * Enable or disable collisions of the camera with the rest of the scene objects.
  43171. */
  43172. checkCollisions: boolean;
  43173. /**
  43174. * Enable or disable gravity on the camera.
  43175. */
  43176. applyGravity: boolean;
  43177. /**
  43178. * Define the current direction the camera is moving to.
  43179. */
  43180. cameraDirection: Vector3;
  43181. /**
  43182. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  43183. * This overrides and empties cameraRotation.
  43184. */
  43185. rotationQuaternion: Quaternion;
  43186. /**
  43187. * Track Roll to maintain the wanted Rolling when looking around.
  43188. */
  43189. _trackRoll: number;
  43190. /**
  43191. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  43192. */
  43193. rollCorrect: number;
  43194. /**
  43195. * Mimic a banked turn, Rolling the camera when Yawing.
  43196. * It's recommended to use rollCorrect = 10 for faster banking correction.
  43197. */
  43198. bankedTurn: boolean;
  43199. /**
  43200. * Limit in radians for how much Roll banking will add. (Default: 90°)
  43201. */
  43202. bankedTurnLimit: number;
  43203. /**
  43204. * Value of 0 disables the banked Roll.
  43205. * Value of 1 is equal to the Yaw angle in radians.
  43206. */
  43207. bankedTurnMultiplier: number;
  43208. /**
  43209. * The inputs manager loads all the input sources, such as keyboard and mouse.
  43210. */
  43211. inputs: FlyCameraInputsManager;
  43212. /**
  43213. * Gets the input sensibility for mouse input.
  43214. * Higher values reduce sensitivity.
  43215. */
  43216. get angularSensibility(): number;
  43217. /**
  43218. * Sets the input sensibility for a mouse input.
  43219. * Higher values reduce sensitivity.
  43220. */
  43221. set angularSensibility(value: number);
  43222. /**
  43223. * Get the keys for camera movement forward.
  43224. */
  43225. get keysForward(): number[];
  43226. /**
  43227. * Set the keys for camera movement forward.
  43228. */
  43229. set keysForward(value: number[]);
  43230. /**
  43231. * Get the keys for camera movement backward.
  43232. */
  43233. get keysBackward(): number[];
  43234. set keysBackward(value: number[]);
  43235. /**
  43236. * Get the keys for camera movement up.
  43237. */
  43238. get keysUp(): number[];
  43239. /**
  43240. * Set the keys for camera movement up.
  43241. */
  43242. set keysUp(value: number[]);
  43243. /**
  43244. * Get the keys for camera movement down.
  43245. */
  43246. get keysDown(): number[];
  43247. /**
  43248. * Set the keys for camera movement down.
  43249. */
  43250. set keysDown(value: number[]);
  43251. /**
  43252. * Get the keys for camera movement left.
  43253. */
  43254. get keysLeft(): number[];
  43255. /**
  43256. * Set the keys for camera movement left.
  43257. */
  43258. set keysLeft(value: number[]);
  43259. /**
  43260. * Set the keys for camera movement right.
  43261. */
  43262. get keysRight(): number[];
  43263. /**
  43264. * Set the keys for camera movement right.
  43265. */
  43266. set keysRight(value: number[]);
  43267. /**
  43268. * Event raised when the camera collides with a mesh in the scene.
  43269. */
  43270. onCollide: (collidedMesh: AbstractMesh) => void;
  43271. private _collider;
  43272. private _needMoveForGravity;
  43273. private _oldPosition;
  43274. private _diffPosition;
  43275. private _newPosition;
  43276. /** @hidden */
  43277. _localDirection: Vector3;
  43278. /** @hidden */
  43279. _transformedDirection: Vector3;
  43280. /**
  43281. * Instantiates a FlyCamera.
  43282. * This is a flying camera, designed for 3D movement and rotation in all directions,
  43283. * such as in a 3D Space Shooter or a Flight Simulator.
  43284. * @param name Define the name of the camera in the scene.
  43285. * @param position Define the starting position of the camera in the scene.
  43286. * @param scene Define the scene the camera belongs to.
  43287. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  43288. */
  43289. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43290. /**
  43291. * Attach a control to the HTML DOM element.
  43292. * @param element Defines the element that listens to the input events.
  43293. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  43294. */
  43295. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43296. /**
  43297. * Detach a control from the HTML DOM element.
  43298. * The camera will stop reacting to that input.
  43299. * @param element Defines the element that listens to the input events.
  43300. */
  43301. detachControl(element: HTMLElement): void;
  43302. private _collisionMask;
  43303. /**
  43304. * Get the mask that the camera ignores in collision events.
  43305. */
  43306. get collisionMask(): number;
  43307. /**
  43308. * Set the mask that the camera ignores in collision events.
  43309. */
  43310. set collisionMask(mask: number);
  43311. /** @hidden */
  43312. _collideWithWorld(displacement: Vector3): void;
  43313. /** @hidden */
  43314. private _onCollisionPositionChange;
  43315. /** @hidden */
  43316. _checkInputs(): void;
  43317. /** @hidden */
  43318. _decideIfNeedsToMove(): boolean;
  43319. /** @hidden */
  43320. _updatePosition(): void;
  43321. /**
  43322. * Restore the Roll to its target value at the rate specified.
  43323. * @param rate - Higher means slower restoring.
  43324. * @hidden
  43325. */
  43326. restoreRoll(rate: number): void;
  43327. /**
  43328. * Destroy the camera and release the current resources held by it.
  43329. */
  43330. dispose(): void;
  43331. /**
  43332. * Get the current object class name.
  43333. * @returns the class name.
  43334. */
  43335. getClassName(): string;
  43336. }
  43337. }
  43338. declare module BABYLON {
  43339. /**
  43340. * Listen to keyboard events to control the camera.
  43341. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43342. */
  43343. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  43344. /**
  43345. * Defines the camera the input is attached to.
  43346. */
  43347. camera: FlyCamera;
  43348. /**
  43349. * The list of keyboard keys used to control the forward move of the camera.
  43350. */
  43351. keysForward: number[];
  43352. /**
  43353. * The list of keyboard keys used to control the backward move of the camera.
  43354. */
  43355. keysBackward: number[];
  43356. /**
  43357. * The list of keyboard keys used to control the forward move of the camera.
  43358. */
  43359. keysUp: number[];
  43360. /**
  43361. * The list of keyboard keys used to control the backward move of the camera.
  43362. */
  43363. keysDown: number[];
  43364. /**
  43365. * The list of keyboard keys used to control the right strafe move of the camera.
  43366. */
  43367. keysRight: number[];
  43368. /**
  43369. * The list of keyboard keys used to control the left strafe move of the camera.
  43370. */
  43371. keysLeft: number[];
  43372. private _keys;
  43373. private _onCanvasBlurObserver;
  43374. private _onKeyboardObserver;
  43375. private _engine;
  43376. private _scene;
  43377. /**
  43378. * Attach the input controls to a specific dom element to get the input from.
  43379. * @param element Defines the element the controls should be listened from
  43380. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43381. */
  43382. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43383. /**
  43384. * Detach the current controls from the specified dom element.
  43385. * @param element Defines the element to stop listening the inputs from
  43386. */
  43387. detachControl(element: Nullable<HTMLElement>): void;
  43388. /**
  43389. * Gets the class name of the current intput.
  43390. * @returns the class name
  43391. */
  43392. getClassName(): string;
  43393. /** @hidden */
  43394. _onLostFocus(e: FocusEvent): void;
  43395. /**
  43396. * Get the friendly name associated with the input class.
  43397. * @returns the input friendly name
  43398. */
  43399. getSimpleName(): string;
  43400. /**
  43401. * Update the current camera state depending on the inputs that have been used this frame.
  43402. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43403. */
  43404. checkInputs(): void;
  43405. }
  43406. }
  43407. declare module BABYLON {
  43408. /**
  43409. * Manage the mouse wheel inputs to control a follow camera.
  43410. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43411. */
  43412. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  43413. /**
  43414. * Defines the camera the input is attached to.
  43415. */
  43416. camera: FollowCamera;
  43417. /**
  43418. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  43419. */
  43420. axisControlRadius: boolean;
  43421. /**
  43422. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  43423. */
  43424. axisControlHeight: boolean;
  43425. /**
  43426. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  43427. */
  43428. axisControlRotation: boolean;
  43429. /**
  43430. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  43431. * relation to mouseWheel events.
  43432. */
  43433. wheelPrecision: number;
  43434. /**
  43435. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  43436. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  43437. */
  43438. wheelDeltaPercentage: number;
  43439. private _wheel;
  43440. private _observer;
  43441. /**
  43442. * Attach the input controls to a specific dom element to get the input from.
  43443. * @param element Defines the element the controls should be listened from
  43444. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43445. */
  43446. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43447. /**
  43448. * Detach the current controls from the specified dom element.
  43449. * @param element Defines the element to stop listening the inputs from
  43450. */
  43451. detachControl(element: Nullable<HTMLElement>): void;
  43452. /**
  43453. * Gets the class name of the current intput.
  43454. * @returns the class name
  43455. */
  43456. getClassName(): string;
  43457. /**
  43458. * Get the friendly name associated with the input class.
  43459. * @returns the input friendly name
  43460. */
  43461. getSimpleName(): string;
  43462. }
  43463. }
  43464. declare module BABYLON {
  43465. /**
  43466. * Manage the pointers inputs to control an follow camera.
  43467. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43468. */
  43469. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  43470. /**
  43471. * Defines the camera the input is attached to.
  43472. */
  43473. camera: FollowCamera;
  43474. /**
  43475. * Gets the class name of the current input.
  43476. * @returns the class name
  43477. */
  43478. getClassName(): string;
  43479. /**
  43480. * Defines the pointer angular sensibility along the X axis or how fast is
  43481. * the camera rotating.
  43482. * A negative number will reverse the axis direction.
  43483. */
  43484. angularSensibilityX: number;
  43485. /**
  43486. * Defines the pointer angular sensibility along the Y axis or how fast is
  43487. * the camera rotating.
  43488. * A negative number will reverse the axis direction.
  43489. */
  43490. angularSensibilityY: number;
  43491. /**
  43492. * Defines the pointer pinch precision or how fast is the camera zooming.
  43493. * A negative number will reverse the axis direction.
  43494. */
  43495. pinchPrecision: number;
  43496. /**
  43497. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  43498. * from 0.
  43499. * It defines the percentage of current camera.radius to use as delta when
  43500. * pinch zoom is used.
  43501. */
  43502. pinchDeltaPercentage: number;
  43503. /**
  43504. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  43505. */
  43506. axisXControlRadius: boolean;
  43507. /**
  43508. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  43509. */
  43510. axisXControlHeight: boolean;
  43511. /**
  43512. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  43513. */
  43514. axisXControlRotation: boolean;
  43515. /**
  43516. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  43517. */
  43518. axisYControlRadius: boolean;
  43519. /**
  43520. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  43521. */
  43522. axisYControlHeight: boolean;
  43523. /**
  43524. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  43525. */
  43526. axisYControlRotation: boolean;
  43527. /**
  43528. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  43529. */
  43530. axisPinchControlRadius: boolean;
  43531. /**
  43532. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  43533. */
  43534. axisPinchControlHeight: boolean;
  43535. /**
  43536. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  43537. */
  43538. axisPinchControlRotation: boolean;
  43539. /**
  43540. * Log error messages if basic misconfiguration has occurred.
  43541. */
  43542. warningEnable: boolean;
  43543. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43544. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43545. private _warningCounter;
  43546. private _warning;
  43547. }
  43548. }
  43549. declare module BABYLON {
  43550. /**
  43551. * Default Inputs manager for the FollowCamera.
  43552. * It groups all the default supported inputs for ease of use.
  43553. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43554. */
  43555. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  43556. /**
  43557. * Instantiates a new FollowCameraInputsManager.
  43558. * @param camera Defines the camera the inputs belong to
  43559. */
  43560. constructor(camera: FollowCamera);
  43561. /**
  43562. * Add keyboard input support to the input manager.
  43563. * @returns the current input manager
  43564. */
  43565. addKeyboard(): FollowCameraInputsManager;
  43566. /**
  43567. * Add mouse wheel input support to the input manager.
  43568. * @returns the current input manager
  43569. */
  43570. addMouseWheel(): FollowCameraInputsManager;
  43571. /**
  43572. * Add pointers input support to the input manager.
  43573. * @returns the current input manager
  43574. */
  43575. addPointers(): FollowCameraInputsManager;
  43576. /**
  43577. * Add orientation input support to the input manager.
  43578. * @returns the current input manager
  43579. */
  43580. addVRDeviceOrientation(): FollowCameraInputsManager;
  43581. }
  43582. }
  43583. declare module BABYLON {
  43584. /**
  43585. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  43586. * an arc rotate version arcFollowCamera are available.
  43587. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43588. */
  43589. export class FollowCamera extends TargetCamera {
  43590. /**
  43591. * Distance the follow camera should follow an object at
  43592. */
  43593. radius: number;
  43594. /**
  43595. * Minimum allowed distance of the camera to the axis of rotation
  43596. * (The camera can not get closer).
  43597. * This can help limiting how the Camera is able to move in the scene.
  43598. */
  43599. lowerRadiusLimit: Nullable<number>;
  43600. /**
  43601. * Maximum allowed distance of the camera to the axis of rotation
  43602. * (The camera can not get further).
  43603. * This can help limiting how the Camera is able to move in the scene.
  43604. */
  43605. upperRadiusLimit: Nullable<number>;
  43606. /**
  43607. * Define a rotation offset between the camera and the object it follows
  43608. */
  43609. rotationOffset: number;
  43610. /**
  43611. * Minimum allowed angle to camera position relative to target object.
  43612. * This can help limiting how the Camera is able to move in the scene.
  43613. */
  43614. lowerRotationOffsetLimit: Nullable<number>;
  43615. /**
  43616. * Maximum allowed angle to camera position relative to target object.
  43617. * This can help limiting how the Camera is able to move in the scene.
  43618. */
  43619. upperRotationOffsetLimit: Nullable<number>;
  43620. /**
  43621. * Define a height offset between the camera and the object it follows.
  43622. * It can help following an object from the top (like a car chaing a plane)
  43623. */
  43624. heightOffset: number;
  43625. /**
  43626. * Minimum allowed height of camera position relative to target object.
  43627. * This can help limiting how the Camera is able to move in the scene.
  43628. */
  43629. lowerHeightOffsetLimit: Nullable<number>;
  43630. /**
  43631. * Maximum allowed height of camera position relative to target object.
  43632. * This can help limiting how the Camera is able to move in the scene.
  43633. */
  43634. upperHeightOffsetLimit: Nullable<number>;
  43635. /**
  43636. * Define how fast the camera can accelerate to follow it s target.
  43637. */
  43638. cameraAcceleration: number;
  43639. /**
  43640. * Define the speed limit of the camera following an object.
  43641. */
  43642. maxCameraSpeed: number;
  43643. /**
  43644. * Define the target of the camera.
  43645. */
  43646. lockedTarget: Nullable<AbstractMesh>;
  43647. /**
  43648. * Defines the input associated with the camera.
  43649. */
  43650. inputs: FollowCameraInputsManager;
  43651. /**
  43652. * Instantiates the follow camera.
  43653. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43654. * @param name Define the name of the camera in the scene
  43655. * @param position Define the position of the camera
  43656. * @param scene Define the scene the camera belong to
  43657. * @param lockedTarget Define the target of the camera
  43658. */
  43659. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  43660. private _follow;
  43661. /**
  43662. * Attached controls to the current camera.
  43663. * @param element Defines the element the controls should be listened from
  43664. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43665. */
  43666. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43667. /**
  43668. * Detach the current controls from the camera.
  43669. * The camera will stop reacting to inputs.
  43670. * @param element Defines the element to stop listening the inputs from
  43671. */
  43672. detachControl(element: HTMLElement): void;
  43673. /** @hidden */
  43674. _checkInputs(): void;
  43675. private _checkLimits;
  43676. /**
  43677. * Gets the camera class name.
  43678. * @returns the class name
  43679. */
  43680. getClassName(): string;
  43681. }
  43682. /**
  43683. * Arc Rotate version of the follow camera.
  43684. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  43685. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43686. */
  43687. export class ArcFollowCamera extends TargetCamera {
  43688. /** The longitudinal angle of the camera */
  43689. alpha: number;
  43690. /** The latitudinal angle of the camera */
  43691. beta: number;
  43692. /** The radius of the camera from its target */
  43693. radius: number;
  43694. /** Define the camera target (the mesh it should follow) */
  43695. target: Nullable<AbstractMesh>;
  43696. private _cartesianCoordinates;
  43697. /**
  43698. * Instantiates a new ArcFollowCamera
  43699. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43700. * @param name Define the name of the camera
  43701. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  43702. * @param beta Define the rotation angle of the camera around the elevation axis
  43703. * @param radius Define the radius of the camera from its target point
  43704. * @param target Define the target of the camera
  43705. * @param scene Define the scene the camera belongs to
  43706. */
  43707. constructor(name: string,
  43708. /** The longitudinal angle of the camera */
  43709. alpha: number,
  43710. /** The latitudinal angle of the camera */
  43711. beta: number,
  43712. /** The radius of the camera from its target */
  43713. radius: number,
  43714. /** Define the camera target (the mesh it should follow) */
  43715. target: Nullable<AbstractMesh>, scene: Scene);
  43716. private _follow;
  43717. /** @hidden */
  43718. _checkInputs(): void;
  43719. /**
  43720. * Returns the class name of the object.
  43721. * It is mostly used internally for serialization purposes.
  43722. */
  43723. getClassName(): string;
  43724. }
  43725. }
  43726. declare module BABYLON {
  43727. /**
  43728. * Manage the keyboard inputs to control the movement of a follow camera.
  43729. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43730. */
  43731. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  43732. /**
  43733. * Defines the camera the input is attached to.
  43734. */
  43735. camera: FollowCamera;
  43736. /**
  43737. * Defines the list of key codes associated with the up action (increase heightOffset)
  43738. */
  43739. keysHeightOffsetIncr: number[];
  43740. /**
  43741. * Defines the list of key codes associated with the down action (decrease heightOffset)
  43742. */
  43743. keysHeightOffsetDecr: number[];
  43744. /**
  43745. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  43746. */
  43747. keysHeightOffsetModifierAlt: boolean;
  43748. /**
  43749. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  43750. */
  43751. keysHeightOffsetModifierCtrl: boolean;
  43752. /**
  43753. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  43754. */
  43755. keysHeightOffsetModifierShift: boolean;
  43756. /**
  43757. * Defines the list of key codes associated with the left action (increase rotationOffset)
  43758. */
  43759. keysRotationOffsetIncr: number[];
  43760. /**
  43761. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  43762. */
  43763. keysRotationOffsetDecr: number[];
  43764. /**
  43765. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  43766. */
  43767. keysRotationOffsetModifierAlt: boolean;
  43768. /**
  43769. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  43770. */
  43771. keysRotationOffsetModifierCtrl: boolean;
  43772. /**
  43773. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  43774. */
  43775. keysRotationOffsetModifierShift: boolean;
  43776. /**
  43777. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  43778. */
  43779. keysRadiusIncr: number[];
  43780. /**
  43781. * Defines the list of key codes associated with the zoom-out action (increase radius)
  43782. */
  43783. keysRadiusDecr: number[];
  43784. /**
  43785. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  43786. */
  43787. keysRadiusModifierAlt: boolean;
  43788. /**
  43789. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  43790. */
  43791. keysRadiusModifierCtrl: boolean;
  43792. /**
  43793. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  43794. */
  43795. keysRadiusModifierShift: boolean;
  43796. /**
  43797. * Defines the rate of change of heightOffset.
  43798. */
  43799. heightSensibility: number;
  43800. /**
  43801. * Defines the rate of change of rotationOffset.
  43802. */
  43803. rotationSensibility: number;
  43804. /**
  43805. * Defines the rate of change of radius.
  43806. */
  43807. radiusSensibility: number;
  43808. private _keys;
  43809. private _ctrlPressed;
  43810. private _altPressed;
  43811. private _shiftPressed;
  43812. private _onCanvasBlurObserver;
  43813. private _onKeyboardObserver;
  43814. private _engine;
  43815. private _scene;
  43816. /**
  43817. * Attach the input controls to a specific dom element to get the input from.
  43818. * @param element Defines the element the controls should be listened from
  43819. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43820. */
  43821. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43822. /**
  43823. * Detach the current controls from the specified dom element.
  43824. * @param element Defines the element to stop listening the inputs from
  43825. */
  43826. detachControl(element: Nullable<HTMLElement>): void;
  43827. /**
  43828. * Update the current camera state depending on the inputs that have been used this frame.
  43829. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43830. */
  43831. checkInputs(): void;
  43832. /**
  43833. * Gets the class name of the current input.
  43834. * @returns the class name
  43835. */
  43836. getClassName(): string;
  43837. /**
  43838. * Get the friendly name associated with the input class.
  43839. * @returns the input friendly name
  43840. */
  43841. getSimpleName(): string;
  43842. /**
  43843. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43844. * allow modification of the heightOffset value.
  43845. */
  43846. private _modifierHeightOffset;
  43847. /**
  43848. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43849. * allow modification of the rotationOffset value.
  43850. */
  43851. private _modifierRotationOffset;
  43852. /**
  43853. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43854. * allow modification of the radius value.
  43855. */
  43856. private _modifierRadius;
  43857. }
  43858. }
  43859. declare module BABYLON {
  43860. interface FreeCameraInputsManager {
  43861. /**
  43862. * @hidden
  43863. */
  43864. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  43865. /**
  43866. * Add orientation input support to the input manager.
  43867. * @returns the current input manager
  43868. */
  43869. addDeviceOrientation(): FreeCameraInputsManager;
  43870. }
  43871. /**
  43872. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  43873. * Screen rotation is taken into account.
  43874. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43875. */
  43876. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  43877. private _camera;
  43878. private _screenOrientationAngle;
  43879. private _constantTranform;
  43880. private _screenQuaternion;
  43881. private _alpha;
  43882. private _beta;
  43883. private _gamma;
  43884. /**
  43885. * Can be used to detect if a device orientation sensor is available on a device
  43886. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  43887. * @returns a promise that will resolve on orientation change
  43888. */
  43889. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  43890. /**
  43891. * @hidden
  43892. */
  43893. _onDeviceOrientationChangedObservable: Observable<void>;
  43894. /**
  43895. * Instantiates a new input
  43896. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43897. */
  43898. constructor();
  43899. /**
  43900. * Define the camera controlled by the input.
  43901. */
  43902. get camera(): FreeCamera;
  43903. set camera(camera: FreeCamera);
  43904. /**
  43905. * Attach the input controls to a specific dom element to get the input from.
  43906. * @param element Defines the element the controls should be listened from
  43907. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43908. */
  43909. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43910. private _orientationChanged;
  43911. private _deviceOrientation;
  43912. /**
  43913. * Detach the current controls from the specified dom element.
  43914. * @param element Defines the element to stop listening the inputs from
  43915. */
  43916. detachControl(element: Nullable<HTMLElement>): void;
  43917. /**
  43918. * Update the current camera state depending on the inputs that have been used this frame.
  43919. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43920. */
  43921. checkInputs(): void;
  43922. /**
  43923. * Gets the class name of the current intput.
  43924. * @returns the class name
  43925. */
  43926. getClassName(): string;
  43927. /**
  43928. * Get the friendly name associated with the input class.
  43929. * @returns the input friendly name
  43930. */
  43931. getSimpleName(): string;
  43932. }
  43933. }
  43934. declare module BABYLON {
  43935. /**
  43936. * Manage the gamepad inputs to control a free camera.
  43937. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43938. */
  43939. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  43940. /**
  43941. * Define the camera the input is attached to.
  43942. */
  43943. camera: FreeCamera;
  43944. /**
  43945. * Define the Gamepad controlling the input
  43946. */
  43947. gamepad: Nullable<Gamepad>;
  43948. /**
  43949. * Defines the gamepad rotation sensiblity.
  43950. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43951. */
  43952. gamepadAngularSensibility: number;
  43953. /**
  43954. * Defines the gamepad move sensiblity.
  43955. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43956. */
  43957. gamepadMoveSensibility: number;
  43958. private _yAxisScale;
  43959. /**
  43960. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  43961. */
  43962. get invertYAxis(): boolean;
  43963. set invertYAxis(value: boolean);
  43964. private _onGamepadConnectedObserver;
  43965. private _onGamepadDisconnectedObserver;
  43966. private _cameraTransform;
  43967. private _deltaTransform;
  43968. private _vector3;
  43969. private _vector2;
  43970. /**
  43971. * Attach the input controls to a specific dom element to get the input from.
  43972. * @param element Defines the element the controls should be listened from
  43973. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43974. */
  43975. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43976. /**
  43977. * Detach the current controls from the specified dom element.
  43978. * @param element Defines the element to stop listening the inputs from
  43979. */
  43980. detachControl(element: Nullable<HTMLElement>): void;
  43981. /**
  43982. * Update the current camera state depending on the inputs that have been used this frame.
  43983. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43984. */
  43985. checkInputs(): void;
  43986. /**
  43987. * Gets the class name of the current intput.
  43988. * @returns the class name
  43989. */
  43990. getClassName(): string;
  43991. /**
  43992. * Get the friendly name associated with the input class.
  43993. * @returns the input friendly name
  43994. */
  43995. getSimpleName(): string;
  43996. }
  43997. }
  43998. declare module BABYLON {
  43999. /**
  44000. * Defines the potential axis of a Joystick
  44001. */
  44002. export enum JoystickAxis {
  44003. /** X axis */
  44004. X = 0,
  44005. /** Y axis */
  44006. Y = 1,
  44007. /** Z axis */
  44008. Z = 2
  44009. }
  44010. /**
  44011. * Class used to define virtual joystick (used in touch mode)
  44012. */
  44013. export class VirtualJoystick {
  44014. /**
  44015. * Gets or sets a boolean indicating that left and right values must be inverted
  44016. */
  44017. reverseLeftRight: boolean;
  44018. /**
  44019. * Gets or sets a boolean indicating that up and down values must be inverted
  44020. */
  44021. reverseUpDown: boolean;
  44022. /**
  44023. * Gets the offset value for the position (ie. the change of the position value)
  44024. */
  44025. deltaPosition: Vector3;
  44026. /**
  44027. * Gets a boolean indicating if the virtual joystick was pressed
  44028. */
  44029. pressed: boolean;
  44030. /**
  44031. * Canvas the virtual joystick will render onto, default z-index of this is 5
  44032. */
  44033. static Canvas: Nullable<HTMLCanvasElement>;
  44034. private static _globalJoystickIndex;
  44035. private static vjCanvasContext;
  44036. private static vjCanvasWidth;
  44037. private static vjCanvasHeight;
  44038. private static halfWidth;
  44039. private _action;
  44040. private _axisTargetedByLeftAndRight;
  44041. private _axisTargetedByUpAndDown;
  44042. private _joystickSensibility;
  44043. private _inversedSensibility;
  44044. private _joystickPointerID;
  44045. private _joystickColor;
  44046. private _joystickPointerPos;
  44047. private _joystickPreviousPointerPos;
  44048. private _joystickPointerStartPos;
  44049. private _deltaJoystickVector;
  44050. private _leftJoystick;
  44051. private _touches;
  44052. private _onPointerDownHandlerRef;
  44053. private _onPointerMoveHandlerRef;
  44054. private _onPointerUpHandlerRef;
  44055. private _onResize;
  44056. /**
  44057. * Creates a new virtual joystick
  44058. * @param leftJoystick defines that the joystick is for left hand (false by default)
  44059. */
  44060. constructor(leftJoystick?: boolean);
  44061. /**
  44062. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  44063. * @param newJoystickSensibility defines the new sensibility
  44064. */
  44065. setJoystickSensibility(newJoystickSensibility: number): void;
  44066. private _onPointerDown;
  44067. private _onPointerMove;
  44068. private _onPointerUp;
  44069. /**
  44070. * Change the color of the virtual joystick
  44071. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  44072. */
  44073. setJoystickColor(newColor: string): void;
  44074. /**
  44075. * Defines a callback to call when the joystick is touched
  44076. * @param action defines the callback
  44077. */
  44078. setActionOnTouch(action: () => any): void;
  44079. /**
  44080. * Defines which axis you'd like to control for left & right
  44081. * @param axis defines the axis to use
  44082. */
  44083. setAxisForLeftRight(axis: JoystickAxis): void;
  44084. /**
  44085. * Defines which axis you'd like to control for up & down
  44086. * @param axis defines the axis to use
  44087. */
  44088. setAxisForUpDown(axis: JoystickAxis): void;
  44089. private _drawVirtualJoystick;
  44090. /**
  44091. * Release internal HTML canvas
  44092. */
  44093. releaseCanvas(): void;
  44094. }
  44095. }
  44096. declare module BABYLON {
  44097. interface FreeCameraInputsManager {
  44098. /**
  44099. * Add virtual joystick input support to the input manager.
  44100. * @returns the current input manager
  44101. */
  44102. addVirtualJoystick(): FreeCameraInputsManager;
  44103. }
  44104. /**
  44105. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  44106. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44107. */
  44108. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  44109. /**
  44110. * Defines the camera the input is attached to.
  44111. */
  44112. camera: FreeCamera;
  44113. private _leftjoystick;
  44114. private _rightjoystick;
  44115. /**
  44116. * Gets the left stick of the virtual joystick.
  44117. * @returns The virtual Joystick
  44118. */
  44119. getLeftJoystick(): VirtualJoystick;
  44120. /**
  44121. * Gets the right stick of the virtual joystick.
  44122. * @returns The virtual Joystick
  44123. */
  44124. getRightJoystick(): VirtualJoystick;
  44125. /**
  44126. * Update the current camera state depending on the inputs that have been used this frame.
  44127. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44128. */
  44129. checkInputs(): void;
  44130. /**
  44131. * Attach the input controls to a specific dom element to get the input from.
  44132. * @param element Defines the element the controls should be listened from
  44133. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44134. */
  44135. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44136. /**
  44137. * Detach the current controls from the specified dom element.
  44138. * @param element Defines the element to stop listening the inputs from
  44139. */
  44140. detachControl(element: Nullable<HTMLElement>): void;
  44141. /**
  44142. * Gets the class name of the current intput.
  44143. * @returns the class name
  44144. */
  44145. getClassName(): string;
  44146. /**
  44147. * Get the friendly name associated with the input class.
  44148. * @returns the input friendly name
  44149. */
  44150. getSimpleName(): string;
  44151. }
  44152. }
  44153. declare module BABYLON {
  44154. /**
  44155. * This represents a FPS type of camera controlled by touch.
  44156. * This is like a universal camera minus the Gamepad controls.
  44157. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44158. */
  44159. export class TouchCamera extends FreeCamera {
  44160. /**
  44161. * Defines the touch sensibility for rotation.
  44162. * The higher the faster.
  44163. */
  44164. get touchAngularSensibility(): number;
  44165. set touchAngularSensibility(value: number);
  44166. /**
  44167. * Defines the touch sensibility for move.
  44168. * The higher the faster.
  44169. */
  44170. get touchMoveSensibility(): number;
  44171. set touchMoveSensibility(value: number);
  44172. /**
  44173. * Instantiates a new touch camera.
  44174. * This represents a FPS type of camera controlled by touch.
  44175. * This is like a universal camera minus the Gamepad controls.
  44176. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44177. * @param name Define the name of the camera in the scene
  44178. * @param position Define the start position of the camera in the scene
  44179. * @param scene Define the scene the camera belongs to
  44180. */
  44181. constructor(name: string, position: Vector3, scene: Scene);
  44182. /**
  44183. * Gets the current object class name.
  44184. * @return the class name
  44185. */
  44186. getClassName(): string;
  44187. /** @hidden */
  44188. _setupInputs(): void;
  44189. }
  44190. }
  44191. declare module BABYLON {
  44192. /**
  44193. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  44194. * being tilted forward or back and left or right.
  44195. */
  44196. export class DeviceOrientationCamera extends FreeCamera {
  44197. private _initialQuaternion;
  44198. private _quaternionCache;
  44199. private _tmpDragQuaternion;
  44200. private _disablePointerInputWhenUsingDeviceOrientation;
  44201. /**
  44202. * Creates a new device orientation camera
  44203. * @param name The name of the camera
  44204. * @param position The start position camera
  44205. * @param scene The scene the camera belongs to
  44206. */
  44207. constructor(name: string, position: Vector3, scene: Scene);
  44208. /**
  44209. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  44210. */
  44211. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  44212. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  44213. private _dragFactor;
  44214. /**
  44215. * Enabled turning on the y axis when the orientation sensor is active
  44216. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  44217. */
  44218. enableHorizontalDragging(dragFactor?: number): void;
  44219. /**
  44220. * Gets the current instance class name ("DeviceOrientationCamera").
  44221. * This helps avoiding instanceof at run time.
  44222. * @returns the class name
  44223. */
  44224. getClassName(): string;
  44225. /**
  44226. * @hidden
  44227. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  44228. */
  44229. _checkInputs(): void;
  44230. /**
  44231. * Reset the camera to its default orientation on the specified axis only.
  44232. * @param axis The axis to reset
  44233. */
  44234. resetToCurrentRotation(axis?: Axis): void;
  44235. }
  44236. }
  44237. declare module BABYLON {
  44238. /**
  44239. * Defines supported buttons for XBox360 compatible gamepads
  44240. */
  44241. export enum Xbox360Button {
  44242. /** A */
  44243. A = 0,
  44244. /** B */
  44245. B = 1,
  44246. /** X */
  44247. X = 2,
  44248. /** Y */
  44249. Y = 3,
  44250. /** Left button */
  44251. LB = 4,
  44252. /** Right button */
  44253. RB = 5,
  44254. /** Back */
  44255. Back = 8,
  44256. /** Start */
  44257. Start = 9,
  44258. /** Left stick */
  44259. LeftStick = 10,
  44260. /** Right stick */
  44261. RightStick = 11
  44262. }
  44263. /** Defines values for XBox360 DPad */
  44264. export enum Xbox360Dpad {
  44265. /** Up */
  44266. Up = 12,
  44267. /** Down */
  44268. Down = 13,
  44269. /** Left */
  44270. Left = 14,
  44271. /** Right */
  44272. Right = 15
  44273. }
  44274. /**
  44275. * Defines a XBox360 gamepad
  44276. */
  44277. export class Xbox360Pad extends Gamepad {
  44278. private _leftTrigger;
  44279. private _rightTrigger;
  44280. private _onlefttriggerchanged;
  44281. private _onrighttriggerchanged;
  44282. private _onbuttondown;
  44283. private _onbuttonup;
  44284. private _ondpaddown;
  44285. private _ondpadup;
  44286. /** Observable raised when a button is pressed */
  44287. onButtonDownObservable: Observable<Xbox360Button>;
  44288. /** Observable raised when a button is released */
  44289. onButtonUpObservable: Observable<Xbox360Button>;
  44290. /** Observable raised when a pad is pressed */
  44291. onPadDownObservable: Observable<Xbox360Dpad>;
  44292. /** Observable raised when a pad is released */
  44293. onPadUpObservable: Observable<Xbox360Dpad>;
  44294. private _buttonA;
  44295. private _buttonB;
  44296. private _buttonX;
  44297. private _buttonY;
  44298. private _buttonBack;
  44299. private _buttonStart;
  44300. private _buttonLB;
  44301. private _buttonRB;
  44302. private _buttonLeftStick;
  44303. private _buttonRightStick;
  44304. private _dPadUp;
  44305. private _dPadDown;
  44306. private _dPadLeft;
  44307. private _dPadRight;
  44308. private _isXboxOnePad;
  44309. /**
  44310. * Creates a new XBox360 gamepad object
  44311. * @param id defines the id of this gamepad
  44312. * @param index defines its index
  44313. * @param gamepad defines the internal HTML gamepad object
  44314. * @param xboxOne defines if it is a XBox One gamepad
  44315. */
  44316. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  44317. /**
  44318. * Defines the callback to call when left trigger is pressed
  44319. * @param callback defines the callback to use
  44320. */
  44321. onlefttriggerchanged(callback: (value: number) => void): void;
  44322. /**
  44323. * Defines the callback to call when right trigger is pressed
  44324. * @param callback defines the callback to use
  44325. */
  44326. onrighttriggerchanged(callback: (value: number) => void): void;
  44327. /**
  44328. * Gets the left trigger value
  44329. */
  44330. get leftTrigger(): number;
  44331. /**
  44332. * Sets the left trigger value
  44333. */
  44334. set leftTrigger(newValue: number);
  44335. /**
  44336. * Gets the right trigger value
  44337. */
  44338. get rightTrigger(): number;
  44339. /**
  44340. * Sets the right trigger value
  44341. */
  44342. set rightTrigger(newValue: number);
  44343. /**
  44344. * Defines the callback to call when a button is pressed
  44345. * @param callback defines the callback to use
  44346. */
  44347. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  44348. /**
  44349. * Defines the callback to call when a button is released
  44350. * @param callback defines the callback to use
  44351. */
  44352. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  44353. /**
  44354. * Defines the callback to call when a pad is pressed
  44355. * @param callback defines the callback to use
  44356. */
  44357. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  44358. /**
  44359. * Defines the callback to call when a pad is released
  44360. * @param callback defines the callback to use
  44361. */
  44362. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  44363. private _setButtonValue;
  44364. private _setDPadValue;
  44365. /**
  44366. * Gets the value of the `A` button
  44367. */
  44368. get buttonA(): number;
  44369. /**
  44370. * Sets the value of the `A` button
  44371. */
  44372. set buttonA(value: number);
  44373. /**
  44374. * Gets the value of the `B` button
  44375. */
  44376. get buttonB(): number;
  44377. /**
  44378. * Sets the value of the `B` button
  44379. */
  44380. set buttonB(value: number);
  44381. /**
  44382. * Gets the value of the `X` button
  44383. */
  44384. get buttonX(): number;
  44385. /**
  44386. * Sets the value of the `X` button
  44387. */
  44388. set buttonX(value: number);
  44389. /**
  44390. * Gets the value of the `Y` button
  44391. */
  44392. get buttonY(): number;
  44393. /**
  44394. * Sets the value of the `Y` button
  44395. */
  44396. set buttonY(value: number);
  44397. /**
  44398. * Gets the value of the `Start` button
  44399. */
  44400. get buttonStart(): number;
  44401. /**
  44402. * Sets the value of the `Start` button
  44403. */
  44404. set buttonStart(value: number);
  44405. /**
  44406. * Gets the value of the `Back` button
  44407. */
  44408. get buttonBack(): number;
  44409. /**
  44410. * Sets the value of the `Back` button
  44411. */
  44412. set buttonBack(value: number);
  44413. /**
  44414. * Gets the value of the `Left` button
  44415. */
  44416. get buttonLB(): number;
  44417. /**
  44418. * Sets the value of the `Left` button
  44419. */
  44420. set buttonLB(value: number);
  44421. /**
  44422. * Gets the value of the `Right` button
  44423. */
  44424. get buttonRB(): number;
  44425. /**
  44426. * Sets the value of the `Right` button
  44427. */
  44428. set buttonRB(value: number);
  44429. /**
  44430. * Gets the value of the Left joystick
  44431. */
  44432. get buttonLeftStick(): number;
  44433. /**
  44434. * Sets the value of the Left joystick
  44435. */
  44436. set buttonLeftStick(value: number);
  44437. /**
  44438. * Gets the value of the Right joystick
  44439. */
  44440. get buttonRightStick(): number;
  44441. /**
  44442. * Sets the value of the Right joystick
  44443. */
  44444. set buttonRightStick(value: number);
  44445. /**
  44446. * Gets the value of D-pad up
  44447. */
  44448. get dPadUp(): number;
  44449. /**
  44450. * Sets the value of D-pad up
  44451. */
  44452. set dPadUp(value: number);
  44453. /**
  44454. * Gets the value of D-pad down
  44455. */
  44456. get dPadDown(): number;
  44457. /**
  44458. * Sets the value of D-pad down
  44459. */
  44460. set dPadDown(value: number);
  44461. /**
  44462. * Gets the value of D-pad left
  44463. */
  44464. get dPadLeft(): number;
  44465. /**
  44466. * Sets the value of D-pad left
  44467. */
  44468. set dPadLeft(value: number);
  44469. /**
  44470. * Gets the value of D-pad right
  44471. */
  44472. get dPadRight(): number;
  44473. /**
  44474. * Sets the value of D-pad right
  44475. */
  44476. set dPadRight(value: number);
  44477. /**
  44478. * Force the gamepad to synchronize with device values
  44479. */
  44480. update(): void;
  44481. /**
  44482. * Disposes the gamepad
  44483. */
  44484. dispose(): void;
  44485. }
  44486. }
  44487. declare module BABYLON {
  44488. /**
  44489. * Defines supported buttons for DualShock compatible gamepads
  44490. */
  44491. export enum DualShockButton {
  44492. /** Cross */
  44493. Cross = 0,
  44494. /** Circle */
  44495. Circle = 1,
  44496. /** Square */
  44497. Square = 2,
  44498. /** Triangle */
  44499. Triangle = 3,
  44500. /** L1 */
  44501. L1 = 4,
  44502. /** R1 */
  44503. R1 = 5,
  44504. /** Share */
  44505. Share = 8,
  44506. /** Options */
  44507. Options = 9,
  44508. /** Left stick */
  44509. LeftStick = 10,
  44510. /** Right stick */
  44511. RightStick = 11
  44512. }
  44513. /** Defines values for DualShock DPad */
  44514. export enum DualShockDpad {
  44515. /** Up */
  44516. Up = 12,
  44517. /** Down */
  44518. Down = 13,
  44519. /** Left */
  44520. Left = 14,
  44521. /** Right */
  44522. Right = 15
  44523. }
  44524. /**
  44525. * Defines a DualShock gamepad
  44526. */
  44527. export class DualShockPad extends Gamepad {
  44528. private _leftTrigger;
  44529. private _rightTrigger;
  44530. private _onlefttriggerchanged;
  44531. private _onrighttriggerchanged;
  44532. private _onbuttondown;
  44533. private _onbuttonup;
  44534. private _ondpaddown;
  44535. private _ondpadup;
  44536. /** Observable raised when a button is pressed */
  44537. onButtonDownObservable: Observable<DualShockButton>;
  44538. /** Observable raised when a button is released */
  44539. onButtonUpObservable: Observable<DualShockButton>;
  44540. /** Observable raised when a pad is pressed */
  44541. onPadDownObservable: Observable<DualShockDpad>;
  44542. /** Observable raised when a pad is released */
  44543. onPadUpObservable: Observable<DualShockDpad>;
  44544. private _buttonCross;
  44545. private _buttonCircle;
  44546. private _buttonSquare;
  44547. private _buttonTriangle;
  44548. private _buttonShare;
  44549. private _buttonOptions;
  44550. private _buttonL1;
  44551. private _buttonR1;
  44552. private _buttonLeftStick;
  44553. private _buttonRightStick;
  44554. private _dPadUp;
  44555. private _dPadDown;
  44556. private _dPadLeft;
  44557. private _dPadRight;
  44558. /**
  44559. * Creates a new DualShock gamepad object
  44560. * @param id defines the id of this gamepad
  44561. * @param index defines its index
  44562. * @param gamepad defines the internal HTML gamepad object
  44563. */
  44564. constructor(id: string, index: number, gamepad: any);
  44565. /**
  44566. * Defines the callback to call when left trigger is pressed
  44567. * @param callback defines the callback to use
  44568. */
  44569. onlefttriggerchanged(callback: (value: number) => void): void;
  44570. /**
  44571. * Defines the callback to call when right trigger is pressed
  44572. * @param callback defines the callback to use
  44573. */
  44574. onrighttriggerchanged(callback: (value: number) => void): void;
  44575. /**
  44576. * Gets the left trigger value
  44577. */
  44578. get leftTrigger(): number;
  44579. /**
  44580. * Sets the left trigger value
  44581. */
  44582. set leftTrigger(newValue: number);
  44583. /**
  44584. * Gets the right trigger value
  44585. */
  44586. get rightTrigger(): number;
  44587. /**
  44588. * Sets the right trigger value
  44589. */
  44590. set rightTrigger(newValue: number);
  44591. /**
  44592. * Defines the callback to call when a button is pressed
  44593. * @param callback defines the callback to use
  44594. */
  44595. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  44596. /**
  44597. * Defines the callback to call when a button is released
  44598. * @param callback defines the callback to use
  44599. */
  44600. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  44601. /**
  44602. * Defines the callback to call when a pad is pressed
  44603. * @param callback defines the callback to use
  44604. */
  44605. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  44606. /**
  44607. * Defines the callback to call when a pad is released
  44608. * @param callback defines the callback to use
  44609. */
  44610. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  44611. private _setButtonValue;
  44612. private _setDPadValue;
  44613. /**
  44614. * Gets the value of the `Cross` button
  44615. */
  44616. get buttonCross(): number;
  44617. /**
  44618. * Sets the value of the `Cross` button
  44619. */
  44620. set buttonCross(value: number);
  44621. /**
  44622. * Gets the value of the `Circle` button
  44623. */
  44624. get buttonCircle(): number;
  44625. /**
  44626. * Sets the value of the `Circle` button
  44627. */
  44628. set buttonCircle(value: number);
  44629. /**
  44630. * Gets the value of the `Square` button
  44631. */
  44632. get buttonSquare(): number;
  44633. /**
  44634. * Sets the value of the `Square` button
  44635. */
  44636. set buttonSquare(value: number);
  44637. /**
  44638. * Gets the value of the `Triangle` button
  44639. */
  44640. get buttonTriangle(): number;
  44641. /**
  44642. * Sets the value of the `Triangle` button
  44643. */
  44644. set buttonTriangle(value: number);
  44645. /**
  44646. * Gets the value of the `Options` button
  44647. */
  44648. get buttonOptions(): number;
  44649. /**
  44650. * Sets the value of the `Options` button
  44651. */
  44652. set buttonOptions(value: number);
  44653. /**
  44654. * Gets the value of the `Share` button
  44655. */
  44656. get buttonShare(): number;
  44657. /**
  44658. * Sets the value of the `Share` button
  44659. */
  44660. set buttonShare(value: number);
  44661. /**
  44662. * Gets the value of the `L1` button
  44663. */
  44664. get buttonL1(): number;
  44665. /**
  44666. * Sets the value of the `L1` button
  44667. */
  44668. set buttonL1(value: number);
  44669. /**
  44670. * Gets the value of the `R1` button
  44671. */
  44672. get buttonR1(): number;
  44673. /**
  44674. * Sets the value of the `R1` button
  44675. */
  44676. set buttonR1(value: number);
  44677. /**
  44678. * Gets the value of the Left joystick
  44679. */
  44680. get buttonLeftStick(): number;
  44681. /**
  44682. * Sets the value of the Left joystick
  44683. */
  44684. set buttonLeftStick(value: number);
  44685. /**
  44686. * Gets the value of the Right joystick
  44687. */
  44688. get buttonRightStick(): number;
  44689. /**
  44690. * Sets the value of the Right joystick
  44691. */
  44692. set buttonRightStick(value: number);
  44693. /**
  44694. * Gets the value of D-pad up
  44695. */
  44696. get dPadUp(): number;
  44697. /**
  44698. * Sets the value of D-pad up
  44699. */
  44700. set dPadUp(value: number);
  44701. /**
  44702. * Gets the value of D-pad down
  44703. */
  44704. get dPadDown(): number;
  44705. /**
  44706. * Sets the value of D-pad down
  44707. */
  44708. set dPadDown(value: number);
  44709. /**
  44710. * Gets the value of D-pad left
  44711. */
  44712. get dPadLeft(): number;
  44713. /**
  44714. * Sets the value of D-pad left
  44715. */
  44716. set dPadLeft(value: number);
  44717. /**
  44718. * Gets the value of D-pad right
  44719. */
  44720. get dPadRight(): number;
  44721. /**
  44722. * Sets the value of D-pad right
  44723. */
  44724. set dPadRight(value: number);
  44725. /**
  44726. * Force the gamepad to synchronize with device values
  44727. */
  44728. update(): void;
  44729. /**
  44730. * Disposes the gamepad
  44731. */
  44732. dispose(): void;
  44733. }
  44734. }
  44735. declare module BABYLON {
  44736. /**
  44737. * Manager for handling gamepads
  44738. */
  44739. export class GamepadManager {
  44740. private _scene?;
  44741. private _babylonGamepads;
  44742. private _oneGamepadConnected;
  44743. /** @hidden */
  44744. _isMonitoring: boolean;
  44745. private _gamepadEventSupported;
  44746. private _gamepadSupport?;
  44747. /**
  44748. * observable to be triggered when the gamepad controller has been connected
  44749. */
  44750. onGamepadConnectedObservable: Observable<Gamepad>;
  44751. /**
  44752. * observable to be triggered when the gamepad controller has been disconnected
  44753. */
  44754. onGamepadDisconnectedObservable: Observable<Gamepad>;
  44755. private _onGamepadConnectedEvent;
  44756. private _onGamepadDisconnectedEvent;
  44757. /**
  44758. * Initializes the gamepad manager
  44759. * @param _scene BabylonJS scene
  44760. */
  44761. constructor(_scene?: Scene | undefined);
  44762. /**
  44763. * The gamepads in the game pad manager
  44764. */
  44765. get gamepads(): Gamepad[];
  44766. /**
  44767. * Get the gamepad controllers based on type
  44768. * @param type The type of gamepad controller
  44769. * @returns Nullable gamepad
  44770. */
  44771. getGamepadByType(type?: number): Nullable<Gamepad>;
  44772. /**
  44773. * Disposes the gamepad manager
  44774. */
  44775. dispose(): void;
  44776. private _addNewGamepad;
  44777. private _startMonitoringGamepads;
  44778. private _stopMonitoringGamepads;
  44779. /** @hidden */
  44780. _checkGamepadsStatus(): void;
  44781. private _updateGamepadObjects;
  44782. }
  44783. }
  44784. declare module BABYLON {
  44785. interface Scene {
  44786. /** @hidden */
  44787. _gamepadManager: Nullable<GamepadManager>;
  44788. /**
  44789. * Gets the gamepad manager associated with the scene
  44790. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  44791. */
  44792. gamepadManager: GamepadManager;
  44793. }
  44794. /**
  44795. * Interface representing a free camera inputs manager
  44796. */
  44797. interface FreeCameraInputsManager {
  44798. /**
  44799. * Adds gamepad input support to the FreeCameraInputsManager.
  44800. * @returns the FreeCameraInputsManager
  44801. */
  44802. addGamepad(): FreeCameraInputsManager;
  44803. }
  44804. /**
  44805. * Interface representing an arc rotate camera inputs manager
  44806. */
  44807. interface ArcRotateCameraInputsManager {
  44808. /**
  44809. * Adds gamepad input support to the ArcRotateCamera InputManager.
  44810. * @returns the camera inputs manager
  44811. */
  44812. addGamepad(): ArcRotateCameraInputsManager;
  44813. }
  44814. /**
  44815. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  44816. */
  44817. export class GamepadSystemSceneComponent implements ISceneComponent {
  44818. /**
  44819. * The component name helpfull to identify the component in the list of scene components.
  44820. */
  44821. readonly name: string;
  44822. /**
  44823. * The scene the component belongs to.
  44824. */
  44825. scene: Scene;
  44826. /**
  44827. * Creates a new instance of the component for the given scene
  44828. * @param scene Defines the scene to register the component in
  44829. */
  44830. constructor(scene: Scene);
  44831. /**
  44832. * Registers the component in a given scene
  44833. */
  44834. register(): void;
  44835. /**
  44836. * Rebuilds the elements related to this component in case of
  44837. * context lost for instance.
  44838. */
  44839. rebuild(): void;
  44840. /**
  44841. * Disposes the component and the associated ressources
  44842. */
  44843. dispose(): void;
  44844. private _beforeCameraUpdate;
  44845. }
  44846. }
  44847. declare module BABYLON {
  44848. /**
  44849. * 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,
  44850. * which still works and will still be found in many Playgrounds.
  44851. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44852. */
  44853. export class UniversalCamera extends TouchCamera {
  44854. /**
  44855. * Defines the gamepad rotation sensiblity.
  44856. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44857. */
  44858. get gamepadAngularSensibility(): number;
  44859. set gamepadAngularSensibility(value: number);
  44860. /**
  44861. * Defines the gamepad move sensiblity.
  44862. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44863. */
  44864. get gamepadMoveSensibility(): number;
  44865. set gamepadMoveSensibility(value: number);
  44866. /**
  44867. * 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,
  44868. * which still works and will still be found in many Playgrounds.
  44869. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44870. * @param name Define the name of the camera in the scene
  44871. * @param position Define the start position of the camera in the scene
  44872. * @param scene Define the scene the camera belongs to
  44873. */
  44874. constructor(name: string, position: Vector3, scene: Scene);
  44875. /**
  44876. * Gets the current object class name.
  44877. * @return the class name
  44878. */
  44879. getClassName(): string;
  44880. }
  44881. }
  44882. declare module BABYLON {
  44883. /**
  44884. * This represents a FPS type of camera. This is only here for back compat purpose.
  44885. * Please use the UniversalCamera instead as both are identical.
  44886. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44887. */
  44888. export class GamepadCamera extends UniversalCamera {
  44889. /**
  44890. * Instantiates a new Gamepad Camera
  44891. * This represents a FPS type of camera. This is only here for back compat purpose.
  44892. * Please use the UniversalCamera instead as both are identical.
  44893. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44894. * @param name Define the name of the camera in the scene
  44895. * @param position Define the start position of the camera in the scene
  44896. * @param scene Define the scene the camera belongs to
  44897. */
  44898. constructor(name: string, position: Vector3, scene: Scene);
  44899. /**
  44900. * Gets the current object class name.
  44901. * @return the class name
  44902. */
  44903. getClassName(): string;
  44904. }
  44905. }
  44906. declare module BABYLON {
  44907. /** @hidden */
  44908. export var passPixelShader: {
  44909. name: string;
  44910. shader: string;
  44911. };
  44912. }
  44913. declare module BABYLON {
  44914. /** @hidden */
  44915. export var passCubePixelShader: {
  44916. name: string;
  44917. shader: string;
  44918. };
  44919. }
  44920. declare module BABYLON {
  44921. /**
  44922. * PassPostProcess which produces an output the same as it's input
  44923. */
  44924. export class PassPostProcess extends PostProcess {
  44925. /**
  44926. * Creates the PassPostProcess
  44927. * @param name The name of the effect.
  44928. * @param options The required width/height ratio to downsize to before computing the render pass.
  44929. * @param camera The camera to apply the render pass to.
  44930. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  44931. * @param engine The engine which the post process will be applied. (default: current engine)
  44932. * @param reusable If the post process can be reused on the same frame. (default: false)
  44933. * @param textureType The type of texture to be used when performing the post processing.
  44934. * @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)
  44935. */
  44936. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  44937. }
  44938. /**
  44939. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  44940. */
  44941. export class PassCubePostProcess extends PostProcess {
  44942. private _face;
  44943. /**
  44944. * Gets or sets the cube face to display.
  44945. * * 0 is +X
  44946. * * 1 is -X
  44947. * * 2 is +Y
  44948. * * 3 is -Y
  44949. * * 4 is +Z
  44950. * * 5 is -Z
  44951. */
  44952. get face(): number;
  44953. set face(value: number);
  44954. /**
  44955. * Creates the PassCubePostProcess
  44956. * @param name The name of the effect.
  44957. * @param options The required width/height ratio to downsize to before computing the render pass.
  44958. * @param camera The camera to apply the render pass to.
  44959. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  44960. * @param engine The engine which the post process will be applied. (default: current engine)
  44961. * @param reusable If the post process can be reused on the same frame. (default: false)
  44962. * @param textureType The type of texture to be used when performing the post processing.
  44963. * @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)
  44964. */
  44965. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  44966. }
  44967. }
  44968. declare module BABYLON {
  44969. /** @hidden */
  44970. export var anaglyphPixelShader: {
  44971. name: string;
  44972. shader: string;
  44973. };
  44974. }
  44975. declare module BABYLON {
  44976. /**
  44977. * Postprocess used to generate anaglyphic rendering
  44978. */
  44979. export class AnaglyphPostProcess extends PostProcess {
  44980. private _passedProcess;
  44981. /**
  44982. * Creates a new AnaglyphPostProcess
  44983. * @param name defines postprocess name
  44984. * @param options defines creation options or target ratio scale
  44985. * @param rigCameras defines cameras using this postprocess
  44986. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  44987. * @param engine defines hosting engine
  44988. * @param reusable defines if the postprocess will be reused multiple times per frame
  44989. */
  44990. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  44991. }
  44992. }
  44993. declare module BABYLON {
  44994. /**
  44995. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  44996. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44997. */
  44998. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  44999. /**
  45000. * Creates a new AnaglyphArcRotateCamera
  45001. * @param name defines camera name
  45002. * @param alpha defines alpha angle (in radians)
  45003. * @param beta defines beta angle (in radians)
  45004. * @param radius defines radius
  45005. * @param target defines camera target
  45006. * @param interaxialDistance defines distance between each color axis
  45007. * @param scene defines the hosting scene
  45008. */
  45009. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  45010. /**
  45011. * Gets camera class name
  45012. * @returns AnaglyphArcRotateCamera
  45013. */
  45014. getClassName(): string;
  45015. }
  45016. }
  45017. declare module BABYLON {
  45018. /**
  45019. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  45020. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45021. */
  45022. export class AnaglyphFreeCamera extends FreeCamera {
  45023. /**
  45024. * Creates a new AnaglyphFreeCamera
  45025. * @param name defines camera name
  45026. * @param position defines initial position
  45027. * @param interaxialDistance defines distance between each color axis
  45028. * @param scene defines the hosting scene
  45029. */
  45030. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45031. /**
  45032. * Gets camera class name
  45033. * @returns AnaglyphFreeCamera
  45034. */
  45035. getClassName(): string;
  45036. }
  45037. }
  45038. declare module BABYLON {
  45039. /**
  45040. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  45041. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45042. */
  45043. export class AnaglyphGamepadCamera extends GamepadCamera {
  45044. /**
  45045. * Creates a new AnaglyphGamepadCamera
  45046. * @param name defines camera name
  45047. * @param position defines initial position
  45048. * @param interaxialDistance defines distance between each color axis
  45049. * @param scene defines the hosting scene
  45050. */
  45051. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45052. /**
  45053. * Gets camera class name
  45054. * @returns AnaglyphGamepadCamera
  45055. */
  45056. getClassName(): string;
  45057. }
  45058. }
  45059. declare module BABYLON {
  45060. /**
  45061. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  45062. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45063. */
  45064. export class AnaglyphUniversalCamera extends UniversalCamera {
  45065. /**
  45066. * Creates a new AnaglyphUniversalCamera
  45067. * @param name defines camera name
  45068. * @param position defines initial position
  45069. * @param interaxialDistance defines distance between each color axis
  45070. * @param scene defines the hosting scene
  45071. */
  45072. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45073. /**
  45074. * Gets camera class name
  45075. * @returns AnaglyphUniversalCamera
  45076. */
  45077. getClassName(): string;
  45078. }
  45079. }
  45080. declare module BABYLON {
  45081. /**
  45082. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  45083. * @see http://doc.babylonjs.com/features/cameras
  45084. */
  45085. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  45086. /**
  45087. * Creates a new StereoscopicArcRotateCamera
  45088. * @param name defines camera name
  45089. * @param alpha defines alpha angle (in radians)
  45090. * @param beta defines beta angle (in radians)
  45091. * @param radius defines radius
  45092. * @param target defines camera target
  45093. * @param interaxialDistance defines distance between each color axis
  45094. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45095. * @param scene defines the hosting scene
  45096. */
  45097. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45098. /**
  45099. * Gets camera class name
  45100. * @returns StereoscopicArcRotateCamera
  45101. */
  45102. getClassName(): string;
  45103. }
  45104. }
  45105. declare module BABYLON {
  45106. /**
  45107. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  45108. * @see http://doc.babylonjs.com/features/cameras
  45109. */
  45110. export class StereoscopicFreeCamera extends FreeCamera {
  45111. /**
  45112. * Creates a new StereoscopicFreeCamera
  45113. * @param name defines camera name
  45114. * @param position defines initial position
  45115. * @param interaxialDistance defines distance between each color axis
  45116. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45117. * @param scene defines the hosting scene
  45118. */
  45119. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45120. /**
  45121. * Gets camera class name
  45122. * @returns StereoscopicFreeCamera
  45123. */
  45124. getClassName(): string;
  45125. }
  45126. }
  45127. declare module BABYLON {
  45128. /**
  45129. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  45130. * @see http://doc.babylonjs.com/features/cameras
  45131. */
  45132. export class StereoscopicGamepadCamera extends GamepadCamera {
  45133. /**
  45134. * Creates a new StereoscopicGamepadCamera
  45135. * @param name defines camera name
  45136. * @param position defines initial position
  45137. * @param interaxialDistance defines distance between each color axis
  45138. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45139. * @param scene defines the hosting scene
  45140. */
  45141. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45142. /**
  45143. * Gets camera class name
  45144. * @returns StereoscopicGamepadCamera
  45145. */
  45146. getClassName(): string;
  45147. }
  45148. }
  45149. declare module BABYLON {
  45150. /**
  45151. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  45152. * @see http://doc.babylonjs.com/features/cameras
  45153. */
  45154. export class StereoscopicUniversalCamera extends UniversalCamera {
  45155. /**
  45156. * Creates a new StereoscopicUniversalCamera
  45157. * @param name defines camera name
  45158. * @param position defines initial position
  45159. * @param interaxialDistance defines distance between each color axis
  45160. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45161. * @param scene defines the hosting scene
  45162. */
  45163. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45164. /**
  45165. * Gets camera class name
  45166. * @returns StereoscopicUniversalCamera
  45167. */
  45168. getClassName(): string;
  45169. }
  45170. }
  45171. declare module BABYLON {
  45172. /**
  45173. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  45174. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  45175. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  45176. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  45177. */
  45178. export class VirtualJoysticksCamera extends FreeCamera {
  45179. /**
  45180. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  45181. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  45182. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  45183. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  45184. * @param name Define the name of the camera in the scene
  45185. * @param position Define the start position of the camera in the scene
  45186. * @param scene Define the scene the camera belongs to
  45187. */
  45188. constructor(name: string, position: Vector3, scene: Scene);
  45189. /**
  45190. * Gets the current object class name.
  45191. * @return the class name
  45192. */
  45193. getClassName(): string;
  45194. }
  45195. }
  45196. declare module BABYLON {
  45197. /**
  45198. * This represents all the required metrics to create a VR camera.
  45199. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  45200. */
  45201. export class VRCameraMetrics {
  45202. /**
  45203. * Define the horizontal resolution off the screen.
  45204. */
  45205. hResolution: number;
  45206. /**
  45207. * Define the vertical resolution off the screen.
  45208. */
  45209. vResolution: number;
  45210. /**
  45211. * Define the horizontal screen size.
  45212. */
  45213. hScreenSize: number;
  45214. /**
  45215. * Define the vertical screen size.
  45216. */
  45217. vScreenSize: number;
  45218. /**
  45219. * Define the vertical screen center position.
  45220. */
  45221. vScreenCenter: number;
  45222. /**
  45223. * Define the distance of the eyes to the screen.
  45224. */
  45225. eyeToScreenDistance: number;
  45226. /**
  45227. * Define the distance between both lenses
  45228. */
  45229. lensSeparationDistance: number;
  45230. /**
  45231. * Define the distance between both viewer's eyes.
  45232. */
  45233. interpupillaryDistance: number;
  45234. /**
  45235. * Define the distortion factor of the VR postprocess.
  45236. * Please, touch with care.
  45237. */
  45238. distortionK: number[];
  45239. /**
  45240. * Define the chromatic aberration correction factors for the VR post process.
  45241. */
  45242. chromaAbCorrection: number[];
  45243. /**
  45244. * Define the scale factor of the post process.
  45245. * The smaller the better but the slower.
  45246. */
  45247. postProcessScaleFactor: number;
  45248. /**
  45249. * Define an offset for the lens center.
  45250. */
  45251. lensCenterOffset: number;
  45252. /**
  45253. * Define if the current vr camera should compensate the distortion of the lense or not.
  45254. */
  45255. compensateDistortion: boolean;
  45256. /**
  45257. * Defines if multiview should be enabled when rendering (Default: false)
  45258. */
  45259. multiviewEnabled: boolean;
  45260. /**
  45261. * Gets the rendering aspect ratio based on the provided resolutions.
  45262. */
  45263. get aspectRatio(): number;
  45264. /**
  45265. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  45266. */
  45267. get aspectRatioFov(): number;
  45268. /**
  45269. * @hidden
  45270. */
  45271. get leftHMatrix(): Matrix;
  45272. /**
  45273. * @hidden
  45274. */
  45275. get rightHMatrix(): Matrix;
  45276. /**
  45277. * @hidden
  45278. */
  45279. get leftPreViewMatrix(): Matrix;
  45280. /**
  45281. * @hidden
  45282. */
  45283. get rightPreViewMatrix(): Matrix;
  45284. /**
  45285. * Get the default VRMetrics based on the most generic setup.
  45286. * @returns the default vr metrics
  45287. */
  45288. static GetDefault(): VRCameraMetrics;
  45289. }
  45290. }
  45291. declare module BABYLON {
  45292. /** @hidden */
  45293. export var vrDistortionCorrectionPixelShader: {
  45294. name: string;
  45295. shader: string;
  45296. };
  45297. }
  45298. declare module BABYLON {
  45299. /**
  45300. * VRDistortionCorrectionPostProcess used for mobile VR
  45301. */
  45302. export class VRDistortionCorrectionPostProcess extends PostProcess {
  45303. private _isRightEye;
  45304. private _distortionFactors;
  45305. private _postProcessScaleFactor;
  45306. private _lensCenterOffset;
  45307. private _scaleIn;
  45308. private _scaleFactor;
  45309. private _lensCenter;
  45310. /**
  45311. * Initializes the VRDistortionCorrectionPostProcess
  45312. * @param name The name of the effect.
  45313. * @param camera The camera to apply the render pass to.
  45314. * @param isRightEye If this is for the right eye distortion
  45315. * @param vrMetrics All the required metrics for the VR camera
  45316. */
  45317. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  45318. }
  45319. }
  45320. declare module BABYLON {
  45321. /**
  45322. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  45323. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45324. */
  45325. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  45326. /**
  45327. * Creates a new VRDeviceOrientationArcRotateCamera
  45328. * @param name defines camera name
  45329. * @param alpha defines the camera rotation along the logitudinal axis
  45330. * @param beta defines the camera rotation along the latitudinal axis
  45331. * @param radius defines the camera distance from its target
  45332. * @param target defines the camera target
  45333. * @param scene defines the scene the camera belongs to
  45334. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45335. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45336. */
  45337. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45338. /**
  45339. * Gets camera class name
  45340. * @returns VRDeviceOrientationArcRotateCamera
  45341. */
  45342. getClassName(): string;
  45343. }
  45344. }
  45345. declare module BABYLON {
  45346. /**
  45347. * Camera used to simulate VR rendering (based on FreeCamera)
  45348. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45349. */
  45350. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  45351. /**
  45352. * Creates a new VRDeviceOrientationFreeCamera
  45353. * @param name defines camera name
  45354. * @param position defines the start position of the camera
  45355. * @param scene defines the scene the camera belongs to
  45356. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45357. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45358. */
  45359. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45360. /**
  45361. * Gets camera class name
  45362. * @returns VRDeviceOrientationFreeCamera
  45363. */
  45364. getClassName(): string;
  45365. }
  45366. }
  45367. declare module BABYLON {
  45368. /**
  45369. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  45370. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45371. */
  45372. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  45373. /**
  45374. * Creates a new VRDeviceOrientationGamepadCamera
  45375. * @param name defines camera name
  45376. * @param position defines the start position of the camera
  45377. * @param scene defines the scene the camera belongs to
  45378. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45379. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45380. */
  45381. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45382. /**
  45383. * Gets camera class name
  45384. * @returns VRDeviceOrientationGamepadCamera
  45385. */
  45386. getClassName(): string;
  45387. }
  45388. }
  45389. declare module BABYLON {
  45390. /**
  45391. * A class extending Texture allowing drawing on a texture
  45392. * @see http://doc.babylonjs.com/how_to/dynamictexture
  45393. */
  45394. export class DynamicTexture extends Texture {
  45395. private _generateMipMaps;
  45396. private _canvas;
  45397. private _context;
  45398. /**
  45399. * Creates a DynamicTexture
  45400. * @param name defines the name of the texture
  45401. * @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
  45402. * @param scene defines the scene where you want the texture
  45403. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  45404. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  45405. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  45406. */
  45407. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  45408. /**
  45409. * Get the current class name of the texture useful for serialization or dynamic coding.
  45410. * @returns "DynamicTexture"
  45411. */
  45412. getClassName(): string;
  45413. /**
  45414. * Gets the current state of canRescale
  45415. */
  45416. get canRescale(): boolean;
  45417. private _recreate;
  45418. /**
  45419. * Scales the texture
  45420. * @param ratio the scale factor to apply to both width and height
  45421. */
  45422. scale(ratio: number): void;
  45423. /**
  45424. * Resizes the texture
  45425. * @param width the new width
  45426. * @param height the new height
  45427. */
  45428. scaleTo(width: number, height: number): void;
  45429. /**
  45430. * Gets the context of the canvas used by the texture
  45431. * @returns the canvas context of the dynamic texture
  45432. */
  45433. getContext(): CanvasRenderingContext2D;
  45434. /**
  45435. * Clears the texture
  45436. */
  45437. clear(): void;
  45438. /**
  45439. * Updates the texture
  45440. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  45441. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  45442. */
  45443. update(invertY?: boolean, premulAlpha?: boolean): void;
  45444. /**
  45445. * Draws text onto the texture
  45446. * @param text defines the text to be drawn
  45447. * @param x defines the placement of the text from the left
  45448. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  45449. * @param font defines the font to be used with font-style, font-size, font-name
  45450. * @param color defines the color used for the text
  45451. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  45452. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  45453. * @param update defines whether texture is immediately update (default is true)
  45454. */
  45455. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  45456. /**
  45457. * Clones the texture
  45458. * @returns the clone of the texture.
  45459. */
  45460. clone(): DynamicTexture;
  45461. /**
  45462. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  45463. * @returns a serialized dynamic texture object
  45464. */
  45465. serialize(): any;
  45466. private _IsCanvasElement;
  45467. /** @hidden */
  45468. _rebuild(): void;
  45469. }
  45470. }
  45471. declare module BABYLON {
  45472. /** @hidden */
  45473. export var imageProcessingPixelShader: {
  45474. name: string;
  45475. shader: string;
  45476. };
  45477. }
  45478. declare module BABYLON {
  45479. /**
  45480. * ImageProcessingPostProcess
  45481. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  45482. */
  45483. export class ImageProcessingPostProcess extends PostProcess {
  45484. /**
  45485. * Default configuration related to image processing available in the PBR Material.
  45486. */
  45487. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45488. /**
  45489. * Gets the image processing configuration used either in this material.
  45490. */
  45491. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  45492. /**
  45493. * Sets the Default image processing configuration used either in the this material.
  45494. *
  45495. * If sets to null, the scene one is in use.
  45496. */
  45497. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  45498. /**
  45499. * Keep track of the image processing observer to allow dispose and replace.
  45500. */
  45501. private _imageProcessingObserver;
  45502. /**
  45503. * Attaches a new image processing configuration to the PBR Material.
  45504. * @param configuration
  45505. */
  45506. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  45507. /**
  45508. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45509. */
  45510. get colorCurves(): Nullable<ColorCurves>;
  45511. /**
  45512. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45513. */
  45514. set colorCurves(value: Nullable<ColorCurves>);
  45515. /**
  45516. * Gets wether the color curves effect is enabled.
  45517. */
  45518. get colorCurvesEnabled(): boolean;
  45519. /**
  45520. * Sets wether the color curves effect is enabled.
  45521. */
  45522. set colorCurvesEnabled(value: boolean);
  45523. /**
  45524. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45525. */
  45526. get colorGradingTexture(): Nullable<BaseTexture>;
  45527. /**
  45528. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45529. */
  45530. set colorGradingTexture(value: Nullable<BaseTexture>);
  45531. /**
  45532. * Gets wether the color grading effect is enabled.
  45533. */
  45534. get colorGradingEnabled(): boolean;
  45535. /**
  45536. * Gets wether the color grading effect is enabled.
  45537. */
  45538. set colorGradingEnabled(value: boolean);
  45539. /**
  45540. * Gets exposure used in the effect.
  45541. */
  45542. get exposure(): number;
  45543. /**
  45544. * Sets exposure used in the effect.
  45545. */
  45546. set exposure(value: number);
  45547. /**
  45548. * Gets wether tonemapping is enabled or not.
  45549. */
  45550. get toneMappingEnabled(): boolean;
  45551. /**
  45552. * Sets wether tonemapping is enabled or not
  45553. */
  45554. set toneMappingEnabled(value: boolean);
  45555. /**
  45556. * Gets the type of tone mapping effect.
  45557. */
  45558. get toneMappingType(): number;
  45559. /**
  45560. * Sets the type of tone mapping effect.
  45561. */
  45562. set toneMappingType(value: number);
  45563. /**
  45564. * Gets contrast used in the effect.
  45565. */
  45566. get contrast(): number;
  45567. /**
  45568. * Sets contrast used in the effect.
  45569. */
  45570. set contrast(value: number);
  45571. /**
  45572. * Gets Vignette stretch size.
  45573. */
  45574. get vignetteStretch(): number;
  45575. /**
  45576. * Sets Vignette stretch size.
  45577. */
  45578. set vignetteStretch(value: number);
  45579. /**
  45580. * Gets Vignette centre X Offset.
  45581. */
  45582. get vignetteCentreX(): number;
  45583. /**
  45584. * Sets Vignette centre X Offset.
  45585. */
  45586. set vignetteCentreX(value: number);
  45587. /**
  45588. * Gets Vignette centre Y Offset.
  45589. */
  45590. get vignetteCentreY(): number;
  45591. /**
  45592. * Sets Vignette centre Y Offset.
  45593. */
  45594. set vignetteCentreY(value: number);
  45595. /**
  45596. * Gets Vignette weight or intensity of the vignette effect.
  45597. */
  45598. get vignetteWeight(): number;
  45599. /**
  45600. * Sets Vignette weight or intensity of the vignette effect.
  45601. */
  45602. set vignetteWeight(value: number);
  45603. /**
  45604. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45605. * if vignetteEnabled is set to true.
  45606. */
  45607. get vignetteColor(): Color4;
  45608. /**
  45609. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45610. * if vignetteEnabled is set to true.
  45611. */
  45612. set vignetteColor(value: Color4);
  45613. /**
  45614. * Gets Camera field of view used by the Vignette effect.
  45615. */
  45616. get vignetteCameraFov(): number;
  45617. /**
  45618. * Sets Camera field of view used by the Vignette effect.
  45619. */
  45620. set vignetteCameraFov(value: number);
  45621. /**
  45622. * Gets the vignette blend mode allowing different kind of effect.
  45623. */
  45624. get vignetteBlendMode(): number;
  45625. /**
  45626. * Sets the vignette blend mode allowing different kind of effect.
  45627. */
  45628. set vignetteBlendMode(value: number);
  45629. /**
  45630. * Gets wether the vignette effect is enabled.
  45631. */
  45632. get vignetteEnabled(): boolean;
  45633. /**
  45634. * Sets wether the vignette effect is enabled.
  45635. */
  45636. set vignetteEnabled(value: boolean);
  45637. private _fromLinearSpace;
  45638. /**
  45639. * Gets wether the input of the processing is in Gamma or Linear Space.
  45640. */
  45641. get fromLinearSpace(): boolean;
  45642. /**
  45643. * Sets wether the input of the processing is in Gamma or Linear Space.
  45644. */
  45645. set fromLinearSpace(value: boolean);
  45646. /**
  45647. * Defines cache preventing GC.
  45648. */
  45649. private _defines;
  45650. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  45651. /**
  45652. * "ImageProcessingPostProcess"
  45653. * @returns "ImageProcessingPostProcess"
  45654. */
  45655. getClassName(): string;
  45656. protected _updateParameters(): void;
  45657. dispose(camera?: Camera): void;
  45658. }
  45659. }
  45660. declare module BABYLON {
  45661. /**
  45662. * Class containing static functions to help procedurally build meshes
  45663. */
  45664. export class GroundBuilder {
  45665. /**
  45666. * Creates a ground mesh
  45667. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  45668. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  45669. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45670. * @param name defines the name of the mesh
  45671. * @param options defines the options used to create the mesh
  45672. * @param scene defines the hosting scene
  45673. * @returns the ground mesh
  45674. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  45675. */
  45676. static CreateGround(name: string, options: {
  45677. width?: number;
  45678. height?: number;
  45679. subdivisions?: number;
  45680. subdivisionsX?: number;
  45681. subdivisionsY?: number;
  45682. updatable?: boolean;
  45683. }, scene: any): Mesh;
  45684. /**
  45685. * Creates a tiled ground mesh
  45686. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  45687. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  45688. * * 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
  45689. * * 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
  45690. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45691. * @param name defines the name of the mesh
  45692. * @param options defines the options used to create the mesh
  45693. * @param scene defines the hosting scene
  45694. * @returns the tiled ground mesh
  45695. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  45696. */
  45697. static CreateTiledGround(name: string, options: {
  45698. xmin: number;
  45699. zmin: number;
  45700. xmax: number;
  45701. zmax: number;
  45702. subdivisions?: {
  45703. w: number;
  45704. h: number;
  45705. };
  45706. precision?: {
  45707. w: number;
  45708. h: number;
  45709. };
  45710. updatable?: boolean;
  45711. }, scene?: Nullable<Scene>): Mesh;
  45712. /**
  45713. * Creates a ground mesh from a height map
  45714. * * The parameter `url` sets the URL of the height map image resource.
  45715. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  45716. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  45717. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  45718. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  45719. * * 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.
  45720. * * 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).
  45721. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  45722. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45723. * @param name defines the name of the mesh
  45724. * @param url defines the url to the height map
  45725. * @param options defines the options used to create the mesh
  45726. * @param scene defines the hosting scene
  45727. * @returns the ground mesh
  45728. * @see https://doc.babylonjs.com/babylon101/height_map
  45729. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  45730. */
  45731. static CreateGroundFromHeightMap(name: string, url: string, options: {
  45732. width?: number;
  45733. height?: number;
  45734. subdivisions?: number;
  45735. minHeight?: number;
  45736. maxHeight?: number;
  45737. colorFilter?: Color3;
  45738. alphaFilter?: number;
  45739. updatable?: boolean;
  45740. onReady?: (mesh: GroundMesh) => void;
  45741. }, scene?: Nullable<Scene>): GroundMesh;
  45742. }
  45743. }
  45744. declare module BABYLON {
  45745. /**
  45746. * Class containing static functions to help procedurally build meshes
  45747. */
  45748. export class TorusBuilder {
  45749. /**
  45750. * Creates a torus mesh
  45751. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  45752. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  45753. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  45754. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45755. * * 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
  45756. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45757. * @param name defines the name of the mesh
  45758. * @param options defines the options used to create the mesh
  45759. * @param scene defines the hosting scene
  45760. * @returns the torus mesh
  45761. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  45762. */
  45763. static CreateTorus(name: string, options: {
  45764. diameter?: number;
  45765. thickness?: number;
  45766. tessellation?: number;
  45767. updatable?: boolean;
  45768. sideOrientation?: number;
  45769. frontUVs?: Vector4;
  45770. backUVs?: Vector4;
  45771. }, scene: any): Mesh;
  45772. }
  45773. }
  45774. declare module BABYLON {
  45775. /**
  45776. * Class containing static functions to help procedurally build meshes
  45777. */
  45778. export class CylinderBuilder {
  45779. /**
  45780. * Creates a cylinder or a cone mesh
  45781. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  45782. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  45783. * * 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.
  45784. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  45785. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  45786. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  45787. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  45788. * * 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).
  45789. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  45790. * * 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).
  45791. * * 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
  45792. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  45793. * * 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
  45794. * * 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.
  45795. * * If `enclose` is false, a ring surface is one element.
  45796. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  45797. * * 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
  45798. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45799. * * 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
  45800. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45801. * @param name defines the name of the mesh
  45802. * @param options defines the options used to create the mesh
  45803. * @param scene defines the hosting scene
  45804. * @returns the cylinder mesh
  45805. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  45806. */
  45807. static CreateCylinder(name: string, options: {
  45808. height?: number;
  45809. diameterTop?: number;
  45810. diameterBottom?: number;
  45811. diameter?: number;
  45812. tessellation?: number;
  45813. subdivisions?: number;
  45814. arc?: number;
  45815. faceColors?: Color4[];
  45816. faceUV?: Vector4[];
  45817. updatable?: boolean;
  45818. hasRings?: boolean;
  45819. enclose?: boolean;
  45820. cap?: number;
  45821. sideOrientation?: number;
  45822. frontUVs?: Vector4;
  45823. backUVs?: Vector4;
  45824. }, scene: any): Mesh;
  45825. }
  45826. }
  45827. declare module BABYLON {
  45828. /**
  45829. * States of the webXR experience
  45830. */
  45831. export enum WebXRState {
  45832. /**
  45833. * Transitioning to being in XR mode
  45834. */
  45835. ENTERING_XR = 0,
  45836. /**
  45837. * Transitioning to non XR mode
  45838. */
  45839. EXITING_XR = 1,
  45840. /**
  45841. * In XR mode and presenting
  45842. */
  45843. IN_XR = 2,
  45844. /**
  45845. * Not entered XR mode
  45846. */
  45847. NOT_IN_XR = 3
  45848. }
  45849. /**
  45850. * Abstraction of the XR render target
  45851. */
  45852. export interface WebXRRenderTarget extends IDisposable {
  45853. /**
  45854. * xrpresent context of the canvas which can be used to display/mirror xr content
  45855. */
  45856. canvasContext: WebGLRenderingContext;
  45857. /**
  45858. * xr layer for the canvas
  45859. */
  45860. xrLayer: Nullable<XRWebGLLayer>;
  45861. /**
  45862. * Initializes the xr layer for the session
  45863. * @param xrSession xr session
  45864. * @returns a promise that will resolve once the XR Layer has been created
  45865. */
  45866. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  45867. }
  45868. }
  45869. declare module BABYLON {
  45870. /**
  45871. * COnfiguration object for WebXR output canvas
  45872. */
  45873. export class WebXRManagedOutputCanvasOptions {
  45874. /**
  45875. * An optional canvas in case you wish to create it yourself and provide it here.
  45876. * If not provided, a new canvas will be created
  45877. */
  45878. canvasElement?: HTMLCanvasElement;
  45879. /**
  45880. * Options for this XR Layer output
  45881. */
  45882. canvasOptions?: XRWebGLLayerOptions;
  45883. /**
  45884. * CSS styling for a newly created canvas (if not provided)
  45885. */
  45886. newCanvasCssStyle?: string;
  45887. /**
  45888. * Get the default values of the configuration object
  45889. * @returns default values of this configuration object
  45890. */
  45891. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  45892. }
  45893. /**
  45894. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  45895. */
  45896. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  45897. private _options;
  45898. private _canvas;
  45899. private _engine;
  45900. /**
  45901. * Rendering context of the canvas which can be used to display/mirror xr content
  45902. */
  45903. canvasContext: WebGLRenderingContext;
  45904. /**
  45905. * xr layer for the canvas
  45906. */
  45907. xrLayer: Nullable<XRWebGLLayer>;
  45908. /**
  45909. * Initializes the canvas to be added/removed upon entering/exiting xr
  45910. * @param _xrSessionManager The XR Session manager
  45911. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  45912. */
  45913. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  45914. /**
  45915. * Disposes of the object
  45916. */
  45917. dispose(): void;
  45918. /**
  45919. * Initializes the xr layer for the session
  45920. * @param xrSession xr session
  45921. * @returns a promise that will resolve once the XR Layer has been created
  45922. */
  45923. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  45924. private _addCanvas;
  45925. private _removeCanvas;
  45926. private _setManagedOutputCanvas;
  45927. }
  45928. }
  45929. declare module BABYLON {
  45930. /**
  45931. * Manages an XRSession to work with Babylon's engine
  45932. * @see https://doc.babylonjs.com/how_to/webxr
  45933. */
  45934. export class WebXRSessionManager implements IDisposable {
  45935. /** The scene which the session should be created for */
  45936. scene: Scene;
  45937. private _referenceSpace;
  45938. private _rttProvider;
  45939. private _sessionEnded;
  45940. private _xrNavigator;
  45941. private baseLayer;
  45942. /**
  45943. * The base reference space from which the session started. good if you want to reset your
  45944. * reference space
  45945. */
  45946. baseReferenceSpace: XRReferenceSpace;
  45947. /**
  45948. * Current XR frame
  45949. */
  45950. currentFrame: Nullable<XRFrame>;
  45951. /** WebXR timestamp updated every frame */
  45952. currentTimestamp: number;
  45953. /**
  45954. * Used just in case of a failure to initialize an immersive session.
  45955. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  45956. */
  45957. defaultHeightCompensation: number;
  45958. /**
  45959. * Fires every time a new xrFrame arrives which can be used to update the camera
  45960. */
  45961. onXRFrameObservable: Observable<XRFrame>;
  45962. /**
  45963. * Fires when the reference space changed
  45964. */
  45965. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  45966. /**
  45967. * Fires when the xr session is ended either by the device or manually done
  45968. */
  45969. onXRSessionEnded: Observable<any>;
  45970. /**
  45971. * Fires when the xr session is ended either by the device or manually done
  45972. */
  45973. onXRSessionInit: Observable<XRSession>;
  45974. /**
  45975. * Underlying xr session
  45976. */
  45977. session: XRSession;
  45978. /**
  45979. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  45980. * or get the offset the player is currently at.
  45981. */
  45982. viewerReferenceSpace: XRReferenceSpace;
  45983. /**
  45984. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  45985. * @param scene The scene which the session should be created for
  45986. */
  45987. constructor(
  45988. /** The scene which the session should be created for */
  45989. scene: Scene);
  45990. /**
  45991. * The current reference space used in this session. This reference space can constantly change!
  45992. * It is mainly used to offset the camera's position.
  45993. */
  45994. get referenceSpace(): XRReferenceSpace;
  45995. /**
  45996. * Set a new reference space and triggers the observable
  45997. */
  45998. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  45999. /**
  46000. * Disposes of the session manager
  46001. */
  46002. dispose(): void;
  46003. /**
  46004. * Stops the xrSession and restores the render loop
  46005. * @returns Promise which resolves after it exits XR
  46006. */
  46007. exitXRAsync(): Promise<void>;
  46008. /**
  46009. * Gets the correct render target texture to be rendered this frame for this eye
  46010. * @param eye the eye for which to get the render target
  46011. * @returns the render target for the specified eye
  46012. */
  46013. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  46014. /**
  46015. * Creates a WebXRRenderTarget object for the XR session
  46016. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  46017. * @param options optional options to provide when creating a new render target
  46018. * @returns a WebXR render target to which the session can render
  46019. */
  46020. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  46021. /**
  46022. * Initializes the manager
  46023. * After initialization enterXR can be called to start an XR session
  46024. * @returns Promise which resolves after it is initialized
  46025. */
  46026. initializeAsync(): Promise<void>;
  46027. /**
  46028. * Initializes an xr session
  46029. * @param xrSessionMode mode to initialize
  46030. * @param xrSessionInit defines optional and required values to pass to the session builder
  46031. * @returns a promise which will resolve once the session has been initialized
  46032. */
  46033. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  46034. /**
  46035. * Checks if a session would be supported for the creation options specified
  46036. * @param sessionMode session mode to check if supported eg. immersive-vr
  46037. * @returns A Promise that resolves to true if supported and false if not
  46038. */
  46039. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46040. /**
  46041. * Resets the reference space to the one started the session
  46042. */
  46043. resetReferenceSpace(): void;
  46044. /**
  46045. * Starts rendering to the xr layer
  46046. */
  46047. runXRRenderLoop(): void;
  46048. /**
  46049. * Sets the reference space on the xr session
  46050. * @param referenceSpaceType space to set
  46051. * @returns a promise that will resolve once the reference space has been set
  46052. */
  46053. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  46054. /**
  46055. * Updates the render state of the session
  46056. * @param state state to set
  46057. * @returns a promise that resolves once the render state has been updated
  46058. */
  46059. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  46060. /**
  46061. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  46062. * @param sessionMode defines the session to test
  46063. * @returns a promise with boolean as final value
  46064. */
  46065. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46066. private _createRenderTargetTexture;
  46067. }
  46068. }
  46069. declare module BABYLON {
  46070. /**
  46071. * WebXR Camera which holds the views for the xrSession
  46072. * @see https://doc.babylonjs.com/how_to/webxr_camera
  46073. */
  46074. export class WebXRCamera extends FreeCamera {
  46075. private _xrSessionManager;
  46076. private _firstFrame;
  46077. private _referenceQuaternion;
  46078. private _referencedPosition;
  46079. private _xrInvPositionCache;
  46080. private _xrInvQuaternionCache;
  46081. /**
  46082. * Should position compensation execute on first frame.
  46083. * This is used when copying the position from a native (non XR) camera
  46084. */
  46085. compensateOnFirstFrame: boolean;
  46086. /**
  46087. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  46088. * @param name the name of the camera
  46089. * @param scene the scene to add the camera to
  46090. * @param _xrSessionManager a constructed xr session manager
  46091. */
  46092. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  46093. /**
  46094. * Return the user's height, unrelated to the current ground.
  46095. * This will be the y position of this camera, when ground level is 0.
  46096. */
  46097. get realWorldHeight(): number;
  46098. /** @hidden */
  46099. _updateForDualEyeDebugging(): void;
  46100. /**
  46101. * Sets this camera's transformation based on a non-vr camera
  46102. * @param otherCamera the non-vr camera to copy the transformation from
  46103. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  46104. */
  46105. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  46106. /**
  46107. * Gets the current instance class name ("WebXRCamera").
  46108. * @returns the class name
  46109. */
  46110. getClassName(): string;
  46111. /**
  46112. * Overriding the _getViewMatrix function, as it is computed by WebXR
  46113. */
  46114. _getViewMatrix(): Matrix;
  46115. private _updateFromXRSession;
  46116. private _updateNumberOfRigCameras;
  46117. private _updateReferenceSpace;
  46118. private _updateReferenceSpaceOffset;
  46119. }
  46120. }
  46121. declare module BABYLON {
  46122. /**
  46123. * Defining the interface required for a (webxr) feature
  46124. */
  46125. export interface IWebXRFeature extends IDisposable {
  46126. /**
  46127. * Is this feature attached
  46128. */
  46129. attached: boolean;
  46130. /**
  46131. * Should auto-attach be disabled?
  46132. */
  46133. disableAutoAttach: boolean;
  46134. /**
  46135. * Attach the feature to the session
  46136. * Will usually be called by the features manager
  46137. *
  46138. * @param force should attachment be forced (even when already attached)
  46139. * @returns true if successful.
  46140. */
  46141. attach(force?: boolean): boolean;
  46142. /**
  46143. * Detach the feature from the session
  46144. * Will usually be called by the features manager
  46145. *
  46146. * @returns true if successful.
  46147. */
  46148. detach(): boolean;
  46149. }
  46150. /**
  46151. * A list of the currently available features without referencing them
  46152. */
  46153. export class WebXRFeatureName {
  46154. /**
  46155. * The name of the anchor system feature
  46156. */
  46157. static ANCHOR_SYSTEM: string;
  46158. /**
  46159. * The name of the background remover feature
  46160. */
  46161. static BACKGROUND_REMOVER: string;
  46162. /**
  46163. * The name of the hit test feature
  46164. */
  46165. static HIT_TEST: string;
  46166. /**
  46167. * physics impostors for xr controllers feature
  46168. */
  46169. static PHYSICS_CONTROLLERS: string;
  46170. /**
  46171. * The name of the plane detection feature
  46172. */
  46173. static PLANE_DETECTION: string;
  46174. /**
  46175. * The name of the pointer selection feature
  46176. */
  46177. static POINTER_SELECTION: string;
  46178. /**
  46179. * The name of the teleportation feature
  46180. */
  46181. static TELEPORTATION: string;
  46182. }
  46183. /**
  46184. * Defining the constructor of a feature. Used to register the modules.
  46185. */
  46186. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  46187. /**
  46188. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  46189. * It is mainly used in AR sessions.
  46190. *
  46191. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  46192. */
  46193. export class WebXRFeaturesManager implements IDisposable {
  46194. private _xrSessionManager;
  46195. private static readonly _AvailableFeatures;
  46196. private _features;
  46197. /**
  46198. * constructs a new features manages.
  46199. *
  46200. * @param _xrSessionManager an instance of WebXRSessionManager
  46201. */
  46202. constructor(_xrSessionManager: WebXRSessionManager);
  46203. /**
  46204. * Used to register a module. After calling this function a developer can use this feature in the scene.
  46205. * Mainly used internally.
  46206. *
  46207. * @param featureName the name of the feature to register
  46208. * @param constructorFunction the function used to construct the module
  46209. * @param version the (babylon) version of the module
  46210. * @param stable is that a stable version of this module
  46211. */
  46212. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  46213. /**
  46214. * Returns a constructor of a specific feature.
  46215. *
  46216. * @param featureName the name of the feature to construct
  46217. * @param version the version of the feature to load
  46218. * @param xrSessionManager the xrSessionManager. Used to construct the module
  46219. * @param options optional options provided to the module.
  46220. * @returns a function that, when called, will return a new instance of this feature
  46221. */
  46222. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  46223. /**
  46224. * Can be used to return the list of features currently registered
  46225. *
  46226. * @returns an Array of available features
  46227. */
  46228. static GetAvailableFeatures(): string[];
  46229. /**
  46230. * Gets the versions available for a specific feature
  46231. * @param featureName the name of the feature
  46232. * @returns an array with the available versions
  46233. */
  46234. static GetAvailableVersions(featureName: string): string[];
  46235. /**
  46236. * Return the latest unstable version of this feature
  46237. * @param featureName the name of the feature to search
  46238. * @returns the version number. if not found will return -1
  46239. */
  46240. static GetLatestVersionOfFeature(featureName: string): number;
  46241. /**
  46242. * Return the latest stable version of this feature
  46243. * @param featureName the name of the feature to search
  46244. * @returns the version number. if not found will return -1
  46245. */
  46246. static GetStableVersionOfFeature(featureName: string): number;
  46247. /**
  46248. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  46249. * Can be used during a session to start a feature
  46250. * @param featureName the name of feature to attach
  46251. */
  46252. attachFeature(featureName: string): void;
  46253. /**
  46254. * Can be used inside a session or when the session ends to detach a specific feature
  46255. * @param featureName the name of the feature to detach
  46256. */
  46257. detachFeature(featureName: string): void;
  46258. /**
  46259. * Used to disable an already-enabled feature
  46260. * The feature will be disposed and will be recreated once enabled.
  46261. * @param featureName the feature to disable
  46262. * @returns true if disable was successful
  46263. */
  46264. disableFeature(featureName: string | {
  46265. Name: string;
  46266. }): boolean;
  46267. /**
  46268. * dispose this features manager
  46269. */
  46270. dispose(): void;
  46271. /**
  46272. * 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.
  46273. * 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.
  46274. *
  46275. * @param featureName the name of the feature to load or the class of the feature
  46276. * @param version optional version to load. if not provided the latest version will be enabled
  46277. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  46278. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  46279. * @returns a new constructed feature or throws an error if feature not found.
  46280. */
  46281. enableFeature(featureName: string | {
  46282. Name: string;
  46283. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  46284. /**
  46285. * get the implementation of an enabled feature.
  46286. * @param featureName the name of the feature to load
  46287. * @returns the feature class, if found
  46288. */
  46289. getEnabledFeature(featureName: string): IWebXRFeature;
  46290. /**
  46291. * Get the list of enabled features
  46292. * @returns an array of enabled features
  46293. */
  46294. getEnabledFeatures(): string[];
  46295. }
  46296. }
  46297. declare module BABYLON {
  46298. /**
  46299. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  46300. * @see https://doc.babylonjs.com/how_to/webxr
  46301. */
  46302. export class WebXRExperienceHelper implements IDisposable {
  46303. private scene;
  46304. private _nonVRCamera;
  46305. private _originalSceneAutoClear;
  46306. private _supported;
  46307. /**
  46308. * Camera used to render xr content
  46309. */
  46310. camera: WebXRCamera;
  46311. /** A features manager for this xr session */
  46312. featuresManager: WebXRFeaturesManager;
  46313. /**
  46314. * Observers registered here will be triggered after the camera's initial transformation is set
  46315. * This can be used to set a different ground level or an extra rotation.
  46316. *
  46317. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  46318. * to the position set after this observable is done executing.
  46319. */
  46320. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  46321. /**
  46322. * Fires when the state of the experience helper has changed
  46323. */
  46324. onStateChangedObservable: Observable<WebXRState>;
  46325. /** Session manager used to keep track of xr session */
  46326. sessionManager: WebXRSessionManager;
  46327. /**
  46328. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  46329. */
  46330. state: WebXRState;
  46331. /**
  46332. * Creates a WebXRExperienceHelper
  46333. * @param scene The scene the helper should be created in
  46334. */
  46335. private constructor();
  46336. /**
  46337. * Creates the experience helper
  46338. * @param scene the scene to attach the experience helper to
  46339. * @returns a promise for the experience helper
  46340. */
  46341. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  46342. /**
  46343. * Disposes of the experience helper
  46344. */
  46345. dispose(): void;
  46346. /**
  46347. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  46348. * @param sessionMode options for the XR session
  46349. * @param referenceSpaceType frame of reference of the XR session
  46350. * @param renderTarget the output canvas that will be used to enter XR mode
  46351. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  46352. * @returns promise that resolves after xr mode has entered
  46353. */
  46354. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  46355. /**
  46356. * Exits XR mode and returns the scene to its original state
  46357. * @returns promise that resolves after xr mode has exited
  46358. */
  46359. exitXRAsync(): Promise<void>;
  46360. private _nonXRToXRCamera;
  46361. private _setState;
  46362. }
  46363. }
  46364. declare module BABYLON {
  46365. /**
  46366. * X-Y values for axes in WebXR
  46367. */
  46368. export interface IWebXRMotionControllerAxesValue {
  46369. /**
  46370. * The value of the x axis
  46371. */
  46372. x: number;
  46373. /**
  46374. * The value of the y-axis
  46375. */
  46376. y: number;
  46377. }
  46378. /**
  46379. * changed / previous values for the values of this component
  46380. */
  46381. export interface IWebXRMotionControllerComponentChangesValues<T> {
  46382. /**
  46383. * current (this frame) value
  46384. */
  46385. current: T;
  46386. /**
  46387. * previous (last change) value
  46388. */
  46389. previous: T;
  46390. }
  46391. /**
  46392. * Represents changes in the component between current frame and last values recorded
  46393. */
  46394. export interface IWebXRMotionControllerComponentChanges {
  46395. /**
  46396. * will be populated with previous and current values if axes changed
  46397. */
  46398. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  46399. /**
  46400. * will be populated with previous and current values if pressed changed
  46401. */
  46402. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46403. /**
  46404. * will be populated with previous and current values if touched changed
  46405. */
  46406. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46407. /**
  46408. * will be populated with previous and current values if value changed
  46409. */
  46410. value?: IWebXRMotionControllerComponentChangesValues<number>;
  46411. }
  46412. /**
  46413. * This class represents a single component (for example button or thumbstick) of a motion controller
  46414. */
  46415. export class WebXRControllerComponent implements IDisposable {
  46416. /**
  46417. * the id of this component
  46418. */
  46419. id: string;
  46420. /**
  46421. * the type of the component
  46422. */
  46423. type: MotionControllerComponentType;
  46424. private _buttonIndex;
  46425. private _axesIndices;
  46426. private _axes;
  46427. private _changes;
  46428. private _currentValue;
  46429. private _hasChanges;
  46430. private _pressed;
  46431. private _touched;
  46432. /**
  46433. * button component type
  46434. */
  46435. static BUTTON_TYPE: MotionControllerComponentType;
  46436. /**
  46437. * squeeze component type
  46438. */
  46439. static SQUEEZE_TYPE: MotionControllerComponentType;
  46440. /**
  46441. * Thumbstick component type
  46442. */
  46443. static THUMBSTICK_TYPE: MotionControllerComponentType;
  46444. /**
  46445. * Touchpad component type
  46446. */
  46447. static TOUCHPAD_TYPE: MotionControllerComponentType;
  46448. /**
  46449. * trigger component type
  46450. */
  46451. static TRIGGER_TYPE: MotionControllerComponentType;
  46452. /**
  46453. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  46454. * the axes data changes
  46455. */
  46456. onAxisValueChangedObservable: Observable<{
  46457. x: number;
  46458. y: number;
  46459. }>;
  46460. /**
  46461. * Observers registered here will be triggered when the state of a button changes
  46462. * State change is either pressed / touched / value
  46463. */
  46464. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  46465. /**
  46466. * Creates a new component for a motion controller.
  46467. * It is created by the motion controller itself
  46468. *
  46469. * @param id the id of this component
  46470. * @param type the type of the component
  46471. * @param _buttonIndex index in the buttons array of the gamepad
  46472. * @param _axesIndices indices of the values in the axes array of the gamepad
  46473. */
  46474. constructor(
  46475. /**
  46476. * the id of this component
  46477. */
  46478. id: string,
  46479. /**
  46480. * the type of the component
  46481. */
  46482. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  46483. /**
  46484. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  46485. */
  46486. get axes(): IWebXRMotionControllerAxesValue;
  46487. /**
  46488. * Get the changes. Elements will be populated only if they changed with their previous and current value
  46489. */
  46490. get changes(): IWebXRMotionControllerComponentChanges;
  46491. /**
  46492. * Return whether or not the component changed the last frame
  46493. */
  46494. get hasChanges(): boolean;
  46495. /**
  46496. * is the button currently pressed
  46497. */
  46498. get pressed(): boolean;
  46499. /**
  46500. * is the button currently touched
  46501. */
  46502. get touched(): boolean;
  46503. /**
  46504. * Get the current value of this component
  46505. */
  46506. get value(): number;
  46507. /**
  46508. * Dispose this component
  46509. */
  46510. dispose(): void;
  46511. /**
  46512. * Are there axes correlating to this component
  46513. * @return true is axes data is available
  46514. */
  46515. isAxes(): boolean;
  46516. /**
  46517. * Is this component a button (hence - pressable)
  46518. * @returns true if can be pressed
  46519. */
  46520. isButton(): boolean;
  46521. /**
  46522. * update this component using the gamepad object it is in. Called on every frame
  46523. * @param nativeController the native gamepad controller object
  46524. */
  46525. update(nativeController: IMinimalMotionControllerObject): void;
  46526. }
  46527. }
  46528. declare module BABYLON {
  46529. /**
  46530. * Interface used to represent data loading progression
  46531. */
  46532. export interface ISceneLoaderProgressEvent {
  46533. /**
  46534. * Defines if data length to load can be evaluated
  46535. */
  46536. readonly lengthComputable: boolean;
  46537. /**
  46538. * Defines the loaded data length
  46539. */
  46540. readonly loaded: number;
  46541. /**
  46542. * Defines the data length to load
  46543. */
  46544. readonly total: number;
  46545. }
  46546. /**
  46547. * Interface used by SceneLoader plugins to define supported file extensions
  46548. */
  46549. export interface ISceneLoaderPluginExtensions {
  46550. /**
  46551. * Defines the list of supported extensions
  46552. */
  46553. [extension: string]: {
  46554. isBinary: boolean;
  46555. };
  46556. }
  46557. /**
  46558. * Interface used by SceneLoader plugin factory
  46559. */
  46560. export interface ISceneLoaderPluginFactory {
  46561. /**
  46562. * Defines the name of the factory
  46563. */
  46564. name: string;
  46565. /**
  46566. * Function called to create a new plugin
  46567. * @return the new plugin
  46568. */
  46569. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  46570. /**
  46571. * The callback that returns true if the data can be directly loaded.
  46572. * @param data string containing the file data
  46573. * @returns if the data can be loaded directly
  46574. */
  46575. canDirectLoad?(data: string): boolean;
  46576. }
  46577. /**
  46578. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  46579. */
  46580. export interface ISceneLoaderPluginBase {
  46581. /**
  46582. * The friendly name of this plugin.
  46583. */
  46584. name: string;
  46585. /**
  46586. * The file extensions supported by this plugin.
  46587. */
  46588. extensions: string | ISceneLoaderPluginExtensions;
  46589. /**
  46590. * The callback called when loading from a url.
  46591. * @param scene scene loading this url
  46592. * @param url url to load
  46593. * @param onSuccess callback called when the file successfully loads
  46594. * @param onProgress callback called while file is loading (if the server supports this mode)
  46595. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  46596. * @param onError callback called when the file fails to load
  46597. * @returns a file request object
  46598. */
  46599. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46600. /**
  46601. * The callback called when loading from a file object.
  46602. * @param scene scene loading this file
  46603. * @param file defines the file to load
  46604. * @param onSuccess defines the callback to call when data is loaded
  46605. * @param onProgress defines the callback to call during loading process
  46606. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  46607. * @param onError defines the callback to call when an error occurs
  46608. * @returns a file request object
  46609. */
  46610. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46611. /**
  46612. * The callback that returns true if the data can be directly loaded.
  46613. * @param data string containing the file data
  46614. * @returns if the data can be loaded directly
  46615. */
  46616. canDirectLoad?(data: string): boolean;
  46617. /**
  46618. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  46619. * @param scene scene loading this data
  46620. * @param data string containing the data
  46621. * @returns data to pass to the plugin
  46622. */
  46623. directLoad?(scene: Scene, data: string): any;
  46624. /**
  46625. * The callback that allows custom handling of the root url based on the response url.
  46626. * @param rootUrl the original root url
  46627. * @param responseURL the response url if available
  46628. * @returns the new root url
  46629. */
  46630. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  46631. }
  46632. /**
  46633. * Interface used to define a SceneLoader plugin
  46634. */
  46635. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  46636. /**
  46637. * Import meshes into a scene.
  46638. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46639. * @param scene The scene to import into
  46640. * @param data The data to import
  46641. * @param rootUrl The root url for scene and resources
  46642. * @param meshes The meshes array to import into
  46643. * @param particleSystems The particle systems array to import into
  46644. * @param skeletons The skeletons array to import into
  46645. * @param onError The callback when import fails
  46646. * @returns True if successful or false otherwise
  46647. */
  46648. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  46649. /**
  46650. * Load into a scene.
  46651. * @param scene The scene to load into
  46652. * @param data The data to import
  46653. * @param rootUrl The root url for scene and resources
  46654. * @param onError The callback when import fails
  46655. * @returns True if successful or false otherwise
  46656. */
  46657. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  46658. /**
  46659. * Load into an asset container.
  46660. * @param scene The scene to load into
  46661. * @param data The data to import
  46662. * @param rootUrl The root url for scene and resources
  46663. * @param onError The callback when import fails
  46664. * @returns The loaded asset container
  46665. */
  46666. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  46667. }
  46668. /**
  46669. * Interface used to define an async SceneLoader plugin
  46670. */
  46671. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  46672. /**
  46673. * Import meshes into a scene.
  46674. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46675. * @param scene The scene to import into
  46676. * @param data The data to import
  46677. * @param rootUrl The root url for scene and resources
  46678. * @param onProgress The callback when the load progresses
  46679. * @param fileName Defines the name of the file to load
  46680. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  46681. */
  46682. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  46683. meshes: AbstractMesh[];
  46684. particleSystems: IParticleSystem[];
  46685. skeletons: Skeleton[];
  46686. animationGroups: AnimationGroup[];
  46687. }>;
  46688. /**
  46689. * Load into a scene.
  46690. * @param scene The scene to load into
  46691. * @param data The data to import
  46692. * @param rootUrl The root url for scene and resources
  46693. * @param onProgress The callback when the load progresses
  46694. * @param fileName Defines the name of the file to load
  46695. * @returns Nothing
  46696. */
  46697. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  46698. /**
  46699. * Load into an asset container.
  46700. * @param scene The scene to load into
  46701. * @param data The data to import
  46702. * @param rootUrl The root url for scene and resources
  46703. * @param onProgress The callback when the load progresses
  46704. * @param fileName Defines the name of the file to load
  46705. * @returns The loaded asset container
  46706. */
  46707. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  46708. }
  46709. /**
  46710. * Mode that determines how to handle old animation groups before loading new ones.
  46711. */
  46712. export enum SceneLoaderAnimationGroupLoadingMode {
  46713. /**
  46714. * Reset all old animations to initial state then dispose them.
  46715. */
  46716. Clean = 0,
  46717. /**
  46718. * Stop all old animations.
  46719. */
  46720. Stop = 1,
  46721. /**
  46722. * Restart old animations from first frame.
  46723. */
  46724. Sync = 2,
  46725. /**
  46726. * Old animations remains untouched.
  46727. */
  46728. NoSync = 3
  46729. }
  46730. /**
  46731. * Class used to load scene from various file formats using registered plugins
  46732. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  46733. */
  46734. export class SceneLoader {
  46735. /**
  46736. * No logging while loading
  46737. */
  46738. static readonly NO_LOGGING: number;
  46739. /**
  46740. * Minimal logging while loading
  46741. */
  46742. static readonly MINIMAL_LOGGING: number;
  46743. /**
  46744. * Summary logging while loading
  46745. */
  46746. static readonly SUMMARY_LOGGING: number;
  46747. /**
  46748. * Detailled logging while loading
  46749. */
  46750. static readonly DETAILED_LOGGING: number;
  46751. /**
  46752. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  46753. */
  46754. static get ForceFullSceneLoadingForIncremental(): boolean;
  46755. static set ForceFullSceneLoadingForIncremental(value: boolean);
  46756. /**
  46757. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  46758. */
  46759. static get ShowLoadingScreen(): boolean;
  46760. static set ShowLoadingScreen(value: boolean);
  46761. /**
  46762. * Defines the current logging level (while loading the scene)
  46763. * @ignorenaming
  46764. */
  46765. static get loggingLevel(): number;
  46766. static set loggingLevel(value: number);
  46767. /**
  46768. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  46769. */
  46770. static get CleanBoneMatrixWeights(): boolean;
  46771. static set CleanBoneMatrixWeights(value: boolean);
  46772. /**
  46773. * Event raised when a plugin is used to load a scene
  46774. */
  46775. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  46776. private static _registeredPlugins;
  46777. private static _getDefaultPlugin;
  46778. private static _getPluginForExtension;
  46779. private static _getPluginForDirectLoad;
  46780. private static _getPluginForFilename;
  46781. private static _getDirectLoad;
  46782. private static _loadData;
  46783. private static _getFileInfo;
  46784. /**
  46785. * Gets a plugin that can load the given extension
  46786. * @param extension defines the extension to load
  46787. * @returns a plugin or null if none works
  46788. */
  46789. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  46790. /**
  46791. * Gets a boolean indicating that the given extension can be loaded
  46792. * @param extension defines the extension to load
  46793. * @returns true if the extension is supported
  46794. */
  46795. static IsPluginForExtensionAvailable(extension: string): boolean;
  46796. /**
  46797. * Adds a new plugin to the list of registered plugins
  46798. * @param plugin defines the plugin to add
  46799. */
  46800. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  46801. /**
  46802. * Import meshes into a scene
  46803. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46804. * @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)
  46805. * @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)
  46806. * @param scene the instance of BABYLON.Scene to append to
  46807. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  46808. * @param onProgress a callback with a progress event for each file being loaded
  46809. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46810. * @param pluginExtension the extension used to determine the plugin
  46811. * @returns The loaded plugin
  46812. */
  46813. 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>;
  46814. /**
  46815. * Import meshes into a scene
  46816. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46817. * @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)
  46818. * @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)
  46819. * @param scene the instance of BABYLON.Scene to append to
  46820. * @param onProgress a callback with a progress event for each file being loaded
  46821. * @param pluginExtension the extension used to determine the plugin
  46822. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  46823. */
  46824. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  46825. meshes: AbstractMesh[];
  46826. particleSystems: IParticleSystem[];
  46827. skeletons: Skeleton[];
  46828. animationGroups: AnimationGroup[];
  46829. }>;
  46830. /**
  46831. * Load a scene
  46832. * @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)
  46833. * @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)
  46834. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46835. * @param onSuccess a callback with the scene when import succeeds
  46836. * @param onProgress a callback with a progress event for each file being loaded
  46837. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46838. * @param pluginExtension the extension used to determine the plugin
  46839. * @returns The loaded plugin
  46840. */
  46841. 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>;
  46842. /**
  46843. * Load a scene
  46844. * @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)
  46845. * @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)
  46846. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46847. * @param onProgress a callback with a progress event for each file being loaded
  46848. * @param pluginExtension the extension used to determine the plugin
  46849. * @returns The loaded scene
  46850. */
  46851. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  46852. /**
  46853. * Append a scene
  46854. * @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)
  46855. * @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)
  46856. * @param scene is the instance of BABYLON.Scene to append to
  46857. * @param onSuccess a callback with the scene when import succeeds
  46858. * @param onProgress a callback with a progress event for each file being loaded
  46859. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46860. * @param pluginExtension the extension used to determine the plugin
  46861. * @returns The loaded plugin
  46862. */
  46863. 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>;
  46864. /**
  46865. * Append a scene
  46866. * @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)
  46867. * @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)
  46868. * @param scene is the instance of BABYLON.Scene to append to
  46869. * @param onProgress a callback with a progress event for each file being loaded
  46870. * @param pluginExtension the extension used to determine the plugin
  46871. * @returns The given scene
  46872. */
  46873. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  46874. /**
  46875. * Load a scene into an asset container
  46876. * @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)
  46877. * @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)
  46878. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46879. * @param onSuccess a callback with the scene when import succeeds
  46880. * @param onProgress a callback with a progress event for each file being loaded
  46881. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46882. * @param pluginExtension the extension used to determine the plugin
  46883. * @returns The loaded plugin
  46884. */
  46885. 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>;
  46886. /**
  46887. * Load a scene into an asset container
  46888. * @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)
  46889. * @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)
  46890. * @param scene is the instance of Scene to append to
  46891. * @param onProgress a callback with a progress event for each file being loaded
  46892. * @param pluginExtension the extension used to determine the plugin
  46893. * @returns The loaded asset container
  46894. */
  46895. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  46896. /**
  46897. * Import animations from a file into a scene
  46898. * @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)
  46899. * @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)
  46900. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46901. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  46902. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  46903. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  46904. * @param onSuccess a callback with the scene when import succeeds
  46905. * @param onProgress a callback with a progress event for each file being loaded
  46906. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46907. */
  46908. 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>): void;
  46909. /**
  46910. * Import animations from a file into a scene
  46911. * @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)
  46912. * @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)
  46913. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46914. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  46915. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  46916. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  46917. * @param onSuccess a callback with the scene when import succeeds
  46918. * @param onProgress a callback with a progress event for each file being loaded
  46919. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46920. * @returns the updated scene with imported animations
  46921. */
  46922. 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>): Promise<Scene>;
  46923. }
  46924. }
  46925. declare module BABYLON {
  46926. /**
  46927. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  46928. */
  46929. export type MotionControllerHandedness = "none" | "left" | "right";
  46930. /**
  46931. * The type of components available in motion controllers.
  46932. * This is not the name of the component.
  46933. */
  46934. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  46935. /**
  46936. * The state of a controller component
  46937. */
  46938. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  46939. /**
  46940. * The schema of motion controller layout.
  46941. * No object will be initialized using this interface
  46942. * This is used just to define the profile.
  46943. */
  46944. export interface IMotionControllerLayout {
  46945. /**
  46946. * Path to load the assets. Usually relative to the base path
  46947. */
  46948. assetPath: string;
  46949. /**
  46950. * Available components (unsorted)
  46951. */
  46952. components: {
  46953. /**
  46954. * A map of component Ids
  46955. */
  46956. [componentId: string]: {
  46957. /**
  46958. * The type of input the component outputs
  46959. */
  46960. type: MotionControllerComponentType;
  46961. /**
  46962. * The indices of this component in the gamepad object
  46963. */
  46964. gamepadIndices: {
  46965. /**
  46966. * Index of button
  46967. */
  46968. button?: number;
  46969. /**
  46970. * If available, index of x-axis
  46971. */
  46972. xAxis?: number;
  46973. /**
  46974. * If available, index of y-axis
  46975. */
  46976. yAxis?: number;
  46977. };
  46978. /**
  46979. * The mesh's root node name
  46980. */
  46981. rootNodeName: string;
  46982. /**
  46983. * Animation definitions for this model
  46984. */
  46985. visualResponses: {
  46986. [stateKey: string]: {
  46987. /**
  46988. * What property will be animated
  46989. */
  46990. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  46991. /**
  46992. * What states influence this visual response
  46993. */
  46994. states: MotionControllerComponentStateType[];
  46995. /**
  46996. * Type of animation - movement or visibility
  46997. */
  46998. valueNodeProperty: "transform" | "visibility";
  46999. /**
  47000. * Base node name to move. Its position will be calculated according to the min and max nodes
  47001. */
  47002. valueNodeName?: string;
  47003. /**
  47004. * Minimum movement node
  47005. */
  47006. minNodeName?: string;
  47007. /**
  47008. * Max movement node
  47009. */
  47010. maxNodeName?: string;
  47011. };
  47012. };
  47013. /**
  47014. * If touch enabled, what is the name of node to display user feedback
  47015. */
  47016. touchPointNodeName?: string;
  47017. };
  47018. };
  47019. /**
  47020. * Is it xr standard mapping or not
  47021. */
  47022. gamepadMapping: "" | "xr-standard";
  47023. /**
  47024. * Base root node of this entire model
  47025. */
  47026. rootNodeName: string;
  47027. /**
  47028. * Defines the main button component id
  47029. */
  47030. selectComponentId: string;
  47031. }
  47032. /**
  47033. * A definition for the layout map in the input profile
  47034. */
  47035. export interface IMotionControllerLayoutMap {
  47036. /**
  47037. * Layouts with handedness type as a key
  47038. */
  47039. [handedness: string]: IMotionControllerLayout;
  47040. }
  47041. /**
  47042. * The XR Input profile schema
  47043. * Profiles can be found here:
  47044. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  47045. */
  47046. export interface IMotionControllerProfile {
  47047. /**
  47048. * fallback profiles for this profileId
  47049. */
  47050. fallbackProfileIds: string[];
  47051. /**
  47052. * The layout map, with handedness as key
  47053. */
  47054. layouts: IMotionControllerLayoutMap;
  47055. /**
  47056. * The id of this profile
  47057. * correlates to the profile(s) in the xrInput.profiles array
  47058. */
  47059. profileId: string;
  47060. }
  47061. /**
  47062. * A helper-interface for the 3 meshes needed for controller button animation
  47063. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  47064. */
  47065. export interface IMotionControllerButtonMeshMap {
  47066. /**
  47067. * the mesh that defines the pressed value mesh position.
  47068. * This is used to find the max-position of this button
  47069. */
  47070. pressedMesh: AbstractMesh;
  47071. /**
  47072. * the mesh that defines the unpressed value mesh position.
  47073. * This is used to find the min (or initial) position of this button
  47074. */
  47075. unpressedMesh: AbstractMesh;
  47076. /**
  47077. * The mesh that will be changed when value changes
  47078. */
  47079. valueMesh: AbstractMesh;
  47080. }
  47081. /**
  47082. * A helper-interface for the 3 meshes needed for controller axis animation.
  47083. * This will be expanded when touchpad animations are fully supported
  47084. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  47085. */
  47086. export interface IMotionControllerMeshMap {
  47087. /**
  47088. * the mesh that defines the maximum value mesh position.
  47089. */
  47090. maxMesh?: AbstractMesh;
  47091. /**
  47092. * the mesh that defines the minimum value mesh position.
  47093. */
  47094. minMesh?: AbstractMesh;
  47095. /**
  47096. * The mesh that will be changed when axis value changes
  47097. */
  47098. valueMesh: AbstractMesh;
  47099. }
  47100. /**
  47101. * The elements needed for change-detection of the gamepad objects in motion controllers
  47102. */
  47103. export interface IMinimalMotionControllerObject {
  47104. /**
  47105. * Available axes of this controller
  47106. */
  47107. axes: number[];
  47108. /**
  47109. * An array of available buttons
  47110. */
  47111. buttons: Array<{
  47112. /**
  47113. * Value of the button/trigger
  47114. */
  47115. value: number;
  47116. /**
  47117. * If the button/trigger is currently touched
  47118. */
  47119. touched: boolean;
  47120. /**
  47121. * If the button/trigger is currently pressed
  47122. */
  47123. pressed: boolean;
  47124. }>;
  47125. /**
  47126. * EXPERIMENTAL haptic support.
  47127. */
  47128. hapticActuators?: Array<{
  47129. pulse: (value: number, duration: number) => Promise<boolean>;
  47130. }>;
  47131. }
  47132. /**
  47133. * An Abstract Motion controller
  47134. * This class receives an xrInput and a profile layout and uses those to initialize the components
  47135. * Each component has an observable to check for changes in value and state
  47136. */
  47137. export abstract class WebXRAbstractMotionController implements IDisposable {
  47138. protected scene: Scene;
  47139. protected layout: IMotionControllerLayout;
  47140. /**
  47141. * The gamepad object correlating to this controller
  47142. */
  47143. gamepadObject: IMinimalMotionControllerObject;
  47144. /**
  47145. * handedness (left/right/none) of this controller
  47146. */
  47147. handedness: MotionControllerHandedness;
  47148. private _initComponent;
  47149. private _modelReady;
  47150. /**
  47151. * A map of components (WebXRControllerComponent) in this motion controller
  47152. * Components have a ComponentType and can also have both button and axis definitions
  47153. */
  47154. readonly components: {
  47155. [id: string]: WebXRControllerComponent;
  47156. };
  47157. /**
  47158. * Disable the model's animation. Can be set at any time.
  47159. */
  47160. disableAnimation: boolean;
  47161. /**
  47162. * Observers registered here will be triggered when the model of this controller is done loading
  47163. */
  47164. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  47165. /**
  47166. * The profile id of this motion controller
  47167. */
  47168. abstract profileId: string;
  47169. /**
  47170. * The root mesh of the model. It is null if the model was not yet initialized
  47171. */
  47172. rootMesh: Nullable<AbstractMesh>;
  47173. /**
  47174. * constructs a new abstract motion controller
  47175. * @param scene the scene to which the model of the controller will be added
  47176. * @param layout The profile layout to load
  47177. * @param gamepadObject The gamepad object correlating to this controller
  47178. * @param handedness handedness (left/right/none) of this controller
  47179. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  47180. */
  47181. constructor(scene: Scene, layout: IMotionControllerLayout,
  47182. /**
  47183. * The gamepad object correlating to this controller
  47184. */
  47185. gamepadObject: IMinimalMotionControllerObject,
  47186. /**
  47187. * handedness (left/right/none) of this controller
  47188. */
  47189. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  47190. /**
  47191. * Dispose this controller, the model mesh and all its components
  47192. */
  47193. dispose(): void;
  47194. /**
  47195. * Returns all components of specific type
  47196. * @param type the type to search for
  47197. * @return an array of components with this type
  47198. */
  47199. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  47200. /**
  47201. * get a component based an its component id as defined in layout.components
  47202. * @param id the id of the component
  47203. * @returns the component correlates to the id or undefined if not found
  47204. */
  47205. getComponent(id: string): WebXRControllerComponent;
  47206. /**
  47207. * Get the list of components available in this motion controller
  47208. * @returns an array of strings correlating to available components
  47209. */
  47210. getComponentIds(): string[];
  47211. /**
  47212. * Get the first component of specific type
  47213. * @param type type of component to find
  47214. * @return a controller component or null if not found
  47215. */
  47216. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  47217. /**
  47218. * Get the main (Select) component of this controller as defined in the layout
  47219. * @returns the main component of this controller
  47220. */
  47221. getMainComponent(): WebXRControllerComponent;
  47222. /**
  47223. * Loads the model correlating to this controller
  47224. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  47225. * @returns A promise fulfilled with the result of the model loading
  47226. */
  47227. loadModel(): Promise<boolean>;
  47228. /**
  47229. * Update this model using the current XRFrame
  47230. * @param xrFrame the current xr frame to use and update the model
  47231. */
  47232. updateFromXRFrame(xrFrame: XRFrame): void;
  47233. /**
  47234. * Backwards compatibility due to a deeply-integrated typo
  47235. */
  47236. get handness(): XREye;
  47237. /**
  47238. * Pulse (vibrate) this controller
  47239. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  47240. * Consecutive calls to this function will cancel the last pulse call
  47241. *
  47242. * @param value the strength of the pulse in 0.0...1.0 range
  47243. * @param duration Duration of the pulse in milliseconds
  47244. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  47245. * @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
  47246. */
  47247. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  47248. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  47249. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  47250. /**
  47251. * Moves the axis on the controller mesh based on its current state
  47252. * @param axis the index of the axis
  47253. * @param axisValue the value of the axis which determines the meshes new position
  47254. * @hidden
  47255. */
  47256. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  47257. /**
  47258. * Update the model itself with the current frame data
  47259. * @param xrFrame the frame to use for updating the model mesh
  47260. */
  47261. protected updateModel(xrFrame: XRFrame): void;
  47262. /**
  47263. * Get the filename and path for this controller's model
  47264. * @returns a map of filename and path
  47265. */
  47266. protected abstract _getFilenameAndPath(): {
  47267. filename: string;
  47268. path: string;
  47269. };
  47270. /**
  47271. * This function is called before the mesh is loaded. It checks for loading constraints.
  47272. * For example, this function can check if the GLB loader is available
  47273. * If this function returns false, the generic controller will be loaded instead
  47274. * @returns Is the client ready to load the mesh
  47275. */
  47276. protected abstract _getModelLoadingConstraints(): boolean;
  47277. /**
  47278. * This function will be called after the model was successfully loaded and can be used
  47279. * for mesh transformations before it is available for the user
  47280. * @param meshes the loaded meshes
  47281. */
  47282. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  47283. /**
  47284. * Set the root mesh for this controller. Important for the WebXR controller class
  47285. * @param meshes the loaded meshes
  47286. */
  47287. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  47288. /**
  47289. * A function executed each frame that updates the mesh (if needed)
  47290. * @param xrFrame the current xrFrame
  47291. */
  47292. protected abstract _updateModel(xrFrame: XRFrame): void;
  47293. private _getGenericFilenameAndPath;
  47294. private _getGenericParentMesh;
  47295. }
  47296. }
  47297. declare module BABYLON {
  47298. /**
  47299. * A generic trigger-only motion controller for WebXR
  47300. */
  47301. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  47302. /**
  47303. * Static version of the profile id of this controller
  47304. */
  47305. static ProfileId: string;
  47306. profileId: string;
  47307. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  47308. protected _getFilenameAndPath(): {
  47309. filename: string;
  47310. path: string;
  47311. };
  47312. protected _getModelLoadingConstraints(): boolean;
  47313. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  47314. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47315. protected _updateModel(): void;
  47316. }
  47317. }
  47318. declare module BABYLON {
  47319. /**
  47320. * Class containing static functions to help procedurally build meshes
  47321. */
  47322. export class SphereBuilder {
  47323. /**
  47324. * Creates a sphere mesh
  47325. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  47326. * * 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`)
  47327. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  47328. * * 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
  47329. * * 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)
  47330. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47331. * * 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
  47332. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47333. * @param name defines the name of the mesh
  47334. * @param options defines the options used to create the mesh
  47335. * @param scene defines the hosting scene
  47336. * @returns the sphere mesh
  47337. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  47338. */
  47339. static CreateSphere(name: string, options: {
  47340. segments?: number;
  47341. diameter?: number;
  47342. diameterX?: number;
  47343. diameterY?: number;
  47344. diameterZ?: number;
  47345. arc?: number;
  47346. slice?: number;
  47347. sideOrientation?: number;
  47348. frontUVs?: Vector4;
  47349. backUVs?: Vector4;
  47350. updatable?: boolean;
  47351. }, scene?: Nullable<Scene>): Mesh;
  47352. }
  47353. }
  47354. declare module BABYLON {
  47355. /**
  47356. * A profiled motion controller has its profile loaded from an online repository.
  47357. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  47358. */
  47359. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  47360. private _repositoryUrl;
  47361. private _buttonMeshMapping;
  47362. private _touchDots;
  47363. /**
  47364. * The profile ID of this controller. Will be populated when the controller initializes.
  47365. */
  47366. profileId: string;
  47367. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  47368. dispose(): void;
  47369. protected _getFilenameAndPath(): {
  47370. filename: string;
  47371. path: string;
  47372. };
  47373. protected _getModelLoadingConstraints(): boolean;
  47374. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  47375. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47376. protected _updateModel(_xrFrame: XRFrame): void;
  47377. }
  47378. }
  47379. declare module BABYLON {
  47380. /**
  47381. * A construction function type to create a new controller based on an xrInput object
  47382. */
  47383. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  47384. /**
  47385. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  47386. *
  47387. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  47388. * it should be replaced with auto-loaded controllers.
  47389. *
  47390. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  47391. */
  47392. export class WebXRMotionControllerManager {
  47393. private static _AvailableControllers;
  47394. private static _Fallbacks;
  47395. private static _ProfileLoadingPromises;
  47396. private static _ProfilesList;
  47397. /**
  47398. * The base URL of the online controller repository. Can be changed at any time.
  47399. */
  47400. static BaseRepositoryUrl: string;
  47401. /**
  47402. * Which repository gets priority - local or online
  47403. */
  47404. static PrioritizeOnlineRepository: boolean;
  47405. /**
  47406. * Use the online repository, or use only locally-defined controllers
  47407. */
  47408. static UseOnlineRepository: boolean;
  47409. /**
  47410. * Clear the cache used for profile loading and reload when requested again
  47411. */
  47412. static ClearProfilesCache(): void;
  47413. /**
  47414. * Register the default fallbacks.
  47415. * This function is called automatically when this file is imported.
  47416. */
  47417. static DefaultFallbacks(): void;
  47418. /**
  47419. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  47420. * @param profileId the profile to which a fallback needs to be found
  47421. * @return an array with corresponding fallback profiles
  47422. */
  47423. static FindFallbackWithProfileId(profileId: string): string[];
  47424. /**
  47425. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  47426. * The order of search:
  47427. *
  47428. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  47429. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  47430. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  47431. * 4) return the generic trigger controller if none were found
  47432. *
  47433. * @param xrInput the xrInput to which a new controller is initialized
  47434. * @param scene the scene to which the model will be added
  47435. * @param forceProfile force a certain profile for this controller
  47436. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  47437. */
  47438. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  47439. /**
  47440. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  47441. *
  47442. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  47443. *
  47444. * @param type the profile type to register
  47445. * @param constructFunction the function to be called when loading this profile
  47446. */
  47447. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  47448. /**
  47449. * Register a fallback to a specific profile.
  47450. * @param profileId the profileId that will receive the fallbacks
  47451. * @param fallbacks A list of fallback profiles
  47452. */
  47453. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  47454. /**
  47455. * Will update the list of profiles available in the repository
  47456. * @return a promise that resolves to a map of profiles available online
  47457. */
  47458. static UpdateProfilesList(): Promise<{
  47459. [profile: string]: string;
  47460. }>;
  47461. private static _LoadProfileFromRepository;
  47462. private static _LoadProfilesFromAvailableControllers;
  47463. }
  47464. }
  47465. declare module BABYLON {
  47466. /**
  47467. * Configuration options for the WebXR controller creation
  47468. */
  47469. export interface IWebXRControllerOptions {
  47470. /**
  47471. * Should the controller mesh be animated when a user interacts with it
  47472. * The pressed buttons / thumbstick and touchpad animations will be disabled
  47473. */
  47474. disableMotionControllerAnimation?: boolean;
  47475. /**
  47476. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  47477. */
  47478. doNotLoadControllerMesh?: boolean;
  47479. /**
  47480. * Force a specific controller type for this controller.
  47481. * This can be used when creating your own profile or when testing different controllers
  47482. */
  47483. forceControllerProfile?: string;
  47484. /**
  47485. * Defines a rendering group ID for meshes that will be loaded.
  47486. * This is for the default controllers only.
  47487. */
  47488. renderingGroupId?: number;
  47489. }
  47490. /**
  47491. * Represents an XR controller
  47492. */
  47493. export class WebXRInputSource {
  47494. private _scene;
  47495. /** The underlying input source for the controller */
  47496. inputSource: XRInputSource;
  47497. private _options;
  47498. private _tmpVector;
  47499. private _uniqueId;
  47500. /**
  47501. * 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
  47502. */
  47503. grip?: AbstractMesh;
  47504. /**
  47505. * If available, this is the gamepad object related to this controller.
  47506. * Using this object it is possible to get click events and trackpad changes of the
  47507. * webxr controller that is currently being used.
  47508. */
  47509. motionController?: WebXRAbstractMotionController;
  47510. /**
  47511. * Event that fires when the controller is removed/disposed.
  47512. * The object provided as event data is this controller, after associated assets were disposed.
  47513. * uniqueId is still available.
  47514. */
  47515. onDisposeObservable: Observable<WebXRInputSource>;
  47516. /**
  47517. * Will be triggered when the mesh associated with the motion controller is done loading.
  47518. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  47519. * A shortened version of controller -> motion controller -> on mesh loaded.
  47520. */
  47521. onMeshLoadedObservable: Observable<AbstractMesh>;
  47522. /**
  47523. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  47524. */
  47525. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  47526. /**
  47527. * Pointer which can be used to select objects or attach a visible laser to
  47528. */
  47529. pointer: AbstractMesh;
  47530. /**
  47531. * Creates the controller
  47532. * @see https://doc.babylonjs.com/how_to/webxr
  47533. * @param _scene the scene which the controller should be associated to
  47534. * @param inputSource the underlying input source for the controller
  47535. * @param _options options for this controller creation
  47536. */
  47537. constructor(_scene: Scene,
  47538. /** The underlying input source for the controller */
  47539. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  47540. /**
  47541. * Get this controllers unique id
  47542. */
  47543. get uniqueId(): string;
  47544. /**
  47545. * Disposes of the object
  47546. */
  47547. dispose(): void;
  47548. /**
  47549. * Gets a world space ray coming from the pointer or grip
  47550. * @param result the resulting ray
  47551. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  47552. */
  47553. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  47554. /**
  47555. * Updates the controller pose based on the given XRFrame
  47556. * @param xrFrame xr frame to update the pose with
  47557. * @param referenceSpace reference space to use
  47558. */
  47559. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  47560. }
  47561. }
  47562. declare module BABYLON {
  47563. /**
  47564. * The schema for initialization options of the XR Input class
  47565. */
  47566. export interface IWebXRInputOptions {
  47567. /**
  47568. * If set to true no model will be automatically loaded
  47569. */
  47570. doNotLoadControllerMeshes?: boolean;
  47571. /**
  47572. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  47573. * If not found, the xr input profile data will be used.
  47574. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  47575. */
  47576. forceInputProfile?: string;
  47577. /**
  47578. * Do not send a request to the controller repository to load the profile.
  47579. *
  47580. * Instead, use the controllers available in babylon itself.
  47581. */
  47582. disableOnlineControllerRepository?: boolean;
  47583. /**
  47584. * A custom URL for the controllers repository
  47585. */
  47586. customControllersRepositoryURL?: string;
  47587. /**
  47588. * Should the controller model's components not move according to the user input
  47589. */
  47590. disableControllerAnimation?: boolean;
  47591. /**
  47592. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  47593. */
  47594. controllerOptions?: IWebXRControllerOptions;
  47595. }
  47596. /**
  47597. * XR input used to track XR inputs such as controllers/rays
  47598. */
  47599. export class WebXRInput implements IDisposable {
  47600. /**
  47601. * the xr session manager for this session
  47602. */
  47603. xrSessionManager: WebXRSessionManager;
  47604. /**
  47605. * the WebXR camera for this session. Mainly used for teleportation
  47606. */
  47607. xrCamera: WebXRCamera;
  47608. private readonly options;
  47609. /**
  47610. * XR controllers being tracked
  47611. */
  47612. controllers: Array<WebXRInputSource>;
  47613. private _frameObserver;
  47614. private _sessionEndedObserver;
  47615. private _sessionInitObserver;
  47616. /**
  47617. * Event when a controller has been connected/added
  47618. */
  47619. onControllerAddedObservable: Observable<WebXRInputSource>;
  47620. /**
  47621. * Event when a controller has been removed/disconnected
  47622. */
  47623. onControllerRemovedObservable: Observable<WebXRInputSource>;
  47624. /**
  47625. * Initializes the WebXRInput
  47626. * @param xrSessionManager the xr session manager for this session
  47627. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  47628. * @param options = initialization options for this xr input
  47629. */
  47630. constructor(
  47631. /**
  47632. * the xr session manager for this session
  47633. */
  47634. xrSessionManager: WebXRSessionManager,
  47635. /**
  47636. * the WebXR camera for this session. Mainly used for teleportation
  47637. */
  47638. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  47639. private _onInputSourcesChange;
  47640. private _addAndRemoveControllers;
  47641. /**
  47642. * Disposes of the object
  47643. */
  47644. dispose(): void;
  47645. }
  47646. }
  47647. declare module BABYLON {
  47648. /**
  47649. * This is the base class for all WebXR features.
  47650. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  47651. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  47652. */
  47653. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  47654. protected _xrSessionManager: WebXRSessionManager;
  47655. private _attached;
  47656. private _removeOnDetach;
  47657. /**
  47658. * Should auto-attach be disabled?
  47659. */
  47660. disableAutoAttach: boolean;
  47661. /**
  47662. * Construct a new (abstract) WebXR feature
  47663. * @param _xrSessionManager the xr session manager for this feature
  47664. */
  47665. constructor(_xrSessionManager: WebXRSessionManager);
  47666. /**
  47667. * Is this feature attached
  47668. */
  47669. get attached(): boolean;
  47670. /**
  47671. * attach this feature
  47672. *
  47673. * @param force should attachment be forced (even when already attached)
  47674. * @returns true if successful, false is failed or already attached
  47675. */
  47676. attach(force?: boolean): boolean;
  47677. /**
  47678. * detach this feature.
  47679. *
  47680. * @returns true if successful, false if failed or already detached
  47681. */
  47682. detach(): boolean;
  47683. /**
  47684. * Dispose this feature and all of the resources attached
  47685. */
  47686. dispose(): void;
  47687. /**
  47688. * This is used to register callbacks that will automatically be removed when detach is called.
  47689. * @param observable the observable to which the observer will be attached
  47690. * @param callback the callback to register
  47691. */
  47692. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  47693. /**
  47694. * Code in this function will be executed on each xrFrame received from the browser.
  47695. * This function will not execute after the feature is detached.
  47696. * @param _xrFrame the current frame
  47697. */
  47698. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  47699. }
  47700. }
  47701. declare module BABYLON {
  47702. /**
  47703. * Renders a layer on top of an existing scene
  47704. */
  47705. export class UtilityLayerRenderer implements IDisposable {
  47706. /** the original scene that will be rendered on top of */
  47707. originalScene: Scene;
  47708. private _pointerCaptures;
  47709. private _lastPointerEvents;
  47710. private static _DefaultUtilityLayer;
  47711. private static _DefaultKeepDepthUtilityLayer;
  47712. private _sharedGizmoLight;
  47713. private _renderCamera;
  47714. /**
  47715. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  47716. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  47717. * @returns the camera that is used when rendering the utility layer
  47718. */
  47719. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  47720. /**
  47721. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  47722. * @param cam the camera that should be used when rendering the utility layer
  47723. */
  47724. setRenderCamera(cam: Nullable<Camera>): void;
  47725. /**
  47726. * @hidden
  47727. * Light which used by gizmos to get light shading
  47728. */
  47729. _getSharedGizmoLight(): HemisphericLight;
  47730. /**
  47731. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  47732. */
  47733. pickUtilitySceneFirst: boolean;
  47734. /**
  47735. * 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)
  47736. */
  47737. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  47738. /**
  47739. * 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)
  47740. */
  47741. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  47742. /**
  47743. * The scene that is rendered on top of the original scene
  47744. */
  47745. utilityLayerScene: Scene;
  47746. /**
  47747. * If the utility layer should automatically be rendered on top of existing scene
  47748. */
  47749. shouldRender: boolean;
  47750. /**
  47751. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  47752. */
  47753. onlyCheckPointerDownEvents: boolean;
  47754. /**
  47755. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  47756. */
  47757. processAllEvents: boolean;
  47758. /**
  47759. * Observable raised when the pointer move from the utility layer scene to the main scene
  47760. */
  47761. onPointerOutObservable: Observable<number>;
  47762. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  47763. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  47764. private _afterRenderObserver;
  47765. private _sceneDisposeObserver;
  47766. private _originalPointerObserver;
  47767. /**
  47768. * Instantiates a UtilityLayerRenderer
  47769. * @param originalScene the original scene that will be rendered on top of
  47770. * @param handleEvents boolean indicating if the utility layer should handle events
  47771. */
  47772. constructor(
  47773. /** the original scene that will be rendered on top of */
  47774. originalScene: Scene, handleEvents?: boolean);
  47775. private _notifyObservers;
  47776. /**
  47777. * Renders the utility layers scene on top of the original scene
  47778. */
  47779. render(): void;
  47780. /**
  47781. * Disposes of the renderer
  47782. */
  47783. dispose(): void;
  47784. private _updateCamera;
  47785. }
  47786. }
  47787. declare module BABYLON {
  47788. /**
  47789. * Options interface for the pointer selection module
  47790. */
  47791. export interface IWebXRControllerPointerSelectionOptions {
  47792. /**
  47793. * if provided, this scene will be used to render meshes.
  47794. */
  47795. customUtilityLayerScene?: Scene;
  47796. /**
  47797. * 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)
  47798. * If not disabled, the last picked point will be used to execute a pointer up event
  47799. * If disabled, pointer up event will be triggered right after the pointer down event.
  47800. * Used in screen and gaze target ray mode only
  47801. */
  47802. disablePointerUpOnTouchOut: boolean;
  47803. /**
  47804. * For gaze mode (time to select instead of press)
  47805. */
  47806. forceGazeMode: boolean;
  47807. /**
  47808. * 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
  47809. * to start a new countdown to the pointer down event.
  47810. * Defaults to 1.
  47811. */
  47812. gazeModePointerMovedFactor?: number;
  47813. /**
  47814. * Different button type to use instead of the main component
  47815. */
  47816. overrideButtonId?: string;
  47817. /**
  47818. * use this rendering group id for the meshes (optional)
  47819. */
  47820. renderingGroupId?: number;
  47821. /**
  47822. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  47823. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  47824. * 3000 means 3 seconds between pointing at something and selecting it
  47825. */
  47826. timeToSelect?: number;
  47827. /**
  47828. * Should meshes created here be added to a utility layer or the main scene
  47829. */
  47830. useUtilityLayer?: boolean;
  47831. /**
  47832. * the xr input to use with this pointer selection
  47833. */
  47834. xrInput: WebXRInput;
  47835. }
  47836. /**
  47837. * A module that will enable pointer selection for motion controllers of XR Input Sources
  47838. */
  47839. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  47840. private readonly _options;
  47841. private static _idCounter;
  47842. private _attachController;
  47843. private _controllers;
  47844. private _scene;
  47845. private _tmpVectorForPickCompare;
  47846. /**
  47847. * The module's name
  47848. */
  47849. static readonly Name: string;
  47850. /**
  47851. * The (Babylon) version of this module.
  47852. * This is an integer representing the implementation version.
  47853. * This number does not correspond to the WebXR specs version
  47854. */
  47855. static readonly Version: number;
  47856. /**
  47857. * Disable lighting on the laser pointer (so it will always be visible)
  47858. */
  47859. disablePointerLighting: boolean;
  47860. /**
  47861. * Disable lighting on the selection mesh (so it will always be visible)
  47862. */
  47863. disableSelectionMeshLighting: boolean;
  47864. /**
  47865. * Should the laser pointer be displayed
  47866. */
  47867. displayLaserPointer: boolean;
  47868. /**
  47869. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  47870. */
  47871. displaySelectionMesh: boolean;
  47872. /**
  47873. * This color will be set to the laser pointer when selection is triggered
  47874. */
  47875. laserPointerPickedColor: Color3;
  47876. /**
  47877. * Default color of the laser pointer
  47878. */
  47879. laserPointerDefaultColor: Color3;
  47880. /**
  47881. * default color of the selection ring
  47882. */
  47883. selectionMeshDefaultColor: Color3;
  47884. /**
  47885. * This color will be applied to the selection ring when selection is triggered
  47886. */
  47887. selectionMeshPickedColor: Color3;
  47888. /**
  47889. * Optional filter to be used for ray selection. This predicate shares behavior with
  47890. * scene.pointerMovePredicate which takes priority if it is also assigned.
  47891. */
  47892. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  47893. /**
  47894. * constructs a new background remover module
  47895. * @param _xrSessionManager the session manager for this module
  47896. * @param _options read-only options to be used in this module
  47897. */
  47898. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  47899. /**
  47900. * attach this feature
  47901. * Will usually be called by the features manager
  47902. *
  47903. * @returns true if successful.
  47904. */
  47905. attach(): boolean;
  47906. /**
  47907. * detach this feature.
  47908. * Will usually be called by the features manager
  47909. *
  47910. * @returns true if successful.
  47911. */
  47912. detach(): boolean;
  47913. /**
  47914. * Will get the mesh under a specific pointer.
  47915. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  47916. * @param controllerId the controllerId to check
  47917. * @returns The mesh under pointer or null if no mesh is under the pointer
  47918. */
  47919. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  47920. /**
  47921. * Get the xr controller that correlates to the pointer id in the pointer event
  47922. *
  47923. * @param id the pointer id to search for
  47924. * @returns the controller that correlates to this id or null if not found
  47925. */
  47926. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  47927. protected _onXRFrame(_xrFrame: XRFrame): void;
  47928. private _attachGazeMode;
  47929. private _attachScreenRayMode;
  47930. private _attachTrackedPointerRayMode;
  47931. private _convertNormalToDirectionOfRay;
  47932. private _detachController;
  47933. private _generateNewMeshPair;
  47934. private _pickingMoved;
  47935. private _updatePointerDistance;
  47936. /** @hidden */
  47937. get lasterPointerDefaultColor(): Color3;
  47938. }
  47939. }
  47940. declare module BABYLON {
  47941. /**
  47942. * Button which can be used to enter a different mode of XR
  47943. */
  47944. export class WebXREnterExitUIButton {
  47945. /** button element */
  47946. element: HTMLElement;
  47947. /** XR initialization options for the button */
  47948. sessionMode: XRSessionMode;
  47949. /** Reference space type */
  47950. referenceSpaceType: XRReferenceSpaceType;
  47951. /**
  47952. * Creates a WebXREnterExitUIButton
  47953. * @param element button element
  47954. * @param sessionMode XR initialization session mode
  47955. * @param referenceSpaceType the type of reference space to be used
  47956. */
  47957. constructor(
  47958. /** button element */
  47959. element: HTMLElement,
  47960. /** XR initialization options for the button */
  47961. sessionMode: XRSessionMode,
  47962. /** Reference space type */
  47963. referenceSpaceType: XRReferenceSpaceType);
  47964. /**
  47965. * Extendable function which can be used to update the button's visuals when the state changes
  47966. * @param activeButton the current active button in the UI
  47967. */
  47968. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  47969. }
  47970. /**
  47971. * Options to create the webXR UI
  47972. */
  47973. export class WebXREnterExitUIOptions {
  47974. /**
  47975. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  47976. */
  47977. customButtons?: Array<WebXREnterExitUIButton>;
  47978. /**
  47979. * A reference space type to use when creating the default button.
  47980. * Default is local-floor
  47981. */
  47982. referenceSpaceType?: XRReferenceSpaceType;
  47983. /**
  47984. * Context to enter xr with
  47985. */
  47986. renderTarget?: Nullable<WebXRRenderTarget>;
  47987. /**
  47988. * A session mode to use when creating the default button.
  47989. * Default is immersive-vr
  47990. */
  47991. sessionMode?: XRSessionMode;
  47992. /**
  47993. * A list of optional features to init the session with
  47994. */
  47995. optionalFeatures?: string[];
  47996. }
  47997. /**
  47998. * UI to allow the user to enter/exit XR mode
  47999. */
  48000. export class WebXREnterExitUI implements IDisposable {
  48001. private scene;
  48002. /** version of the options passed to this UI */
  48003. options: WebXREnterExitUIOptions;
  48004. private _activeButton;
  48005. private _buttons;
  48006. private _overlay;
  48007. /**
  48008. * Fired every time the active button is changed.
  48009. *
  48010. * When xr is entered via a button that launches xr that button will be the callback parameter
  48011. *
  48012. * When exiting xr the callback parameter will be null)
  48013. */
  48014. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  48015. /**
  48016. *
  48017. * @param scene babylon scene object to use
  48018. * @param options (read-only) version of the options passed to this UI
  48019. */
  48020. private constructor();
  48021. /**
  48022. * Creates UI to allow the user to enter/exit XR mode
  48023. * @param scene the scene to add the ui to
  48024. * @param helper the xr experience helper to enter/exit xr with
  48025. * @param options options to configure the UI
  48026. * @returns the created ui
  48027. */
  48028. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  48029. /**
  48030. * Disposes of the XR UI component
  48031. */
  48032. dispose(): void;
  48033. private _updateButtons;
  48034. }
  48035. }
  48036. declare module BABYLON {
  48037. /**
  48038. * Class containing static functions to help procedurally build meshes
  48039. */
  48040. export class LinesBuilder {
  48041. /**
  48042. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  48043. * * 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
  48044. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  48045. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  48046. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  48047. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  48048. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  48049. * * 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
  48050. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  48051. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48052. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  48053. * @param name defines the name of the new line system
  48054. * @param options defines the options used to create the line system
  48055. * @param scene defines the hosting scene
  48056. * @returns a new line system mesh
  48057. */
  48058. static CreateLineSystem(name: string, options: {
  48059. lines: Vector3[][];
  48060. updatable?: boolean;
  48061. instance?: Nullable<LinesMesh>;
  48062. colors?: Nullable<Color4[][]>;
  48063. useVertexAlpha?: boolean;
  48064. }, scene: Nullable<Scene>): LinesMesh;
  48065. /**
  48066. * Creates a line mesh
  48067. * 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
  48068. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  48069. * * The parameter `points` is an array successive Vector3
  48070. * * 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
  48071. * * The optional parameter `colors` is an array of successive Color4, one per line point
  48072. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  48073. * * When updating an instance, remember that only point positions can change, not the number of points
  48074. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48075. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  48076. * @param name defines the name of the new line system
  48077. * @param options defines the options used to create the line system
  48078. * @param scene defines the hosting scene
  48079. * @returns a new line mesh
  48080. */
  48081. static CreateLines(name: string, options: {
  48082. points: Vector3[];
  48083. updatable?: boolean;
  48084. instance?: Nullable<LinesMesh>;
  48085. colors?: Color4[];
  48086. useVertexAlpha?: boolean;
  48087. }, scene?: Nullable<Scene>): LinesMesh;
  48088. /**
  48089. * Creates a dashed line mesh
  48090. * * 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
  48091. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  48092. * * The parameter `points` is an array successive Vector3
  48093. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  48094. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  48095. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  48096. * * 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
  48097. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  48098. * * When updating an instance, remember that only point positions can change, not the number of points
  48099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48100. * @param name defines the name of the mesh
  48101. * @param options defines the options used to create the mesh
  48102. * @param scene defines the hosting scene
  48103. * @returns the dashed line mesh
  48104. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  48105. */
  48106. static CreateDashedLines(name: string, options: {
  48107. points: Vector3[];
  48108. dashSize?: number;
  48109. gapSize?: number;
  48110. dashNb?: number;
  48111. updatable?: boolean;
  48112. instance?: LinesMesh;
  48113. useVertexAlpha?: boolean;
  48114. }, scene?: Nullable<Scene>): LinesMesh;
  48115. }
  48116. }
  48117. declare module BABYLON {
  48118. /**
  48119. * Construction options for a timer
  48120. */
  48121. export interface ITimerOptions<T> {
  48122. /**
  48123. * Time-to-end
  48124. */
  48125. timeout: number;
  48126. /**
  48127. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  48128. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  48129. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  48130. */
  48131. contextObservable: Observable<T>;
  48132. /**
  48133. * Optional parameters when adding an observer to the observable
  48134. */
  48135. observableParameters?: {
  48136. mask?: number;
  48137. insertFirst?: boolean;
  48138. scope?: any;
  48139. };
  48140. /**
  48141. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  48142. */
  48143. breakCondition?: (data?: ITimerData<T>) => boolean;
  48144. /**
  48145. * Will be triggered when the time condition has met
  48146. */
  48147. onEnded?: (data: ITimerData<any>) => void;
  48148. /**
  48149. * Will be triggered when the break condition has met (prematurely ended)
  48150. */
  48151. onAborted?: (data: ITimerData<any>) => void;
  48152. /**
  48153. * Optional function to execute on each tick (or count)
  48154. */
  48155. onTick?: (data: ITimerData<any>) => void;
  48156. }
  48157. /**
  48158. * An interface defining the data sent by the timer
  48159. */
  48160. export interface ITimerData<T> {
  48161. /**
  48162. * When did it start
  48163. */
  48164. startTime: number;
  48165. /**
  48166. * Time now
  48167. */
  48168. currentTime: number;
  48169. /**
  48170. * Time passed since started
  48171. */
  48172. deltaTime: number;
  48173. /**
  48174. * How much is completed, in [0.0...1.0].
  48175. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  48176. */
  48177. completeRate: number;
  48178. /**
  48179. * What the registered observable sent in the last count
  48180. */
  48181. payload: T;
  48182. }
  48183. /**
  48184. * The current state of the timer
  48185. */
  48186. export enum TimerState {
  48187. /**
  48188. * Timer initialized, not yet started
  48189. */
  48190. INIT = 0,
  48191. /**
  48192. * Timer started and counting
  48193. */
  48194. STARTED = 1,
  48195. /**
  48196. * Timer ended (whether aborted or time reached)
  48197. */
  48198. ENDED = 2
  48199. }
  48200. /**
  48201. * A simple version of the timer. Will take options and start the timer immediately after calling it
  48202. *
  48203. * @param options options with which to initialize this timer
  48204. */
  48205. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  48206. /**
  48207. * An advanced implementation of a timer class
  48208. */
  48209. export class AdvancedTimer<T = any> implements IDisposable {
  48210. /**
  48211. * Will notify each time the timer calculates the remaining time
  48212. */
  48213. onEachCountObservable: Observable<ITimerData<T>>;
  48214. /**
  48215. * Will trigger when the timer was aborted due to the break condition
  48216. */
  48217. onTimerAbortedObservable: Observable<ITimerData<T>>;
  48218. /**
  48219. * Will trigger when the timer ended successfully
  48220. */
  48221. onTimerEndedObservable: Observable<ITimerData<T>>;
  48222. /**
  48223. * Will trigger when the timer state has changed
  48224. */
  48225. onStateChangedObservable: Observable<TimerState>;
  48226. private _observer;
  48227. private _contextObservable;
  48228. private _observableParameters;
  48229. private _startTime;
  48230. private _timer;
  48231. private _state;
  48232. private _breakCondition;
  48233. private _timeToEnd;
  48234. private _breakOnNextTick;
  48235. /**
  48236. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  48237. * @param options construction options for this advanced timer
  48238. */
  48239. constructor(options: ITimerOptions<T>);
  48240. /**
  48241. * set a breaking condition for this timer. Default is to never break during count
  48242. * @param predicate the new break condition. Returns true to break, false otherwise
  48243. */
  48244. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  48245. /**
  48246. * Reset ALL associated observables in this advanced timer
  48247. */
  48248. clearObservables(): void;
  48249. /**
  48250. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  48251. *
  48252. * @param timeToEnd how much time to measure until timer ended
  48253. */
  48254. start(timeToEnd?: number): void;
  48255. /**
  48256. * Will force a stop on the next tick.
  48257. */
  48258. stop(): void;
  48259. /**
  48260. * Dispose this timer, clearing all resources
  48261. */
  48262. dispose(): void;
  48263. private _setState;
  48264. private _tick;
  48265. private _stop;
  48266. }
  48267. }
  48268. declare module BABYLON {
  48269. /**
  48270. * The options container for the teleportation module
  48271. */
  48272. export interface IWebXRTeleportationOptions {
  48273. /**
  48274. * if provided, this scene will be used to render meshes.
  48275. */
  48276. customUtilityLayerScene?: Scene;
  48277. /**
  48278. * Values to configure the default target mesh
  48279. */
  48280. defaultTargetMeshOptions?: {
  48281. /**
  48282. * Fill color of the teleportation area
  48283. */
  48284. teleportationFillColor?: string;
  48285. /**
  48286. * Border color for the teleportation area
  48287. */
  48288. teleportationBorderColor?: string;
  48289. /**
  48290. * Disable the mesh's animation sequence
  48291. */
  48292. disableAnimation?: boolean;
  48293. /**
  48294. * Disable lighting on the material or the ring and arrow
  48295. */
  48296. disableLighting?: boolean;
  48297. /**
  48298. * Override the default material of the torus and arrow
  48299. */
  48300. torusArrowMaterial?: Material;
  48301. };
  48302. /**
  48303. * A list of meshes to use as floor meshes.
  48304. * Meshes can be added and removed after initializing the feature using the
  48305. * addFloorMesh and removeFloorMesh functions
  48306. * If empty, rotation will still work
  48307. */
  48308. floorMeshes?: AbstractMesh[];
  48309. /**
  48310. * use this rendering group id for the meshes (optional)
  48311. */
  48312. renderingGroupId?: number;
  48313. /**
  48314. * Should teleportation move only to snap points
  48315. */
  48316. snapPointsOnly?: boolean;
  48317. /**
  48318. * An array of points to which the teleportation will snap to.
  48319. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  48320. */
  48321. snapPositions?: Vector3[];
  48322. /**
  48323. * How close should the teleportation ray be in order to snap to position.
  48324. * Default to 0.8 units (meters)
  48325. */
  48326. snapToPositionRadius?: number;
  48327. /**
  48328. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  48329. * If you want to support rotation, make sure your mesh has a direction indicator.
  48330. *
  48331. * When left untouched, the default mesh will be initialized.
  48332. */
  48333. teleportationTargetMesh?: AbstractMesh;
  48334. /**
  48335. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  48336. */
  48337. timeToTeleport?: number;
  48338. /**
  48339. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  48340. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  48341. */
  48342. useMainComponentOnly?: boolean;
  48343. /**
  48344. * Should meshes created here be added to a utility layer or the main scene
  48345. */
  48346. useUtilityLayer?: boolean;
  48347. /**
  48348. * Babylon XR Input class for controller
  48349. */
  48350. xrInput: WebXRInput;
  48351. }
  48352. /**
  48353. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  48354. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  48355. * the input of the attached controllers.
  48356. */
  48357. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  48358. private _options;
  48359. private _controllers;
  48360. private _currentTeleportationControllerId;
  48361. private _floorMeshes;
  48362. private _quadraticBezierCurve;
  48363. private _selectionFeature;
  48364. private _snapToPositions;
  48365. private _snappedToPoint;
  48366. private _teleportationRingMaterial?;
  48367. private _tmpRay;
  48368. private _tmpVector;
  48369. /**
  48370. * The module's name
  48371. */
  48372. static readonly Name: string;
  48373. /**
  48374. * The (Babylon) version of this module.
  48375. * This is an integer representing the implementation version.
  48376. * This number does not correspond to the webxr specs version
  48377. */
  48378. static readonly Version: number;
  48379. /**
  48380. * Is movement backwards enabled
  48381. */
  48382. backwardsMovementEnabled: boolean;
  48383. /**
  48384. * Distance to travel when moving backwards
  48385. */
  48386. backwardsTeleportationDistance: number;
  48387. /**
  48388. * The distance from the user to the inspection point in the direction of the controller
  48389. * A higher number will allow the user to move further
  48390. * defaults to 5 (meters, in xr units)
  48391. */
  48392. parabolicCheckRadius: number;
  48393. /**
  48394. * Should the module support parabolic ray on top of direct ray
  48395. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  48396. * Very helpful when moving between floors / different heights
  48397. */
  48398. parabolicRayEnabled: boolean;
  48399. /**
  48400. * How much rotation should be applied when rotating right and left
  48401. */
  48402. rotationAngle: number;
  48403. /**
  48404. * Is rotation enabled when moving forward?
  48405. * Disabling this feature will prevent the user from deciding the direction when teleporting
  48406. */
  48407. rotationEnabled: boolean;
  48408. /**
  48409. * constructs a new anchor system
  48410. * @param _xrSessionManager an instance of WebXRSessionManager
  48411. * @param _options configuration object for this feature
  48412. */
  48413. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  48414. /**
  48415. * Get the snapPointsOnly flag
  48416. */
  48417. get snapPointsOnly(): boolean;
  48418. /**
  48419. * Sets the snapPointsOnly flag
  48420. * @param snapToPoints should teleportation be exclusively to snap points
  48421. */
  48422. set snapPointsOnly(snapToPoints: boolean);
  48423. /**
  48424. * Add a new mesh to the floor meshes array
  48425. * @param mesh the mesh to use as floor mesh
  48426. */
  48427. addFloorMesh(mesh: AbstractMesh): void;
  48428. /**
  48429. * Add a new snap-to point to fix teleportation to this position
  48430. * @param newSnapPoint The new Snap-To point
  48431. */
  48432. addSnapPoint(newSnapPoint: Vector3): void;
  48433. attach(): boolean;
  48434. detach(): boolean;
  48435. dispose(): void;
  48436. /**
  48437. * Remove a mesh from the floor meshes array
  48438. * @param mesh the mesh to remove
  48439. */
  48440. removeFloorMesh(mesh: AbstractMesh): void;
  48441. /**
  48442. * Remove a mesh from the floor meshes array using its name
  48443. * @param name the mesh name to remove
  48444. */
  48445. removeFloorMeshByName(name: string): void;
  48446. /**
  48447. * 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
  48448. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  48449. * @returns was the point found and removed or not
  48450. */
  48451. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  48452. /**
  48453. * This function sets a selection feature that will be disabled when
  48454. * the forward ray is shown and will be reattached when hidden.
  48455. * This is used to remove the selection rays when moving.
  48456. * @param selectionFeature the feature to disable when forward movement is enabled
  48457. */
  48458. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  48459. protected _onXRFrame(_xrFrame: XRFrame): void;
  48460. private _attachController;
  48461. private _createDefaultTargetMesh;
  48462. private _detachController;
  48463. private _findClosestSnapPointWithRadius;
  48464. private _setTargetMeshPosition;
  48465. private _setTargetMeshVisibility;
  48466. private _showParabolicPath;
  48467. private _teleportForward;
  48468. }
  48469. }
  48470. declare module BABYLON {
  48471. /**
  48472. * Options for the default xr helper
  48473. */
  48474. export class WebXRDefaultExperienceOptions {
  48475. /**
  48476. * Enable or disable default UI to enter XR
  48477. */
  48478. disableDefaultUI?: boolean;
  48479. /**
  48480. * Should teleportation not initialize. defaults to false.
  48481. */
  48482. disableTeleportation?: boolean;
  48483. /**
  48484. * Floor meshes that will be used for teleport
  48485. */
  48486. floorMeshes?: Array<AbstractMesh>;
  48487. /**
  48488. * If set to true, the first frame will not be used to reset position
  48489. * The first frame is mainly used when copying transformation from the old camera
  48490. * Mainly used in AR
  48491. */
  48492. ignoreNativeCameraTransformation?: boolean;
  48493. /**
  48494. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  48495. */
  48496. inputOptions?: IWebXRInputOptions;
  48497. /**
  48498. * optional configuration for the output canvas
  48499. */
  48500. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  48501. /**
  48502. * optional UI options. This can be used among other to change session mode and reference space type
  48503. */
  48504. uiOptions?: WebXREnterExitUIOptions;
  48505. /**
  48506. * When loading teleportation and pointer select, use stable versions instead of latest.
  48507. */
  48508. useStablePlugins?: boolean;
  48509. /**
  48510. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  48511. */
  48512. renderingGroupId?: number;
  48513. /**
  48514. * A list of optional features to init the session with
  48515. * If set to true, all features we support will be added
  48516. */
  48517. optionalFeatures?: boolean | string[];
  48518. }
  48519. /**
  48520. * Default experience which provides a similar setup to the previous webVRExperience
  48521. */
  48522. export class WebXRDefaultExperience {
  48523. /**
  48524. * Base experience
  48525. */
  48526. baseExperience: WebXRExperienceHelper;
  48527. /**
  48528. * Enables ui for entering/exiting xr
  48529. */
  48530. enterExitUI: WebXREnterExitUI;
  48531. /**
  48532. * Input experience extension
  48533. */
  48534. input: WebXRInput;
  48535. /**
  48536. * Enables laser pointer and selection
  48537. */
  48538. pointerSelection: WebXRControllerPointerSelection;
  48539. /**
  48540. * Default target xr should render to
  48541. */
  48542. renderTarget: WebXRRenderTarget;
  48543. /**
  48544. * Enables teleportation
  48545. */
  48546. teleportation: WebXRMotionControllerTeleportation;
  48547. private constructor();
  48548. /**
  48549. * Creates the default xr experience
  48550. * @param scene scene
  48551. * @param options options for basic configuration
  48552. * @returns resulting WebXRDefaultExperience
  48553. */
  48554. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48555. /**
  48556. * DIsposes of the experience helper
  48557. */
  48558. dispose(): void;
  48559. }
  48560. }
  48561. declare module BABYLON {
  48562. /**
  48563. * Options to modify the vr teleportation behavior.
  48564. */
  48565. export interface VRTeleportationOptions {
  48566. /**
  48567. * The name of the mesh which should be used as the teleportation floor. (default: null)
  48568. */
  48569. floorMeshName?: string;
  48570. /**
  48571. * A list of meshes to be used as the teleportation floor. (default: empty)
  48572. */
  48573. floorMeshes?: Mesh[];
  48574. /**
  48575. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  48576. */
  48577. teleportationMode?: number;
  48578. /**
  48579. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  48580. */
  48581. teleportationTime?: number;
  48582. /**
  48583. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  48584. */
  48585. teleportationSpeed?: number;
  48586. /**
  48587. * The easing function used in the animation or null for Linear. (default CircleEase)
  48588. */
  48589. easingFunction?: EasingFunction;
  48590. }
  48591. /**
  48592. * Options to modify the vr experience helper's behavior.
  48593. */
  48594. export interface VRExperienceHelperOptions extends WebVROptions {
  48595. /**
  48596. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  48597. */
  48598. createDeviceOrientationCamera?: boolean;
  48599. /**
  48600. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  48601. */
  48602. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  48603. /**
  48604. * Uses the main button on the controller to toggle the laser casted. (default: true)
  48605. */
  48606. laserToggle?: boolean;
  48607. /**
  48608. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  48609. */
  48610. floorMeshes?: Mesh[];
  48611. /**
  48612. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  48613. */
  48614. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  48615. /**
  48616. * Defines if WebXR should be used instead of WebVR (if available)
  48617. */
  48618. useXR?: boolean;
  48619. }
  48620. /**
  48621. * Event containing information after VR has been entered
  48622. */
  48623. export class OnAfterEnteringVRObservableEvent {
  48624. /**
  48625. * If entering vr was successful
  48626. */
  48627. success: boolean;
  48628. }
  48629. /**
  48630. * Helps to quickly add VR support to an existing scene.
  48631. * See http://doc.babylonjs.com/how_to/webvr_helper
  48632. */
  48633. export class VRExperienceHelper {
  48634. /** Options to modify the vr experience helper's behavior. */
  48635. webVROptions: VRExperienceHelperOptions;
  48636. private _scene;
  48637. private _position;
  48638. private _btnVR;
  48639. private _btnVRDisplayed;
  48640. private _webVRsupported;
  48641. private _webVRready;
  48642. private _webVRrequesting;
  48643. private _webVRpresenting;
  48644. private _hasEnteredVR;
  48645. private _fullscreenVRpresenting;
  48646. private _inputElement;
  48647. private _webVRCamera;
  48648. private _vrDeviceOrientationCamera;
  48649. private _deviceOrientationCamera;
  48650. private _existingCamera;
  48651. private _onKeyDown;
  48652. private _onVrDisplayPresentChange;
  48653. private _onVRDisplayChanged;
  48654. private _onVRRequestPresentStart;
  48655. private _onVRRequestPresentComplete;
  48656. /**
  48657. * 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)
  48658. */
  48659. enableGazeEvenWhenNoPointerLock: boolean;
  48660. /**
  48661. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  48662. */
  48663. exitVROnDoubleTap: boolean;
  48664. /**
  48665. * Observable raised right before entering VR.
  48666. */
  48667. onEnteringVRObservable: Observable<VRExperienceHelper>;
  48668. /**
  48669. * Observable raised when entering VR has completed.
  48670. */
  48671. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  48672. /**
  48673. * Observable raised when exiting VR.
  48674. */
  48675. onExitingVRObservable: Observable<VRExperienceHelper>;
  48676. /**
  48677. * Observable raised when controller mesh is loaded.
  48678. */
  48679. onControllerMeshLoadedObservable: Observable<WebVRController>;
  48680. /** Return this.onEnteringVRObservable
  48681. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  48682. */
  48683. get onEnteringVR(): Observable<VRExperienceHelper>;
  48684. /** Return this.onExitingVRObservable
  48685. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  48686. */
  48687. get onExitingVR(): Observable<VRExperienceHelper>;
  48688. /** Return this.onControllerMeshLoadedObservable
  48689. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  48690. */
  48691. get onControllerMeshLoaded(): Observable<WebVRController>;
  48692. private _rayLength;
  48693. private _useCustomVRButton;
  48694. private _teleportationRequested;
  48695. private _teleportActive;
  48696. private _floorMeshName;
  48697. private _floorMeshesCollection;
  48698. private _teleportationMode;
  48699. private _teleportationTime;
  48700. private _teleportationSpeed;
  48701. private _teleportationEasing;
  48702. private _rotationAllowed;
  48703. private _teleportBackwardsVector;
  48704. private _teleportationTarget;
  48705. private _isDefaultTeleportationTarget;
  48706. private _postProcessMove;
  48707. private _teleportationFillColor;
  48708. private _teleportationBorderColor;
  48709. private _rotationAngle;
  48710. private _haloCenter;
  48711. private _cameraGazer;
  48712. private _padSensibilityUp;
  48713. private _padSensibilityDown;
  48714. private _leftController;
  48715. private _rightController;
  48716. private _gazeColor;
  48717. private _laserColor;
  48718. private _pickedLaserColor;
  48719. private _pickedGazeColor;
  48720. /**
  48721. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  48722. */
  48723. onNewMeshSelected: Observable<AbstractMesh>;
  48724. /**
  48725. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  48726. * This observable will provide the mesh and the controller used to select the mesh
  48727. */
  48728. onMeshSelectedWithController: Observable<{
  48729. mesh: AbstractMesh;
  48730. controller: WebVRController;
  48731. }>;
  48732. /**
  48733. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  48734. */
  48735. onNewMeshPicked: Observable<PickingInfo>;
  48736. private _circleEase;
  48737. /**
  48738. * Observable raised before camera teleportation
  48739. */
  48740. onBeforeCameraTeleport: Observable<Vector3>;
  48741. /**
  48742. * Observable raised after camera teleportation
  48743. */
  48744. onAfterCameraTeleport: Observable<Vector3>;
  48745. /**
  48746. * Observable raised when current selected mesh gets unselected
  48747. */
  48748. onSelectedMeshUnselected: Observable<AbstractMesh>;
  48749. private _raySelectionPredicate;
  48750. /**
  48751. * To be optionaly changed by user to define custom ray selection
  48752. */
  48753. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48754. /**
  48755. * To be optionaly changed by user to define custom selection logic (after ray selection)
  48756. */
  48757. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48758. /**
  48759. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  48760. */
  48761. teleportationEnabled: boolean;
  48762. private _defaultHeight;
  48763. private _teleportationInitialized;
  48764. private _interactionsEnabled;
  48765. private _interactionsRequested;
  48766. private _displayGaze;
  48767. private _displayLaserPointer;
  48768. /**
  48769. * The mesh used to display where the user is going to teleport.
  48770. */
  48771. get teleportationTarget(): Mesh;
  48772. /**
  48773. * Sets the mesh to be used to display where the user is going to teleport.
  48774. */
  48775. set teleportationTarget(value: Mesh);
  48776. /**
  48777. * 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
  48778. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  48779. * See http://doc.babylonjs.com/resources/baking_transformations
  48780. */
  48781. get gazeTrackerMesh(): Mesh;
  48782. set gazeTrackerMesh(value: Mesh);
  48783. /**
  48784. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  48785. */
  48786. updateGazeTrackerScale: boolean;
  48787. /**
  48788. * If the gaze trackers color should be updated when selecting meshes
  48789. */
  48790. updateGazeTrackerColor: boolean;
  48791. /**
  48792. * If the controller laser color should be updated when selecting meshes
  48793. */
  48794. updateControllerLaserColor: boolean;
  48795. /**
  48796. * The gaze tracking mesh corresponding to the left controller
  48797. */
  48798. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  48799. /**
  48800. * The gaze tracking mesh corresponding to the right controller
  48801. */
  48802. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  48803. /**
  48804. * If the ray of the gaze should be displayed.
  48805. */
  48806. get displayGaze(): boolean;
  48807. /**
  48808. * Sets if the ray of the gaze should be displayed.
  48809. */
  48810. set displayGaze(value: boolean);
  48811. /**
  48812. * If the ray of the LaserPointer should be displayed.
  48813. */
  48814. get displayLaserPointer(): boolean;
  48815. /**
  48816. * Sets if the ray of the LaserPointer should be displayed.
  48817. */
  48818. set displayLaserPointer(value: boolean);
  48819. /**
  48820. * The deviceOrientationCamera used as the camera when not in VR.
  48821. */
  48822. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  48823. /**
  48824. * Based on the current WebVR support, returns the current VR camera used.
  48825. */
  48826. get currentVRCamera(): Nullable<Camera>;
  48827. /**
  48828. * The webVRCamera which is used when in VR.
  48829. */
  48830. get webVRCamera(): WebVRFreeCamera;
  48831. /**
  48832. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  48833. */
  48834. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  48835. /**
  48836. * The html button that is used to trigger entering into VR.
  48837. */
  48838. get vrButton(): Nullable<HTMLButtonElement>;
  48839. private get _teleportationRequestInitiated();
  48840. /**
  48841. * Defines whether or not Pointer lock should be requested when switching to
  48842. * full screen.
  48843. */
  48844. requestPointerLockOnFullScreen: boolean;
  48845. /**
  48846. * If asking to force XR, this will be populated with the default xr experience
  48847. */
  48848. xr: WebXRDefaultExperience;
  48849. /**
  48850. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  48851. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  48852. */
  48853. xrTestDone: boolean;
  48854. /**
  48855. * Instantiates a VRExperienceHelper.
  48856. * Helps to quickly add VR support to an existing scene.
  48857. * @param scene The scene the VRExperienceHelper belongs to.
  48858. * @param webVROptions Options to modify the vr experience helper's behavior.
  48859. */
  48860. constructor(scene: Scene,
  48861. /** Options to modify the vr experience helper's behavior. */
  48862. webVROptions?: VRExperienceHelperOptions);
  48863. private completeVRInit;
  48864. private _onDefaultMeshLoaded;
  48865. private _onResize;
  48866. private _onFullscreenChange;
  48867. /**
  48868. * Gets a value indicating if we are currently in VR mode.
  48869. */
  48870. get isInVRMode(): boolean;
  48871. private onVrDisplayPresentChange;
  48872. private onVRDisplayChanged;
  48873. private moveButtonToBottomRight;
  48874. private displayVRButton;
  48875. private updateButtonVisibility;
  48876. private _cachedAngularSensibility;
  48877. /**
  48878. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  48879. * Otherwise, will use the fullscreen API.
  48880. */
  48881. enterVR(): void;
  48882. /**
  48883. * Attempt to exit VR, or fullscreen.
  48884. */
  48885. exitVR(): void;
  48886. /**
  48887. * The position of the vr experience helper.
  48888. */
  48889. get position(): Vector3;
  48890. /**
  48891. * Sets the position of the vr experience helper.
  48892. */
  48893. set position(value: Vector3);
  48894. /**
  48895. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  48896. */
  48897. enableInteractions(): void;
  48898. private get _noControllerIsActive();
  48899. private beforeRender;
  48900. private _isTeleportationFloor;
  48901. /**
  48902. * Adds a floor mesh to be used for teleportation.
  48903. * @param floorMesh the mesh to be used for teleportation.
  48904. */
  48905. addFloorMesh(floorMesh: Mesh): void;
  48906. /**
  48907. * Removes a floor mesh from being used for teleportation.
  48908. * @param floorMesh the mesh to be removed.
  48909. */
  48910. removeFloorMesh(floorMesh: Mesh): void;
  48911. /**
  48912. * Enables interactions and teleportation using the VR controllers and gaze.
  48913. * @param vrTeleportationOptions options to modify teleportation behavior.
  48914. */
  48915. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  48916. private _onNewGamepadConnected;
  48917. private _tryEnableInteractionOnController;
  48918. private _onNewGamepadDisconnected;
  48919. private _enableInteractionOnController;
  48920. private _checkTeleportWithRay;
  48921. private _checkRotate;
  48922. private _checkTeleportBackwards;
  48923. private _enableTeleportationOnController;
  48924. private _createTeleportationCircles;
  48925. private _displayTeleportationTarget;
  48926. private _hideTeleportationTarget;
  48927. private _rotateCamera;
  48928. private _moveTeleportationSelectorTo;
  48929. private _workingVector;
  48930. private _workingQuaternion;
  48931. private _workingMatrix;
  48932. /**
  48933. * Time Constant Teleportation Mode
  48934. */
  48935. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  48936. /**
  48937. * Speed Constant Teleportation Mode
  48938. */
  48939. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  48940. /**
  48941. * Teleports the users feet to the desired location
  48942. * @param location The location where the user's feet should be placed
  48943. */
  48944. teleportCamera(location: Vector3): void;
  48945. private _convertNormalToDirectionOfRay;
  48946. private _castRayAndSelectObject;
  48947. private _notifySelectedMeshUnselected;
  48948. /**
  48949. * Permanently set new colors for the laser pointer
  48950. * @param color the new laser color
  48951. * @param pickedColor the new laser color when picked mesh detected
  48952. */
  48953. setLaserColor(color: Color3, pickedColor?: Color3): void;
  48954. /**
  48955. * Set lighting enabled / disabled on the laser pointer of both controllers
  48956. * @param enabled should the lighting be enabled on the laser pointer
  48957. */
  48958. setLaserLightingState(enabled?: boolean): void;
  48959. /**
  48960. * Permanently set new colors for the gaze pointer
  48961. * @param color the new gaze color
  48962. * @param pickedColor the new gaze color when picked mesh detected
  48963. */
  48964. setGazeColor(color: Color3, pickedColor?: Color3): void;
  48965. /**
  48966. * Sets the color of the laser ray from the vr controllers.
  48967. * @param color new color for the ray.
  48968. */
  48969. changeLaserColor(color: Color3): void;
  48970. /**
  48971. * Sets the color of the ray from the vr headsets gaze.
  48972. * @param color new color for the ray.
  48973. */
  48974. changeGazeColor(color: Color3): void;
  48975. /**
  48976. * Exits VR and disposes of the vr experience helper
  48977. */
  48978. dispose(): void;
  48979. /**
  48980. * Gets the name of the VRExperienceHelper class
  48981. * @returns "VRExperienceHelper"
  48982. */
  48983. getClassName(): string;
  48984. }
  48985. }
  48986. declare module BABYLON {
  48987. /**
  48988. * Contains an array of blocks representing the octree
  48989. */
  48990. export interface IOctreeContainer<T> {
  48991. /**
  48992. * Blocks within the octree
  48993. */
  48994. blocks: Array<OctreeBlock<T>>;
  48995. }
  48996. /**
  48997. * Class used to store a cell in an octree
  48998. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48999. */
  49000. export class OctreeBlock<T> {
  49001. /**
  49002. * Gets the content of the current block
  49003. */
  49004. entries: T[];
  49005. /**
  49006. * Gets the list of block children
  49007. */
  49008. blocks: Array<OctreeBlock<T>>;
  49009. private _depth;
  49010. private _maxDepth;
  49011. private _capacity;
  49012. private _minPoint;
  49013. private _maxPoint;
  49014. private _boundingVectors;
  49015. private _creationFunc;
  49016. /**
  49017. * Creates a new block
  49018. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  49019. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  49020. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  49021. * @param depth defines the current depth of this block in the octree
  49022. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  49023. * @param creationFunc defines a callback to call when an element is added to the block
  49024. */
  49025. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  49026. /**
  49027. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  49028. */
  49029. get capacity(): number;
  49030. /**
  49031. * Gets the minimum vector (in world space) of the block's bounding box
  49032. */
  49033. get minPoint(): Vector3;
  49034. /**
  49035. * Gets the maximum vector (in world space) of the block's bounding box
  49036. */
  49037. get maxPoint(): Vector3;
  49038. /**
  49039. * Add a new element to this block
  49040. * @param entry defines the element to add
  49041. */
  49042. addEntry(entry: T): void;
  49043. /**
  49044. * Remove an element from this block
  49045. * @param entry defines the element to remove
  49046. */
  49047. removeEntry(entry: T): void;
  49048. /**
  49049. * Add an array of elements to this block
  49050. * @param entries defines the array of elements to add
  49051. */
  49052. addEntries(entries: T[]): void;
  49053. /**
  49054. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  49055. * @param frustumPlanes defines the frustum planes to test
  49056. * @param selection defines the array to store current content if selection is positive
  49057. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49058. */
  49059. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  49060. /**
  49061. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  49062. * @param sphereCenter defines the bounding sphere center
  49063. * @param sphereRadius defines the bounding sphere radius
  49064. * @param selection defines the array to store current content if selection is positive
  49065. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49066. */
  49067. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  49068. /**
  49069. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  49070. * @param ray defines the ray to test with
  49071. * @param selection defines the array to store current content if selection is positive
  49072. */
  49073. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  49074. /**
  49075. * Subdivide the content into child blocks (this block will then be empty)
  49076. */
  49077. createInnerBlocks(): void;
  49078. /**
  49079. * @hidden
  49080. */
  49081. 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;
  49082. }
  49083. }
  49084. declare module BABYLON {
  49085. /**
  49086. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  49087. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49088. */
  49089. export class Octree<T> {
  49090. /** 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.) */
  49091. maxDepth: number;
  49092. /**
  49093. * Blocks within the octree containing objects
  49094. */
  49095. blocks: Array<OctreeBlock<T>>;
  49096. /**
  49097. * Content stored in the octree
  49098. */
  49099. dynamicContent: T[];
  49100. private _maxBlockCapacity;
  49101. private _selectionContent;
  49102. private _creationFunc;
  49103. /**
  49104. * Creates a octree
  49105. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49106. * @param creationFunc function to be used to instatiate the octree
  49107. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  49108. * @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.)
  49109. */
  49110. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  49111. /** 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.) */
  49112. maxDepth?: number);
  49113. /**
  49114. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  49115. * @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);
  49116. * @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);
  49117. * @param entries meshes to be added to the octree blocks
  49118. */
  49119. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  49120. /**
  49121. * Adds a mesh to the octree
  49122. * @param entry Mesh to add to the octree
  49123. */
  49124. addMesh(entry: T): void;
  49125. /**
  49126. * Remove an element from the octree
  49127. * @param entry defines the element to remove
  49128. */
  49129. removeMesh(entry: T): void;
  49130. /**
  49131. * Selects an array of meshes within the frustum
  49132. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  49133. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  49134. * @returns array of meshes within the frustum
  49135. */
  49136. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  49137. /**
  49138. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  49139. * @param sphereCenter defines the bounding sphere center
  49140. * @param sphereRadius defines the bounding sphere radius
  49141. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49142. * @returns an array of objects that intersect the sphere
  49143. */
  49144. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  49145. /**
  49146. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  49147. * @param ray defines the ray to test with
  49148. * @returns array of intersected objects
  49149. */
  49150. intersectsRay(ray: Ray): SmartArray<T>;
  49151. /**
  49152. * Adds a mesh into the octree block if it intersects the block
  49153. */
  49154. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  49155. /**
  49156. * Adds a submesh into the octree block if it intersects the block
  49157. */
  49158. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  49159. }
  49160. }
  49161. declare module BABYLON {
  49162. interface Scene {
  49163. /**
  49164. * @hidden
  49165. * Backing Filed
  49166. */
  49167. _selectionOctree: Octree<AbstractMesh>;
  49168. /**
  49169. * Gets the octree used to boost mesh selection (picking)
  49170. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49171. */
  49172. selectionOctree: Octree<AbstractMesh>;
  49173. /**
  49174. * Creates or updates the octree used to boost selection (picking)
  49175. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49176. * @param maxCapacity defines the maximum capacity per leaf
  49177. * @param maxDepth defines the maximum depth of the octree
  49178. * @returns an octree of AbstractMesh
  49179. */
  49180. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  49181. }
  49182. interface AbstractMesh {
  49183. /**
  49184. * @hidden
  49185. * Backing Field
  49186. */
  49187. _submeshesOctree: Octree<SubMesh>;
  49188. /**
  49189. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  49190. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  49191. * @param maxCapacity defines the maximum size of each block (64 by default)
  49192. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  49193. * @returns the new octree
  49194. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  49195. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49196. */
  49197. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  49198. }
  49199. /**
  49200. * Defines the octree scene component responsible to manage any octrees
  49201. * in a given scene.
  49202. */
  49203. export class OctreeSceneComponent {
  49204. /**
  49205. * The component name help to identify the component in the list of scene components.
  49206. */
  49207. readonly name: string;
  49208. /**
  49209. * The scene the component belongs to.
  49210. */
  49211. scene: Scene;
  49212. /**
  49213. * Indicates if the meshes have been checked to make sure they are isEnabled()
  49214. */
  49215. readonly checksIsEnabled: boolean;
  49216. /**
  49217. * Creates a new instance of the component for the given scene
  49218. * @param scene Defines the scene to register the component in
  49219. */
  49220. constructor(scene: Scene);
  49221. /**
  49222. * Registers the component in a given scene
  49223. */
  49224. register(): void;
  49225. /**
  49226. * Return the list of active meshes
  49227. * @returns the list of active meshes
  49228. */
  49229. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  49230. /**
  49231. * Return the list of active sub meshes
  49232. * @param mesh The mesh to get the candidates sub meshes from
  49233. * @returns the list of active sub meshes
  49234. */
  49235. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  49236. private _tempRay;
  49237. /**
  49238. * Return the list of sub meshes intersecting with a given local ray
  49239. * @param mesh defines the mesh to find the submesh for
  49240. * @param localRay defines the ray in local space
  49241. * @returns the list of intersecting sub meshes
  49242. */
  49243. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  49244. /**
  49245. * Return the list of sub meshes colliding with a collider
  49246. * @param mesh defines the mesh to find the submesh for
  49247. * @param collider defines the collider to evaluate the collision against
  49248. * @returns the list of colliding sub meshes
  49249. */
  49250. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  49251. /**
  49252. * Rebuilds the elements related to this component in case of
  49253. * context lost for instance.
  49254. */
  49255. rebuild(): void;
  49256. /**
  49257. * Disposes the component and the associated ressources.
  49258. */
  49259. dispose(): void;
  49260. }
  49261. }
  49262. declare module BABYLON {
  49263. /**
  49264. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  49265. */
  49266. export class Gizmo implements IDisposable {
  49267. /** The utility layer the gizmo will be added to */
  49268. gizmoLayer: UtilityLayerRenderer;
  49269. /**
  49270. * The root mesh of the gizmo
  49271. */
  49272. _rootMesh: Mesh;
  49273. private _attachedMesh;
  49274. /**
  49275. * Ratio for the scale of the gizmo (Default: 1)
  49276. */
  49277. scaleRatio: number;
  49278. /**
  49279. * If a custom mesh has been set (Default: false)
  49280. */
  49281. protected _customMeshSet: boolean;
  49282. /**
  49283. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  49284. * * When set, interactions will be enabled
  49285. */
  49286. get attachedMesh(): Nullable<AbstractMesh>;
  49287. set attachedMesh(value: Nullable<AbstractMesh>);
  49288. /**
  49289. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  49290. * @param mesh The mesh to replace the default mesh of the gizmo
  49291. */
  49292. setCustomMesh(mesh: Mesh): void;
  49293. /**
  49294. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  49295. */
  49296. updateGizmoRotationToMatchAttachedMesh: boolean;
  49297. /**
  49298. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  49299. */
  49300. updateGizmoPositionToMatchAttachedMesh: boolean;
  49301. /**
  49302. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  49303. */
  49304. updateScale: boolean;
  49305. protected _interactionsEnabled: boolean;
  49306. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49307. private _beforeRenderObserver;
  49308. private _tempVector;
  49309. /**
  49310. * Creates a gizmo
  49311. * @param gizmoLayer The utility layer the gizmo will be added to
  49312. */
  49313. constructor(
  49314. /** The utility layer the gizmo will be added to */
  49315. gizmoLayer?: UtilityLayerRenderer);
  49316. /**
  49317. * Updates the gizmo to match the attached mesh's position/rotation
  49318. */
  49319. protected _update(): void;
  49320. /**
  49321. * Disposes of the gizmo
  49322. */
  49323. dispose(): void;
  49324. }
  49325. }
  49326. declare module BABYLON {
  49327. /**
  49328. * Single plane drag gizmo
  49329. */
  49330. export class PlaneDragGizmo extends Gizmo {
  49331. /**
  49332. * Drag behavior responsible for the gizmos dragging interactions
  49333. */
  49334. dragBehavior: PointerDragBehavior;
  49335. private _pointerObserver;
  49336. /**
  49337. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49338. */
  49339. snapDistance: number;
  49340. /**
  49341. * Event that fires each time the gizmo snaps to a new location.
  49342. * * snapDistance is the the change in distance
  49343. */
  49344. onSnapObservable: Observable<{
  49345. snapDistance: number;
  49346. }>;
  49347. private _plane;
  49348. private _coloredMaterial;
  49349. private _hoverMaterial;
  49350. private _isEnabled;
  49351. private _parent;
  49352. /** @hidden */
  49353. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  49354. /** @hidden */
  49355. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  49356. /**
  49357. * Creates a PlaneDragGizmo
  49358. * @param gizmoLayer The utility layer the gizmo will be added to
  49359. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  49360. * @param color The color of the gizmo
  49361. */
  49362. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  49363. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49364. /**
  49365. * If the gizmo is enabled
  49366. */
  49367. set isEnabled(value: boolean);
  49368. get isEnabled(): boolean;
  49369. /**
  49370. * Disposes of the gizmo
  49371. */
  49372. dispose(): void;
  49373. }
  49374. }
  49375. declare module BABYLON {
  49376. /**
  49377. * Gizmo that enables dragging a mesh along 3 axis
  49378. */
  49379. export class PositionGizmo extends Gizmo {
  49380. /**
  49381. * Internal gizmo used for interactions on the x axis
  49382. */
  49383. xGizmo: AxisDragGizmo;
  49384. /**
  49385. * Internal gizmo used for interactions on the y axis
  49386. */
  49387. yGizmo: AxisDragGizmo;
  49388. /**
  49389. * Internal gizmo used for interactions on the z axis
  49390. */
  49391. zGizmo: AxisDragGizmo;
  49392. /**
  49393. * Internal gizmo used for interactions on the yz plane
  49394. */
  49395. xPlaneGizmo: PlaneDragGizmo;
  49396. /**
  49397. * Internal gizmo used for interactions on the xz plane
  49398. */
  49399. yPlaneGizmo: PlaneDragGizmo;
  49400. /**
  49401. * Internal gizmo used for interactions on the xy plane
  49402. */
  49403. zPlaneGizmo: PlaneDragGizmo;
  49404. /**
  49405. * private variables
  49406. */
  49407. private _meshAttached;
  49408. private _updateGizmoRotationToMatchAttachedMesh;
  49409. private _snapDistance;
  49410. private _scaleRatio;
  49411. /** Fires an event when any of it's sub gizmos are dragged */
  49412. onDragStartObservable: Observable<unknown>;
  49413. /** Fires an event when any of it's sub gizmos are released from dragging */
  49414. onDragEndObservable: Observable<unknown>;
  49415. /**
  49416. * If set to true, planar drag is enabled
  49417. */
  49418. private _planarGizmoEnabled;
  49419. get attachedMesh(): Nullable<AbstractMesh>;
  49420. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49421. /**
  49422. * Creates a PositionGizmo
  49423. * @param gizmoLayer The utility layer the gizmo will be added to
  49424. */
  49425. constructor(gizmoLayer?: UtilityLayerRenderer);
  49426. /**
  49427. * If the planar drag gizmo is enabled
  49428. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  49429. */
  49430. set planarGizmoEnabled(value: boolean);
  49431. get planarGizmoEnabled(): boolean;
  49432. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49433. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49434. /**
  49435. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49436. */
  49437. set snapDistance(value: number);
  49438. get snapDistance(): number;
  49439. /**
  49440. * Ratio for the scale of the gizmo (Default: 1)
  49441. */
  49442. set scaleRatio(value: number);
  49443. get scaleRatio(): number;
  49444. /**
  49445. * Disposes of the gizmo
  49446. */
  49447. dispose(): void;
  49448. /**
  49449. * CustomMeshes are not supported by this gizmo
  49450. * @param mesh The mesh to replace the default mesh of the gizmo
  49451. */
  49452. setCustomMesh(mesh: Mesh): void;
  49453. }
  49454. }
  49455. declare module BABYLON {
  49456. /**
  49457. * Single axis drag gizmo
  49458. */
  49459. export class AxisDragGizmo extends Gizmo {
  49460. /**
  49461. * Drag behavior responsible for the gizmos dragging interactions
  49462. */
  49463. dragBehavior: PointerDragBehavior;
  49464. private _pointerObserver;
  49465. /**
  49466. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49467. */
  49468. snapDistance: number;
  49469. /**
  49470. * Event that fires each time the gizmo snaps to a new location.
  49471. * * snapDistance is the the change in distance
  49472. */
  49473. onSnapObservable: Observable<{
  49474. snapDistance: number;
  49475. }>;
  49476. private _isEnabled;
  49477. private _parent;
  49478. private _arrow;
  49479. private _coloredMaterial;
  49480. private _hoverMaterial;
  49481. /** @hidden */
  49482. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  49483. /** @hidden */
  49484. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  49485. /**
  49486. * Creates an AxisDragGizmo
  49487. * @param gizmoLayer The utility layer the gizmo will be added to
  49488. * @param dragAxis The axis which the gizmo will be able to drag on
  49489. * @param color The color of the gizmo
  49490. */
  49491. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  49492. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49493. /**
  49494. * If the gizmo is enabled
  49495. */
  49496. set isEnabled(value: boolean);
  49497. get isEnabled(): boolean;
  49498. /**
  49499. * Disposes of the gizmo
  49500. */
  49501. dispose(): void;
  49502. }
  49503. }
  49504. declare module BABYLON.Debug {
  49505. /**
  49506. * The Axes viewer will show 3 axes in a specific point in space
  49507. */
  49508. export class AxesViewer {
  49509. private _xAxis;
  49510. private _yAxis;
  49511. private _zAxis;
  49512. private _scaleLinesFactor;
  49513. private _instanced;
  49514. /**
  49515. * Gets the hosting scene
  49516. */
  49517. scene: Scene;
  49518. /**
  49519. * Gets or sets a number used to scale line length
  49520. */
  49521. scaleLines: number;
  49522. /** Gets the node hierarchy used to render x-axis */
  49523. get xAxis(): TransformNode;
  49524. /** Gets the node hierarchy used to render y-axis */
  49525. get yAxis(): TransformNode;
  49526. /** Gets the node hierarchy used to render z-axis */
  49527. get zAxis(): TransformNode;
  49528. /**
  49529. * Creates a new AxesViewer
  49530. * @param scene defines the hosting scene
  49531. * @param scaleLines defines a number used to scale line length (1 by default)
  49532. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  49533. * @param xAxis defines the node hierarchy used to render the x-axis
  49534. * @param yAxis defines the node hierarchy used to render the y-axis
  49535. * @param zAxis defines the node hierarchy used to render the z-axis
  49536. */
  49537. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  49538. /**
  49539. * Force the viewer to update
  49540. * @param position defines the position of the viewer
  49541. * @param xaxis defines the x axis of the viewer
  49542. * @param yaxis defines the y axis of the viewer
  49543. * @param zaxis defines the z axis of the viewer
  49544. */
  49545. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  49546. /**
  49547. * Creates an instance of this axes viewer.
  49548. * @returns a new axes viewer with instanced meshes
  49549. */
  49550. createInstance(): AxesViewer;
  49551. /** Releases resources */
  49552. dispose(): void;
  49553. private static _SetRenderingGroupId;
  49554. }
  49555. }
  49556. declare module BABYLON.Debug {
  49557. /**
  49558. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  49559. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  49560. */
  49561. export class BoneAxesViewer extends AxesViewer {
  49562. /**
  49563. * Gets or sets the target mesh where to display the axes viewer
  49564. */
  49565. mesh: Nullable<Mesh>;
  49566. /**
  49567. * Gets or sets the target bone where to display the axes viewer
  49568. */
  49569. bone: Nullable<Bone>;
  49570. /** Gets current position */
  49571. pos: Vector3;
  49572. /** Gets direction of X axis */
  49573. xaxis: Vector3;
  49574. /** Gets direction of Y axis */
  49575. yaxis: Vector3;
  49576. /** Gets direction of Z axis */
  49577. zaxis: Vector3;
  49578. /**
  49579. * Creates a new BoneAxesViewer
  49580. * @param scene defines the hosting scene
  49581. * @param bone defines the target bone
  49582. * @param mesh defines the target mesh
  49583. * @param scaleLines defines a scaling factor for line length (1 by default)
  49584. */
  49585. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  49586. /**
  49587. * Force the viewer to update
  49588. */
  49589. update(): void;
  49590. /** Releases resources */
  49591. dispose(): void;
  49592. }
  49593. }
  49594. declare module BABYLON {
  49595. /**
  49596. * Interface used to define scene explorer extensibility option
  49597. */
  49598. export interface IExplorerExtensibilityOption {
  49599. /**
  49600. * Define the option label
  49601. */
  49602. label: string;
  49603. /**
  49604. * Defines the action to execute on click
  49605. */
  49606. action: (entity: any) => void;
  49607. }
  49608. /**
  49609. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  49610. */
  49611. export interface IExplorerExtensibilityGroup {
  49612. /**
  49613. * Defines a predicate to test if a given type mut be extended
  49614. */
  49615. predicate: (entity: any) => boolean;
  49616. /**
  49617. * Gets the list of options added to a type
  49618. */
  49619. entries: IExplorerExtensibilityOption[];
  49620. }
  49621. /**
  49622. * Interface used to define the options to use to create the Inspector
  49623. */
  49624. export interface IInspectorOptions {
  49625. /**
  49626. * Display in overlay mode (default: false)
  49627. */
  49628. overlay?: boolean;
  49629. /**
  49630. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  49631. */
  49632. globalRoot?: HTMLElement;
  49633. /**
  49634. * Display the Scene explorer
  49635. */
  49636. showExplorer?: boolean;
  49637. /**
  49638. * Display the property inspector
  49639. */
  49640. showInspector?: boolean;
  49641. /**
  49642. * Display in embed mode (both panes on the right)
  49643. */
  49644. embedMode?: boolean;
  49645. /**
  49646. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  49647. */
  49648. handleResize?: boolean;
  49649. /**
  49650. * Allow the panes to popup (default: true)
  49651. */
  49652. enablePopup?: boolean;
  49653. /**
  49654. * Allow the panes to be closed by users (default: true)
  49655. */
  49656. enableClose?: boolean;
  49657. /**
  49658. * Optional list of extensibility entries
  49659. */
  49660. explorerExtensibility?: IExplorerExtensibilityGroup[];
  49661. /**
  49662. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  49663. */
  49664. inspectorURL?: string;
  49665. /**
  49666. * Optional initial tab (default to DebugLayerTab.Properties)
  49667. */
  49668. initialTab?: DebugLayerTab;
  49669. }
  49670. interface Scene {
  49671. /**
  49672. * @hidden
  49673. * Backing field
  49674. */
  49675. _debugLayer: DebugLayer;
  49676. /**
  49677. * Gets the debug layer (aka Inspector) associated with the scene
  49678. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49679. */
  49680. debugLayer: DebugLayer;
  49681. }
  49682. /**
  49683. * Enum of inspector action tab
  49684. */
  49685. export enum DebugLayerTab {
  49686. /**
  49687. * Properties tag (default)
  49688. */
  49689. Properties = 0,
  49690. /**
  49691. * Debug tab
  49692. */
  49693. Debug = 1,
  49694. /**
  49695. * Statistics tab
  49696. */
  49697. Statistics = 2,
  49698. /**
  49699. * Tools tab
  49700. */
  49701. Tools = 3,
  49702. /**
  49703. * Settings tab
  49704. */
  49705. Settings = 4
  49706. }
  49707. /**
  49708. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49709. * what is happening in your scene
  49710. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49711. */
  49712. export class DebugLayer {
  49713. /**
  49714. * Define the url to get the inspector script from.
  49715. * By default it uses the babylonjs CDN.
  49716. * @ignoreNaming
  49717. */
  49718. static InspectorURL: string;
  49719. private _scene;
  49720. private BJSINSPECTOR;
  49721. private _onPropertyChangedObservable?;
  49722. /**
  49723. * Observable triggered when a property is changed through the inspector.
  49724. */
  49725. get onPropertyChangedObservable(): any;
  49726. /**
  49727. * Instantiates a new debug layer.
  49728. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49729. * what is happening in your scene
  49730. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49731. * @param scene Defines the scene to inspect
  49732. */
  49733. constructor(scene: Scene);
  49734. /** Creates the inspector window. */
  49735. private _createInspector;
  49736. /**
  49737. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  49738. * @param entity defines the entity to select
  49739. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  49740. */
  49741. select(entity: any, lineContainerTitles?: string | string[]): void;
  49742. /** Get the inspector from bundle or global */
  49743. private _getGlobalInspector;
  49744. /**
  49745. * Get if the inspector is visible or not.
  49746. * @returns true if visible otherwise, false
  49747. */
  49748. isVisible(): boolean;
  49749. /**
  49750. * Hide the inspector and close its window.
  49751. */
  49752. hide(): void;
  49753. /**
  49754. * Update the scene in the inspector
  49755. */
  49756. setAsActiveScene(): void;
  49757. /**
  49758. * Launch the debugLayer.
  49759. * @param config Define the configuration of the inspector
  49760. * @return a promise fulfilled when the debug layer is visible
  49761. */
  49762. show(config?: IInspectorOptions): Promise<DebugLayer>;
  49763. }
  49764. }
  49765. declare module BABYLON {
  49766. /**
  49767. * Class containing static functions to help procedurally build meshes
  49768. */
  49769. export class BoxBuilder {
  49770. /**
  49771. * Creates a box mesh
  49772. * * The parameter `size` sets the size (float) of each box side (default 1)
  49773. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49774. * * 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)
  49775. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49776. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49777. * * 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
  49778. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49779. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49780. * @param name defines the name of the mesh
  49781. * @param options defines the options used to create the mesh
  49782. * @param scene defines the hosting scene
  49783. * @returns the box mesh
  49784. */
  49785. static CreateBox(name: string, options: {
  49786. size?: number;
  49787. width?: number;
  49788. height?: number;
  49789. depth?: number;
  49790. faceUV?: Vector4[];
  49791. faceColors?: Color4[];
  49792. sideOrientation?: number;
  49793. frontUVs?: Vector4;
  49794. backUVs?: Vector4;
  49795. wrap?: boolean;
  49796. topBaseAt?: number;
  49797. bottomBaseAt?: number;
  49798. updatable?: boolean;
  49799. }, scene?: Nullable<Scene>): Mesh;
  49800. }
  49801. }
  49802. declare module BABYLON.Debug {
  49803. /**
  49804. * Used to show the physics impostor around the specific mesh
  49805. */
  49806. export class PhysicsViewer {
  49807. /** @hidden */
  49808. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  49809. /** @hidden */
  49810. protected _meshes: Array<Nullable<AbstractMesh>>;
  49811. /** @hidden */
  49812. protected _scene: Nullable<Scene>;
  49813. /** @hidden */
  49814. protected _numMeshes: number;
  49815. /** @hidden */
  49816. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  49817. private _renderFunction;
  49818. private _utilityLayer;
  49819. private _debugBoxMesh;
  49820. private _debugSphereMesh;
  49821. private _debugCylinderMesh;
  49822. private _debugMaterial;
  49823. private _debugMeshMeshes;
  49824. /**
  49825. * Creates a new PhysicsViewer
  49826. * @param scene defines the hosting scene
  49827. */
  49828. constructor(scene: Scene);
  49829. /** @hidden */
  49830. protected _updateDebugMeshes(): void;
  49831. /**
  49832. * Renders a specified physic impostor
  49833. * @param impostor defines the impostor to render
  49834. * @param targetMesh defines the mesh represented by the impostor
  49835. * @returns the new debug mesh used to render the impostor
  49836. */
  49837. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  49838. /**
  49839. * Hides a specified physic impostor
  49840. * @param impostor defines the impostor to hide
  49841. */
  49842. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  49843. private _getDebugMaterial;
  49844. private _getDebugBoxMesh;
  49845. private _getDebugSphereMesh;
  49846. private _getDebugCylinderMesh;
  49847. private _getDebugMeshMesh;
  49848. private _getDebugMesh;
  49849. /** Releases all resources */
  49850. dispose(): void;
  49851. }
  49852. }
  49853. declare module BABYLON {
  49854. /**
  49855. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  49856. * in order to better appreciate the issue one might have.
  49857. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  49858. */
  49859. export class RayHelper {
  49860. /**
  49861. * Defines the ray we are currently tryin to visualize.
  49862. */
  49863. ray: Nullable<Ray>;
  49864. private _renderPoints;
  49865. private _renderLine;
  49866. private _renderFunction;
  49867. private _scene;
  49868. private _updateToMeshFunction;
  49869. private _attachedToMesh;
  49870. private _meshSpaceDirection;
  49871. private _meshSpaceOrigin;
  49872. /**
  49873. * Helper function to create a colored helper in a scene in one line.
  49874. * @param ray Defines the ray we are currently tryin to visualize
  49875. * @param scene Defines the scene the ray is used in
  49876. * @param color Defines the color we want to see the ray in
  49877. * @returns The newly created ray helper.
  49878. */
  49879. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  49880. /**
  49881. * Instantiate a new ray helper.
  49882. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  49883. * in order to better appreciate the issue one might have.
  49884. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  49885. * @param ray Defines the ray we are currently tryin to visualize
  49886. */
  49887. constructor(ray: Ray);
  49888. /**
  49889. * Shows the ray we are willing to debug.
  49890. * @param scene Defines the scene the ray needs to be rendered in
  49891. * @param color Defines the color the ray needs to be rendered in
  49892. */
  49893. show(scene: Scene, color?: Color3): void;
  49894. /**
  49895. * Hides the ray we are debugging.
  49896. */
  49897. hide(): void;
  49898. private _render;
  49899. /**
  49900. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  49901. * @param mesh Defines the mesh we want the helper attached to
  49902. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  49903. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  49904. * @param length Defines the length of the ray
  49905. */
  49906. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  49907. /**
  49908. * Detach the ray helper from the mesh it has previously been attached to.
  49909. */
  49910. detachFromMesh(): void;
  49911. private _updateToMesh;
  49912. /**
  49913. * Dispose the helper and release its associated resources.
  49914. */
  49915. dispose(): void;
  49916. }
  49917. }
  49918. declare module BABYLON.Debug {
  49919. /**
  49920. * Class used to render a debug view of a given skeleton
  49921. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  49922. */
  49923. export class SkeletonViewer {
  49924. /** defines the skeleton to render */
  49925. skeleton: Skeleton;
  49926. /** defines the mesh attached to the skeleton */
  49927. mesh: AbstractMesh;
  49928. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  49929. autoUpdateBonesMatrices: boolean;
  49930. /** defines the rendering group id to use with the viewer */
  49931. renderingGroupId: number;
  49932. /** Gets or sets the color used to render the skeleton */
  49933. color: Color3;
  49934. private _scene;
  49935. private _debugLines;
  49936. private _debugMesh;
  49937. private _isEnabled;
  49938. private _renderFunction;
  49939. private _utilityLayer;
  49940. /**
  49941. * Returns the mesh used to render the bones
  49942. */
  49943. get debugMesh(): Nullable<LinesMesh>;
  49944. /**
  49945. * Creates a new SkeletonViewer
  49946. * @param skeleton defines the skeleton to render
  49947. * @param mesh defines the mesh attached to the skeleton
  49948. * @param scene defines the hosting scene
  49949. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  49950. * @param renderingGroupId defines the rendering group id to use with the viewer
  49951. */
  49952. constructor(
  49953. /** defines the skeleton to render */
  49954. skeleton: Skeleton,
  49955. /** defines the mesh attached to the skeleton */
  49956. mesh: AbstractMesh, scene: Scene,
  49957. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  49958. autoUpdateBonesMatrices?: boolean,
  49959. /** defines the rendering group id to use with the viewer */
  49960. renderingGroupId?: number);
  49961. /** Gets or sets a boolean indicating if the viewer is enabled */
  49962. set isEnabled(value: boolean);
  49963. get isEnabled(): boolean;
  49964. private _getBonePosition;
  49965. private _getLinesForBonesWithLength;
  49966. private _getLinesForBonesNoLength;
  49967. /** Update the viewer to sync with current skeleton state */
  49968. update(): void;
  49969. /** Release associated resources */
  49970. dispose(): void;
  49971. }
  49972. }
  49973. declare module BABYLON {
  49974. /**
  49975. * Enum for Device Types
  49976. */
  49977. export enum DeviceType {
  49978. /** Generic */
  49979. Generic = 0,
  49980. /** Keyboard */
  49981. Keyboard = 1,
  49982. /** Mouse */
  49983. Mouse = 2,
  49984. /** Touch Pointers */
  49985. Touch = 3,
  49986. /** PS4 Dual Shock */
  49987. DualShock = 4,
  49988. /** Xbox */
  49989. Xbox = 5,
  49990. /** Switch Controller */
  49991. Switch = 6
  49992. }
  49993. /**
  49994. * Enum for All Pointers (Touch/Mouse)
  49995. */
  49996. export enum PointerInput {
  49997. /** Horizontal Axis */
  49998. Horizontal = 0,
  49999. /** Vertical Axis */
  50000. Vertical = 1,
  50001. /** Left Click or Touch */
  50002. LeftClick = 2,
  50003. /** Middle Click */
  50004. MiddleClick = 3,
  50005. /** Right Click */
  50006. RightClick = 4,
  50007. /** Browser Back */
  50008. BrowserBack = 5,
  50009. /** Browser Forward */
  50010. BrowserForward = 6
  50011. }
  50012. /**
  50013. * Enum for Dual Shock Gamepad
  50014. */
  50015. export enum DualShockInput {
  50016. /** Cross */
  50017. Cross = 0,
  50018. /** Circle */
  50019. Circle = 1,
  50020. /** Square */
  50021. Square = 2,
  50022. /** Triangle */
  50023. Triangle = 3,
  50024. /** L1 */
  50025. L1 = 4,
  50026. /** R1 */
  50027. R1 = 5,
  50028. /** L2 */
  50029. L2 = 6,
  50030. /** R2 */
  50031. R2 = 7,
  50032. /** Share */
  50033. Share = 8,
  50034. /** Options */
  50035. Options = 9,
  50036. /** L3 */
  50037. L3 = 10,
  50038. /** R3 */
  50039. R3 = 11,
  50040. /** DPadUp */
  50041. DPadUp = 12,
  50042. /** DPadDown */
  50043. DPadDown = 13,
  50044. /** DPadLeft */
  50045. DPadLeft = 14,
  50046. /** DRight */
  50047. DPadRight = 15,
  50048. /** Home */
  50049. Home = 16,
  50050. /** TouchPad */
  50051. TouchPad = 17,
  50052. /** LStickXAxis */
  50053. LStickXAxis = 18,
  50054. /** LStickYAxis */
  50055. LStickYAxis = 19,
  50056. /** RStickXAxis */
  50057. RStickXAxis = 20,
  50058. /** RStickYAxis */
  50059. RStickYAxis = 21
  50060. }
  50061. /**
  50062. * Enum for Xbox Gamepad
  50063. */
  50064. export enum XboxInput {
  50065. /** A */
  50066. A = 0,
  50067. /** B */
  50068. B = 1,
  50069. /** X */
  50070. X = 2,
  50071. /** Y */
  50072. Y = 3,
  50073. /** LB */
  50074. LB = 4,
  50075. /** RB */
  50076. RB = 5,
  50077. /** LT */
  50078. LT = 6,
  50079. /** RT */
  50080. RT = 7,
  50081. /** Back */
  50082. Back = 8,
  50083. /** Start */
  50084. Start = 9,
  50085. /** LS */
  50086. LS = 10,
  50087. /** RS */
  50088. RS = 11,
  50089. /** DPadUp */
  50090. DPadUp = 12,
  50091. /** DPadDown */
  50092. DPadDown = 13,
  50093. /** DPadLeft */
  50094. DPadLeft = 14,
  50095. /** DRight */
  50096. DPadRight = 15,
  50097. /** Home */
  50098. Home = 16,
  50099. /** LStickXAxis */
  50100. LStickXAxis = 17,
  50101. /** LStickYAxis */
  50102. LStickYAxis = 18,
  50103. /** RStickXAxis */
  50104. RStickXAxis = 19,
  50105. /** RStickYAxis */
  50106. RStickYAxis = 20
  50107. }
  50108. /**
  50109. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  50110. */
  50111. export enum SwitchInput {
  50112. /** B */
  50113. B = 0,
  50114. /** A */
  50115. A = 1,
  50116. /** Y */
  50117. Y = 2,
  50118. /** X */
  50119. X = 3,
  50120. /** L */
  50121. L = 4,
  50122. /** R */
  50123. R = 5,
  50124. /** ZL */
  50125. ZL = 6,
  50126. /** ZR */
  50127. ZR = 7,
  50128. /** Minus */
  50129. Minus = 8,
  50130. /** Plus */
  50131. Plus = 9,
  50132. /** LS */
  50133. LS = 10,
  50134. /** RS */
  50135. RS = 11,
  50136. /** DPadUp */
  50137. DPadUp = 12,
  50138. /** DPadDown */
  50139. DPadDown = 13,
  50140. /** DPadLeft */
  50141. DPadLeft = 14,
  50142. /** DRight */
  50143. DPadRight = 15,
  50144. /** Home */
  50145. Home = 16,
  50146. /** Capture */
  50147. Capture = 17,
  50148. /** LStickXAxis */
  50149. LStickXAxis = 18,
  50150. /** LStickYAxis */
  50151. LStickYAxis = 19,
  50152. /** RStickXAxis */
  50153. RStickXAxis = 20,
  50154. /** RStickYAxis */
  50155. RStickYAxis = 21
  50156. }
  50157. }
  50158. declare module BABYLON {
  50159. /**
  50160. * This class will take all inputs from Keyboard, Pointer, and
  50161. * any Gamepads and provide a polling system that all devices
  50162. * will use. This class assumes that there will only be one
  50163. * pointer device and one keyboard.
  50164. */
  50165. export class DeviceInputSystem implements IDisposable {
  50166. /**
  50167. * Callback to be triggered when a device is connected
  50168. */
  50169. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  50170. /**
  50171. * Callback to be triggered when a device is disconnected
  50172. */
  50173. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  50174. /**
  50175. * Callback to be triggered when event driven input is updated
  50176. */
  50177. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  50178. private _inputs;
  50179. private _gamepads;
  50180. private _keyboardActive;
  50181. private _pointerActive;
  50182. private _elementToAttachTo;
  50183. private _keyboardDownEvent;
  50184. private _keyboardUpEvent;
  50185. private _pointerMoveEvent;
  50186. private _pointerDownEvent;
  50187. private _pointerUpEvent;
  50188. private _gamepadConnectedEvent;
  50189. private _gamepadDisconnectedEvent;
  50190. private static _MAX_KEYCODES;
  50191. private static _MAX_POINTER_INPUTS;
  50192. private constructor();
  50193. /**
  50194. * Creates a new DeviceInputSystem instance
  50195. * @param engine Engine to pull input element from
  50196. * @returns The new instance
  50197. */
  50198. static Create(engine: Engine): DeviceInputSystem;
  50199. /**
  50200. * Checks for current device input value, given an id and input index
  50201. * @param deviceName Id of connected device
  50202. * @param inputIndex Index of device input
  50203. * @returns Current value of input
  50204. */
  50205. /**
  50206. * Checks for current device input value, given an id and input index
  50207. * @param deviceType Enum specifiying device type
  50208. * @param deviceSlot "Slot" or index that device is referenced in
  50209. * @param inputIndex Id of input to be checked
  50210. * @returns Current value of input
  50211. */
  50212. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  50213. /**
  50214. * Dispose of all the eventlisteners
  50215. */
  50216. dispose(): void;
  50217. /**
  50218. * Add device and inputs to device array
  50219. * @param deviceType Enum specifiying device type
  50220. * @param deviceSlot "Slot" or index that device is referenced in
  50221. * @param numberOfInputs Number of input entries to create for given device
  50222. */
  50223. private _registerDevice;
  50224. /**
  50225. * Given a specific device name, remove that device from the device map
  50226. * @param deviceType Enum specifiying device type
  50227. * @param deviceSlot "Slot" or index that device is referenced in
  50228. */
  50229. private _unregisterDevice;
  50230. /**
  50231. * Handle all actions that come from keyboard interaction
  50232. */
  50233. private _handleKeyActions;
  50234. /**
  50235. * Handle all actions that come from pointer interaction
  50236. */
  50237. private _handlePointerActions;
  50238. /**
  50239. * Handle all actions that come from gamepad interaction
  50240. */
  50241. private _handleGamepadActions;
  50242. /**
  50243. * Update all non-event based devices with each frame
  50244. * @param deviceType Enum specifiying device type
  50245. * @param deviceSlot "Slot" or index that device is referenced in
  50246. * @param inputIndex Id of input to be checked
  50247. */
  50248. private _updateDevice;
  50249. /**
  50250. * Gets DeviceType from the device name
  50251. * @param deviceName Name of Device from DeviceInputSystem
  50252. * @returns DeviceType enum value
  50253. */
  50254. private _getGamepadDeviceType;
  50255. }
  50256. }
  50257. declare module BABYLON {
  50258. /**
  50259. * Type to handle enforcement of inputs
  50260. */
  50261. 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;
  50262. }
  50263. declare module BABYLON {
  50264. /**
  50265. * Class that handles all input for a specific device
  50266. */
  50267. export class DeviceSource<T extends DeviceType> {
  50268. /** Type of device */
  50269. readonly deviceType: DeviceType;
  50270. /** "Slot" or index that device is referenced in */
  50271. readonly deviceSlot: number;
  50272. /**
  50273. * Observable to handle device input changes per device
  50274. */
  50275. readonly onInputChangedObservable: Observable<{
  50276. inputIndex: DeviceInput<T>;
  50277. previousState: Nullable<number>;
  50278. currentState: Nullable<number>;
  50279. }>;
  50280. private readonly _deviceInputSystem;
  50281. /**
  50282. * Default Constructor
  50283. * @param deviceInputSystem Reference to DeviceInputSystem
  50284. * @param deviceType Type of device
  50285. * @param deviceSlot "Slot" or index that device is referenced in
  50286. */
  50287. constructor(deviceInputSystem: DeviceInputSystem,
  50288. /** Type of device */
  50289. deviceType: DeviceType,
  50290. /** "Slot" or index that device is referenced in */
  50291. deviceSlot?: number);
  50292. /**
  50293. * Get input for specific input
  50294. * @param inputIndex index of specific input on device
  50295. * @returns Input value from DeviceInputSystem
  50296. */
  50297. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  50298. }
  50299. /**
  50300. * Class to keep track of devices
  50301. */
  50302. export class DeviceSourceManager implements IDisposable {
  50303. /**
  50304. * Observable to be triggered when before a device is connected
  50305. */
  50306. readonly onBeforeDeviceConnectedObservable: Observable<{
  50307. deviceType: DeviceType;
  50308. deviceSlot: number;
  50309. }>;
  50310. /**
  50311. * Observable to be triggered when before a device is disconnected
  50312. */
  50313. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  50314. deviceType: DeviceType;
  50315. deviceSlot: number;
  50316. }>;
  50317. /**
  50318. * Observable to be triggered when after a device is connected
  50319. */
  50320. readonly onAfterDeviceConnectedObservable: Observable<{
  50321. deviceType: DeviceType;
  50322. deviceSlot: number;
  50323. }>;
  50324. /**
  50325. * Observable to be triggered when after a device is disconnected
  50326. */
  50327. readonly onAfterDeviceDisconnectedObservable: Observable<{
  50328. deviceType: DeviceType;
  50329. deviceSlot: number;
  50330. }>;
  50331. private readonly _devices;
  50332. private readonly _firstDevice;
  50333. private readonly _deviceInputSystem;
  50334. /**
  50335. * Default Constructor
  50336. * @param engine engine to pull input element from
  50337. */
  50338. constructor(engine: Engine);
  50339. /**
  50340. * Gets a DeviceSource, given a type and slot
  50341. * @param deviceType Enum specifying device type
  50342. * @param deviceSlot "Slot" or index that device is referenced in
  50343. * @returns DeviceSource object
  50344. */
  50345. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  50346. /**
  50347. * Gets an array of DeviceSource objects for a given device type
  50348. * @param deviceType Enum specifying device type
  50349. * @returns Array of DeviceSource objects
  50350. */
  50351. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  50352. /**
  50353. * Dispose of DeviceInputSystem and other parts
  50354. */
  50355. dispose(): void;
  50356. /**
  50357. * Function to add device name to device list
  50358. * @param deviceType Enum specifying device type
  50359. * @param deviceSlot "Slot" or index that device is referenced in
  50360. */
  50361. private _addDevice;
  50362. /**
  50363. * Function to remove device name to device list
  50364. * @param deviceType Enum specifying device type
  50365. * @param deviceSlot "Slot" or index that device is referenced in
  50366. */
  50367. private _removeDevice;
  50368. /**
  50369. * Updates array storing first connected device of each type
  50370. * @param type Type of Device
  50371. */
  50372. private _updateFirstDevices;
  50373. }
  50374. }
  50375. declare module BABYLON {
  50376. /**
  50377. * Options to create the null engine
  50378. */
  50379. export class NullEngineOptions {
  50380. /**
  50381. * Render width (Default: 512)
  50382. */
  50383. renderWidth: number;
  50384. /**
  50385. * Render height (Default: 256)
  50386. */
  50387. renderHeight: number;
  50388. /**
  50389. * Texture size (Default: 512)
  50390. */
  50391. textureSize: number;
  50392. /**
  50393. * If delta time between frames should be constant
  50394. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50395. */
  50396. deterministicLockstep: boolean;
  50397. /**
  50398. * Maximum about of steps between frames (Default: 4)
  50399. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50400. */
  50401. lockstepMaxSteps: number;
  50402. }
  50403. /**
  50404. * The null engine class provides support for headless version of babylon.js.
  50405. * This can be used in server side scenario or for testing purposes
  50406. */
  50407. export class NullEngine extends Engine {
  50408. private _options;
  50409. /**
  50410. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  50411. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50412. * @returns true if engine is in deterministic lock step mode
  50413. */
  50414. isDeterministicLockStep(): boolean;
  50415. /**
  50416. * Gets the max steps when engine is running in deterministic lock step
  50417. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50418. * @returns the max steps
  50419. */
  50420. getLockstepMaxSteps(): number;
  50421. /**
  50422. * Gets the current hardware scaling level.
  50423. * By default the hardware scaling level is computed from the window device ratio.
  50424. * 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.
  50425. * @returns a number indicating the current hardware scaling level
  50426. */
  50427. getHardwareScalingLevel(): number;
  50428. constructor(options?: NullEngineOptions);
  50429. /**
  50430. * Creates a vertex buffer
  50431. * @param vertices the data for the vertex buffer
  50432. * @returns the new WebGL static buffer
  50433. */
  50434. createVertexBuffer(vertices: FloatArray): DataBuffer;
  50435. /**
  50436. * Creates a new index buffer
  50437. * @param indices defines the content of the index buffer
  50438. * @param updatable defines if the index buffer must be updatable
  50439. * @returns a new webGL buffer
  50440. */
  50441. createIndexBuffer(indices: IndicesArray): DataBuffer;
  50442. /**
  50443. * Clear the current render buffer or the current render target (if any is set up)
  50444. * @param color defines the color to use
  50445. * @param backBuffer defines if the back buffer must be cleared
  50446. * @param depth defines if the depth buffer must be cleared
  50447. * @param stencil defines if the stencil buffer must be cleared
  50448. */
  50449. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  50450. /**
  50451. * Gets the current render width
  50452. * @param useScreen defines if screen size must be used (or the current render target if any)
  50453. * @returns a number defining the current render width
  50454. */
  50455. getRenderWidth(useScreen?: boolean): number;
  50456. /**
  50457. * Gets the current render height
  50458. * @param useScreen defines if screen size must be used (or the current render target if any)
  50459. * @returns a number defining the current render height
  50460. */
  50461. getRenderHeight(useScreen?: boolean): number;
  50462. /**
  50463. * Set the WebGL's viewport
  50464. * @param viewport defines the viewport element to be used
  50465. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  50466. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  50467. */
  50468. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  50469. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  50470. /**
  50471. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  50472. * @param pipelineContext defines the pipeline context to use
  50473. * @param uniformsNames defines the list of uniform names
  50474. * @returns an array of webGL uniform locations
  50475. */
  50476. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  50477. /**
  50478. * Gets the lsit of active attributes for a given webGL program
  50479. * @param pipelineContext defines the pipeline context to use
  50480. * @param attributesNames defines the list of attribute names to get
  50481. * @returns an array of indices indicating the offset of each attribute
  50482. */
  50483. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  50484. /**
  50485. * Binds an effect to the webGL context
  50486. * @param effect defines the effect to bind
  50487. */
  50488. bindSamplers(effect: Effect): void;
  50489. /**
  50490. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  50491. * @param effect defines the effect to activate
  50492. */
  50493. enableEffect(effect: Effect): void;
  50494. /**
  50495. * Set various states to the webGL context
  50496. * @param culling defines backface culling state
  50497. * @param zOffset defines the value to apply to zOffset (0 by default)
  50498. * @param force defines if states must be applied even if cache is up to date
  50499. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  50500. */
  50501. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  50502. /**
  50503. * Set the value of an uniform to an array of int32
  50504. * @param uniform defines the webGL uniform location where to store the value
  50505. * @param array defines the array of int32 to store
  50506. */
  50507. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  50508. /**
  50509. * Set the value of an uniform to an array of int32 (stored as vec2)
  50510. * @param uniform defines the webGL uniform location where to store the value
  50511. * @param array defines the array of int32 to store
  50512. */
  50513. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  50514. /**
  50515. * Set the value of an uniform to an array of int32 (stored as vec3)
  50516. * @param uniform defines the webGL uniform location where to store the value
  50517. * @param array defines the array of int32 to store
  50518. */
  50519. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  50520. /**
  50521. * Set the value of an uniform to an array of int32 (stored as vec4)
  50522. * @param uniform defines the webGL uniform location where to store the value
  50523. * @param array defines the array of int32 to store
  50524. */
  50525. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  50526. /**
  50527. * Set the value of an uniform to an array of float32
  50528. * @param uniform defines the webGL uniform location where to store the value
  50529. * @param array defines the array of float32 to store
  50530. */
  50531. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  50532. /**
  50533. * Set the value of an uniform to an array of float32 (stored as vec2)
  50534. * @param uniform defines the webGL uniform location where to store the value
  50535. * @param array defines the array of float32 to store
  50536. */
  50537. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  50538. /**
  50539. * Set the value of an uniform to an array of float32 (stored as vec3)
  50540. * @param uniform defines the webGL uniform location where to store the value
  50541. * @param array defines the array of float32 to store
  50542. */
  50543. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  50544. /**
  50545. * Set the value of an uniform to an array of float32 (stored as vec4)
  50546. * @param uniform defines the webGL uniform location where to store the value
  50547. * @param array defines the array of float32 to store
  50548. */
  50549. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  50550. /**
  50551. * Set the value of an uniform to an array of number
  50552. * @param uniform defines the webGL uniform location where to store the value
  50553. * @param array defines the array of number to store
  50554. */
  50555. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  50556. /**
  50557. * Set the value of an uniform to an array of number (stored as vec2)
  50558. * @param uniform defines the webGL uniform location where to store the value
  50559. * @param array defines the array of number to store
  50560. */
  50561. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  50562. /**
  50563. * Set the value of an uniform to an array of number (stored as vec3)
  50564. * @param uniform defines the webGL uniform location where to store the value
  50565. * @param array defines the array of number to store
  50566. */
  50567. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  50568. /**
  50569. * Set the value of an uniform to an array of number (stored as vec4)
  50570. * @param uniform defines the webGL uniform location where to store the value
  50571. * @param array defines the array of number to store
  50572. */
  50573. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  50574. /**
  50575. * Set the value of an uniform to an array of float32 (stored as matrices)
  50576. * @param uniform defines the webGL uniform location where to store the value
  50577. * @param matrices defines the array of float32 to store
  50578. */
  50579. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  50580. /**
  50581. * Set the value of an uniform to a matrix (3x3)
  50582. * @param uniform defines the webGL uniform location where to store the value
  50583. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  50584. */
  50585. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50586. /**
  50587. * Set the value of an uniform to a matrix (2x2)
  50588. * @param uniform defines the webGL uniform location where to store the value
  50589. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  50590. */
  50591. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50592. /**
  50593. * Set the value of an uniform to a number (float)
  50594. * @param uniform defines the webGL uniform location where to store the value
  50595. * @param value defines the float number to store
  50596. */
  50597. setFloat(uniform: WebGLUniformLocation, value: number): void;
  50598. /**
  50599. * Set the value of an uniform to a vec2
  50600. * @param uniform defines the webGL uniform location where to store the value
  50601. * @param x defines the 1st component of the value
  50602. * @param y defines the 2nd component of the value
  50603. */
  50604. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  50605. /**
  50606. * Set the value of an uniform to a vec3
  50607. * @param uniform defines the webGL uniform location where to store the value
  50608. * @param x defines the 1st component of the value
  50609. * @param y defines the 2nd component of the value
  50610. * @param z defines the 3rd component of the value
  50611. */
  50612. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  50613. /**
  50614. * Set the value of an uniform to a boolean
  50615. * @param uniform defines the webGL uniform location where to store the value
  50616. * @param bool defines the boolean to store
  50617. */
  50618. setBool(uniform: WebGLUniformLocation, bool: number): void;
  50619. /**
  50620. * Set the value of an uniform to a vec4
  50621. * @param uniform defines the webGL uniform location where to store the value
  50622. * @param x defines the 1st component of the value
  50623. * @param y defines the 2nd component of the value
  50624. * @param z defines the 3rd component of the value
  50625. * @param w defines the 4th component of the value
  50626. */
  50627. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  50628. /**
  50629. * Sets the current alpha mode
  50630. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  50631. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  50632. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  50633. */
  50634. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  50635. /**
  50636. * Bind webGl buffers directly to the webGL context
  50637. * @param vertexBuffers defines the vertex buffer to bind
  50638. * @param indexBuffer defines the index buffer to bind
  50639. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  50640. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  50641. * @param effect defines the effect associated with the vertex buffer
  50642. */
  50643. bindBuffers(vertexBuffers: {
  50644. [key: string]: VertexBuffer;
  50645. }, indexBuffer: DataBuffer, effect: Effect): void;
  50646. /**
  50647. * Force the entire cache to be cleared
  50648. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  50649. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  50650. */
  50651. wipeCaches(bruteForce?: boolean): void;
  50652. /**
  50653. * Send a draw order
  50654. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  50655. * @param indexStart defines the starting index
  50656. * @param indexCount defines the number of index to draw
  50657. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50658. */
  50659. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  50660. /**
  50661. * Draw a list of indexed primitives
  50662. * @param fillMode defines the primitive to use
  50663. * @param indexStart defines the starting index
  50664. * @param indexCount defines the number of index to draw
  50665. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50666. */
  50667. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  50668. /**
  50669. * Draw a list of unindexed primitives
  50670. * @param fillMode defines the primitive to use
  50671. * @param verticesStart defines the index of first vertex to draw
  50672. * @param verticesCount defines the count of vertices to draw
  50673. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50674. */
  50675. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  50676. /** @hidden */
  50677. _createTexture(): WebGLTexture;
  50678. /** @hidden */
  50679. _releaseTexture(texture: InternalTexture): void;
  50680. /**
  50681. * Usually called from Texture.ts.
  50682. * Passed information to create a WebGLTexture
  50683. * @param urlArg defines a value which contains one of the following:
  50684. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  50685. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  50686. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  50687. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  50688. * @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)
  50689. * @param scene needed for loading to the correct scene
  50690. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  50691. * @param onLoad optional callback to be called upon successful completion
  50692. * @param onError optional callback to be called upon failure
  50693. * @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
  50694. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  50695. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  50696. * @param forcedExtension defines the extension to use to pick the right loader
  50697. * @param mimeType defines an optional mime type
  50698. * @returns a InternalTexture for assignment back into BABYLON.Texture
  50699. */
  50700. 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;
  50701. /**
  50702. * Creates a new render target texture
  50703. * @param size defines the size of the texture
  50704. * @param options defines the options used to create the texture
  50705. * @returns a new render target texture stored in an InternalTexture
  50706. */
  50707. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  50708. /**
  50709. * Update the sampling mode of a given texture
  50710. * @param samplingMode defines the required sampling mode
  50711. * @param texture defines the texture to update
  50712. */
  50713. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  50714. /**
  50715. * Binds the frame buffer to the specified texture.
  50716. * @param texture The texture to render to or null for the default canvas
  50717. * @param faceIndex The face of the texture to render to in case of cube texture
  50718. * @param requiredWidth The width of the target to render to
  50719. * @param requiredHeight The height of the target to render to
  50720. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  50721. * @param lodLevel defines le lod level to bind to the frame buffer
  50722. */
  50723. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  50724. /**
  50725. * Unbind the current render target texture from the webGL context
  50726. * @param texture defines the render target texture to unbind
  50727. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  50728. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  50729. */
  50730. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  50731. /**
  50732. * Creates a dynamic vertex buffer
  50733. * @param vertices the data for the dynamic vertex buffer
  50734. * @returns the new WebGL dynamic buffer
  50735. */
  50736. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  50737. /**
  50738. * Update the content of a dynamic texture
  50739. * @param texture defines the texture to update
  50740. * @param canvas defines the canvas containing the source
  50741. * @param invertY defines if data must be stored with Y axis inverted
  50742. * @param premulAlpha defines if alpha is stored as premultiplied
  50743. * @param format defines the format of the data
  50744. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  50745. */
  50746. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  50747. /**
  50748. * Gets a boolean indicating if all created effects are ready
  50749. * @returns true if all effects are ready
  50750. */
  50751. areAllEffectsReady(): boolean;
  50752. /**
  50753. * @hidden
  50754. * Get the current error code of the webGL context
  50755. * @returns the error code
  50756. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  50757. */
  50758. getError(): number;
  50759. /** @hidden */
  50760. _getUnpackAlignement(): number;
  50761. /** @hidden */
  50762. _unpackFlipY(value: boolean): void;
  50763. /**
  50764. * Update a dynamic index buffer
  50765. * @param indexBuffer defines the target index buffer
  50766. * @param indices defines the data to update
  50767. * @param offset defines the offset in the target index buffer where update should start
  50768. */
  50769. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  50770. /**
  50771. * Updates a dynamic vertex buffer.
  50772. * @param vertexBuffer the vertex buffer to update
  50773. * @param vertices the data used to update the vertex buffer
  50774. * @param byteOffset the byte offset of the data (optional)
  50775. * @param byteLength the byte length of the data (optional)
  50776. */
  50777. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  50778. /** @hidden */
  50779. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  50780. /** @hidden */
  50781. _bindTexture(channel: number, texture: InternalTexture): void;
  50782. protected _deleteBuffer(buffer: WebGLBuffer): void;
  50783. /**
  50784. * 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
  50785. */
  50786. releaseEffects(): void;
  50787. displayLoadingUI(): void;
  50788. hideLoadingUI(): void;
  50789. /** @hidden */
  50790. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50791. /** @hidden */
  50792. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50793. /** @hidden */
  50794. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50795. /** @hidden */
  50796. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  50797. }
  50798. }
  50799. declare module BABYLON {
  50800. /**
  50801. * @hidden
  50802. **/
  50803. export class _TimeToken {
  50804. _startTimeQuery: Nullable<WebGLQuery>;
  50805. _endTimeQuery: Nullable<WebGLQuery>;
  50806. _timeElapsedQuery: Nullable<WebGLQuery>;
  50807. _timeElapsedQueryEnded: boolean;
  50808. }
  50809. }
  50810. declare module BABYLON {
  50811. /** @hidden */
  50812. export class _OcclusionDataStorage {
  50813. /** @hidden */
  50814. occlusionInternalRetryCounter: number;
  50815. /** @hidden */
  50816. isOcclusionQueryInProgress: boolean;
  50817. /** @hidden */
  50818. isOccluded: boolean;
  50819. /** @hidden */
  50820. occlusionRetryCount: number;
  50821. /** @hidden */
  50822. occlusionType: number;
  50823. /** @hidden */
  50824. occlusionQueryAlgorithmType: number;
  50825. }
  50826. interface Engine {
  50827. /**
  50828. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  50829. * @return the new query
  50830. */
  50831. createQuery(): WebGLQuery;
  50832. /**
  50833. * Delete and release a webGL query
  50834. * @param query defines the query to delete
  50835. * @return the current engine
  50836. */
  50837. deleteQuery(query: WebGLQuery): Engine;
  50838. /**
  50839. * Check if a given query has resolved and got its value
  50840. * @param query defines the query to check
  50841. * @returns true if the query got its value
  50842. */
  50843. isQueryResultAvailable(query: WebGLQuery): boolean;
  50844. /**
  50845. * Gets the value of a given query
  50846. * @param query defines the query to check
  50847. * @returns the value of the query
  50848. */
  50849. getQueryResult(query: WebGLQuery): number;
  50850. /**
  50851. * Initiates an occlusion query
  50852. * @param algorithmType defines the algorithm to use
  50853. * @param query defines the query to use
  50854. * @returns the current engine
  50855. * @see http://doc.babylonjs.com/features/occlusionquery
  50856. */
  50857. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  50858. /**
  50859. * Ends an occlusion query
  50860. * @see http://doc.babylonjs.com/features/occlusionquery
  50861. * @param algorithmType defines the algorithm to use
  50862. * @returns the current engine
  50863. */
  50864. endOcclusionQuery(algorithmType: number): Engine;
  50865. /**
  50866. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  50867. * Please note that only one query can be issued at a time
  50868. * @returns a time token used to track the time span
  50869. */
  50870. startTimeQuery(): Nullable<_TimeToken>;
  50871. /**
  50872. * Ends a time query
  50873. * @param token defines the token used to measure the time span
  50874. * @returns the time spent (in ns)
  50875. */
  50876. endTimeQuery(token: _TimeToken): int;
  50877. /** @hidden */
  50878. _currentNonTimestampToken: Nullable<_TimeToken>;
  50879. /** @hidden */
  50880. _createTimeQuery(): WebGLQuery;
  50881. /** @hidden */
  50882. _deleteTimeQuery(query: WebGLQuery): void;
  50883. /** @hidden */
  50884. _getGlAlgorithmType(algorithmType: number): number;
  50885. /** @hidden */
  50886. _getTimeQueryResult(query: WebGLQuery): any;
  50887. /** @hidden */
  50888. _getTimeQueryAvailability(query: WebGLQuery): any;
  50889. }
  50890. interface AbstractMesh {
  50891. /**
  50892. * Backing filed
  50893. * @hidden
  50894. */
  50895. __occlusionDataStorage: _OcclusionDataStorage;
  50896. /**
  50897. * Access property
  50898. * @hidden
  50899. */
  50900. _occlusionDataStorage: _OcclusionDataStorage;
  50901. /**
  50902. * 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.
  50903. * The default value is -1 which means don't break the query and wait till the result
  50904. * @see http://doc.babylonjs.com/features/occlusionquery
  50905. */
  50906. occlusionRetryCount: number;
  50907. /**
  50908. * 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:
  50909. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  50910. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  50911. * * 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.
  50912. * @see http://doc.babylonjs.com/features/occlusionquery
  50913. */
  50914. occlusionType: number;
  50915. /**
  50916. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  50917. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  50918. * * 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.
  50919. * @see http://doc.babylonjs.com/features/occlusionquery
  50920. */
  50921. occlusionQueryAlgorithmType: number;
  50922. /**
  50923. * 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
  50924. * @see http://doc.babylonjs.com/features/occlusionquery
  50925. */
  50926. isOccluded: boolean;
  50927. /**
  50928. * Flag to check the progress status of the query
  50929. * @see http://doc.babylonjs.com/features/occlusionquery
  50930. */
  50931. isOcclusionQueryInProgress: boolean;
  50932. }
  50933. }
  50934. declare module BABYLON {
  50935. /** @hidden */
  50936. export var _forceTransformFeedbackToBundle: boolean;
  50937. interface Engine {
  50938. /**
  50939. * Creates a webGL transform feedback object
  50940. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  50941. * @returns the webGL transform feedback object
  50942. */
  50943. createTransformFeedback(): WebGLTransformFeedback;
  50944. /**
  50945. * Delete a webGL transform feedback object
  50946. * @param value defines the webGL transform feedback object to delete
  50947. */
  50948. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  50949. /**
  50950. * Bind a webGL transform feedback object to the webgl context
  50951. * @param value defines the webGL transform feedback object to bind
  50952. */
  50953. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  50954. /**
  50955. * Begins a transform feedback operation
  50956. * @param usePoints defines if points or triangles must be used
  50957. */
  50958. beginTransformFeedback(usePoints: boolean): void;
  50959. /**
  50960. * Ends a transform feedback operation
  50961. */
  50962. endTransformFeedback(): void;
  50963. /**
  50964. * Specify the varyings to use with transform feedback
  50965. * @param program defines the associated webGL program
  50966. * @param value defines the list of strings representing the varying names
  50967. */
  50968. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  50969. /**
  50970. * Bind a webGL buffer for a transform feedback operation
  50971. * @param value defines the webGL buffer to bind
  50972. */
  50973. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  50974. }
  50975. }
  50976. declare module BABYLON {
  50977. /**
  50978. * Creation options of the multi render target texture.
  50979. */
  50980. export interface IMultiRenderTargetOptions {
  50981. /**
  50982. * Define if the texture needs to create mip maps after render.
  50983. */
  50984. generateMipMaps?: boolean;
  50985. /**
  50986. * Define the types of all the draw buffers we want to create
  50987. */
  50988. types?: number[];
  50989. /**
  50990. * Define the sampling modes of all the draw buffers we want to create
  50991. */
  50992. samplingModes?: number[];
  50993. /**
  50994. * Define if a depth buffer is required
  50995. */
  50996. generateDepthBuffer?: boolean;
  50997. /**
  50998. * Define if a stencil buffer is required
  50999. */
  51000. generateStencilBuffer?: boolean;
  51001. /**
  51002. * Define if a depth texture is required instead of a depth buffer
  51003. */
  51004. generateDepthTexture?: boolean;
  51005. /**
  51006. * Define the number of desired draw buffers
  51007. */
  51008. textureCount?: number;
  51009. /**
  51010. * Define if aspect ratio should be adapted to the texture or stay the scene one
  51011. */
  51012. doNotChangeAspectRatio?: boolean;
  51013. /**
  51014. * Define the default type of the buffers we are creating
  51015. */
  51016. defaultType?: number;
  51017. }
  51018. /**
  51019. * A multi render target, like a render target provides the ability to render to a texture.
  51020. * Unlike the render target, it can render to several draw buffers in one draw.
  51021. * This is specially interesting in deferred rendering or for any effects requiring more than
  51022. * just one color from a single pass.
  51023. */
  51024. export class MultiRenderTarget extends RenderTargetTexture {
  51025. private _internalTextures;
  51026. private _textures;
  51027. private _multiRenderTargetOptions;
  51028. /**
  51029. * Get if draw buffers are currently supported by the used hardware and browser.
  51030. */
  51031. get isSupported(): boolean;
  51032. /**
  51033. * Get the list of textures generated by the multi render target.
  51034. */
  51035. get textures(): Texture[];
  51036. /**
  51037. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  51038. */
  51039. get depthTexture(): Texture;
  51040. /**
  51041. * Set the wrapping mode on U of all the textures we are rendering to.
  51042. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  51043. */
  51044. set wrapU(wrap: number);
  51045. /**
  51046. * Set the wrapping mode on V of all the textures we are rendering to.
  51047. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  51048. */
  51049. set wrapV(wrap: number);
  51050. /**
  51051. * Instantiate a new multi render target texture.
  51052. * A multi render target, like a render target provides the ability to render to a texture.
  51053. * Unlike the render target, it can render to several draw buffers in one draw.
  51054. * This is specially interesting in deferred rendering or for any effects requiring more than
  51055. * just one color from a single pass.
  51056. * @param name Define the name of the texture
  51057. * @param size Define the size of the buffers to render to
  51058. * @param count Define the number of target we are rendering into
  51059. * @param scene Define the scene the texture belongs to
  51060. * @param options Define the options used to create the multi render target
  51061. */
  51062. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  51063. /** @hidden */
  51064. _rebuild(): void;
  51065. private _createInternalTextures;
  51066. private _createTextures;
  51067. /**
  51068. * Define the number of samples used if MSAA is enabled.
  51069. */
  51070. get samples(): number;
  51071. set samples(value: number);
  51072. /**
  51073. * Resize all the textures in the multi render target.
  51074. * Be carrefull as it will recreate all the data in the new texture.
  51075. * @param size Define the new size
  51076. */
  51077. resize(size: any): void;
  51078. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  51079. /**
  51080. * Dispose the render targets and their associated resources
  51081. */
  51082. dispose(): void;
  51083. /**
  51084. * Release all the underlying texture used as draw buffers.
  51085. */
  51086. releaseInternalTextures(): void;
  51087. }
  51088. }
  51089. declare module BABYLON {
  51090. interface ThinEngine {
  51091. /**
  51092. * Unbind a list of render target textures from the webGL context
  51093. * This is used only when drawBuffer extension or webGL2 are active
  51094. * @param textures defines the render target textures to unbind
  51095. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  51096. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  51097. */
  51098. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  51099. /**
  51100. * Create a multi render target texture
  51101. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  51102. * @param size defines the size of the texture
  51103. * @param options defines the creation options
  51104. * @returns the cube texture as an InternalTexture
  51105. */
  51106. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  51107. /**
  51108. * Update the sample count for a given multiple render target texture
  51109. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  51110. * @param textures defines the textures to update
  51111. * @param samples defines the sample count to set
  51112. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  51113. */
  51114. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  51115. }
  51116. }
  51117. declare module BABYLON {
  51118. /**
  51119. * Class used to define an additional view for the engine
  51120. * @see https://doc.babylonjs.com/how_to/multi_canvases
  51121. */
  51122. export class EngineView {
  51123. /** Defines the canvas where to render the view */
  51124. target: HTMLCanvasElement;
  51125. /** Defines an optional camera used to render the view (will use active camera else) */
  51126. camera?: Camera;
  51127. }
  51128. interface Engine {
  51129. /**
  51130. * Gets or sets the HTML element to use for attaching events
  51131. */
  51132. inputElement: Nullable<HTMLElement>;
  51133. /**
  51134. * Gets the current engine view
  51135. * @see https://doc.babylonjs.com/how_to/multi_canvases
  51136. */
  51137. activeView: Nullable<EngineView>;
  51138. /** Gets or sets the list of views */
  51139. views: EngineView[];
  51140. /**
  51141. * Register a new child canvas
  51142. * @param canvas defines the canvas to register
  51143. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  51144. * @returns the associated view
  51145. */
  51146. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  51147. /**
  51148. * Remove a registered child canvas
  51149. * @param canvas defines the canvas to remove
  51150. * @returns the current engine
  51151. */
  51152. unRegisterView(canvas: HTMLCanvasElement): Engine;
  51153. }
  51154. }
  51155. declare module BABYLON {
  51156. interface Engine {
  51157. /** @hidden */
  51158. _excludedCompressedTextures: string[];
  51159. /** @hidden */
  51160. _textureFormatInUse: string;
  51161. /**
  51162. * Gets the list of texture formats supported
  51163. */
  51164. readonly texturesSupported: Array<string>;
  51165. /**
  51166. * Gets the texture format in use
  51167. */
  51168. readonly textureFormatInUse: Nullable<string>;
  51169. /**
  51170. * Set the compressed texture extensions or file names to skip.
  51171. *
  51172. * @param skippedFiles defines the list of those texture files you want to skip
  51173. * Example: [".dds", ".env", "myfile.png"]
  51174. */
  51175. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  51176. /**
  51177. * Set the compressed texture format to use, based on the formats you have, and the formats
  51178. * supported by the hardware / browser.
  51179. *
  51180. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  51181. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  51182. * to API arguments needed to compressed textures. This puts the burden on the container
  51183. * generator to house the arcane code for determining these for current & future formats.
  51184. *
  51185. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51186. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51187. *
  51188. * Note: The result of this call is not taken into account when a texture is base64.
  51189. *
  51190. * @param formatsAvailable defines the list of those format families you have created
  51191. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  51192. *
  51193. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  51194. * @returns The extension selected.
  51195. */
  51196. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  51197. }
  51198. }
  51199. declare module BABYLON {
  51200. /**
  51201. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  51202. */
  51203. export interface CubeMapInfo {
  51204. /**
  51205. * The pixel array for the front face.
  51206. * This is stored in format, left to right, up to down format.
  51207. */
  51208. front: Nullable<ArrayBufferView>;
  51209. /**
  51210. * The pixel array for the back face.
  51211. * This is stored in format, left to right, up to down format.
  51212. */
  51213. back: Nullable<ArrayBufferView>;
  51214. /**
  51215. * The pixel array for the left face.
  51216. * This is stored in format, left to right, up to down format.
  51217. */
  51218. left: Nullable<ArrayBufferView>;
  51219. /**
  51220. * The pixel array for the right face.
  51221. * This is stored in format, left to right, up to down format.
  51222. */
  51223. right: Nullable<ArrayBufferView>;
  51224. /**
  51225. * The pixel array for the up face.
  51226. * This is stored in format, left to right, up to down format.
  51227. */
  51228. up: Nullable<ArrayBufferView>;
  51229. /**
  51230. * The pixel array for the down face.
  51231. * This is stored in format, left to right, up to down format.
  51232. */
  51233. down: Nullable<ArrayBufferView>;
  51234. /**
  51235. * The size of the cubemap stored.
  51236. *
  51237. * Each faces will be size * size pixels.
  51238. */
  51239. size: number;
  51240. /**
  51241. * The format of the texture.
  51242. *
  51243. * RGBA, RGB.
  51244. */
  51245. format: number;
  51246. /**
  51247. * The type of the texture data.
  51248. *
  51249. * UNSIGNED_INT, FLOAT.
  51250. */
  51251. type: number;
  51252. /**
  51253. * Specifies whether the texture is in gamma space.
  51254. */
  51255. gammaSpace: boolean;
  51256. }
  51257. /**
  51258. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  51259. */
  51260. export class PanoramaToCubeMapTools {
  51261. private static FACE_LEFT;
  51262. private static FACE_RIGHT;
  51263. private static FACE_FRONT;
  51264. private static FACE_BACK;
  51265. private static FACE_DOWN;
  51266. private static FACE_UP;
  51267. /**
  51268. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  51269. *
  51270. * @param float32Array The source data.
  51271. * @param inputWidth The width of the input panorama.
  51272. * @param inputHeight The height of the input panorama.
  51273. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  51274. * @return The cubemap data
  51275. */
  51276. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  51277. private static CreateCubemapTexture;
  51278. private static CalcProjectionSpherical;
  51279. }
  51280. }
  51281. declare module BABYLON {
  51282. /**
  51283. * Helper class dealing with the extraction of spherical polynomial dataArray
  51284. * from a cube map.
  51285. */
  51286. export class CubeMapToSphericalPolynomialTools {
  51287. private static FileFaces;
  51288. /**
  51289. * Converts a texture to the according Spherical Polynomial data.
  51290. * This extracts the first 3 orders only as they are the only one used in the lighting.
  51291. *
  51292. * @param texture The texture to extract the information from.
  51293. * @return The Spherical Polynomial data.
  51294. */
  51295. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  51296. /**
  51297. * Converts a cubemap to the according Spherical Polynomial data.
  51298. * This extracts the first 3 orders only as they are the only one used in the lighting.
  51299. *
  51300. * @param cubeInfo The Cube map to extract the information from.
  51301. * @return The Spherical Polynomial data.
  51302. */
  51303. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  51304. }
  51305. }
  51306. declare module BABYLON {
  51307. interface BaseTexture {
  51308. /**
  51309. * Get the polynomial representation of the texture data.
  51310. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  51311. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  51312. */
  51313. sphericalPolynomial: Nullable<SphericalPolynomial>;
  51314. }
  51315. }
  51316. declare module BABYLON {
  51317. /** @hidden */
  51318. export var rgbdEncodePixelShader: {
  51319. name: string;
  51320. shader: string;
  51321. };
  51322. }
  51323. declare module BABYLON {
  51324. /** @hidden */
  51325. export var rgbdDecodePixelShader: {
  51326. name: string;
  51327. shader: string;
  51328. };
  51329. }
  51330. declare module BABYLON {
  51331. /**
  51332. * Raw texture data and descriptor sufficient for WebGL texture upload
  51333. */
  51334. export interface EnvironmentTextureInfo {
  51335. /**
  51336. * Version of the environment map
  51337. */
  51338. version: number;
  51339. /**
  51340. * Width of image
  51341. */
  51342. width: number;
  51343. /**
  51344. * Irradiance information stored in the file.
  51345. */
  51346. irradiance: any;
  51347. /**
  51348. * Specular information stored in the file.
  51349. */
  51350. specular: any;
  51351. }
  51352. /**
  51353. * Defines One Image in the file. It requires only the position in the file
  51354. * as well as the length.
  51355. */
  51356. interface BufferImageData {
  51357. /**
  51358. * Length of the image data.
  51359. */
  51360. length: number;
  51361. /**
  51362. * Position of the data from the null terminator delimiting the end of the JSON.
  51363. */
  51364. position: number;
  51365. }
  51366. /**
  51367. * Defines the specular data enclosed in the file.
  51368. * This corresponds to the version 1 of the data.
  51369. */
  51370. export interface EnvironmentTextureSpecularInfoV1 {
  51371. /**
  51372. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  51373. */
  51374. specularDataPosition?: number;
  51375. /**
  51376. * This contains all the images data needed to reconstruct the cubemap.
  51377. */
  51378. mipmaps: Array<BufferImageData>;
  51379. /**
  51380. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  51381. */
  51382. lodGenerationScale: number;
  51383. }
  51384. /**
  51385. * Sets of helpers addressing the serialization and deserialization of environment texture
  51386. * stored in a BabylonJS env file.
  51387. * Those files are usually stored as .env files.
  51388. */
  51389. export class EnvironmentTextureTools {
  51390. /**
  51391. * Magic number identifying the env file.
  51392. */
  51393. private static _MagicBytes;
  51394. /**
  51395. * Gets the environment info from an env file.
  51396. * @param data The array buffer containing the .env bytes.
  51397. * @returns the environment file info (the json header) if successfully parsed.
  51398. */
  51399. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  51400. /**
  51401. * Creates an environment texture from a loaded cube texture.
  51402. * @param texture defines the cube texture to convert in env file
  51403. * @return a promise containing the environment data if succesfull.
  51404. */
  51405. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  51406. /**
  51407. * Creates a JSON representation of the spherical data.
  51408. * @param texture defines the texture containing the polynomials
  51409. * @return the JSON representation of the spherical info
  51410. */
  51411. private static _CreateEnvTextureIrradiance;
  51412. /**
  51413. * Creates the ArrayBufferViews used for initializing environment texture image data.
  51414. * @param data the image data
  51415. * @param info parameters that determine what views will be created for accessing the underlying buffer
  51416. * @return the views described by info providing access to the underlying buffer
  51417. */
  51418. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  51419. /**
  51420. * Uploads the texture info contained in the env file to the GPU.
  51421. * @param texture defines the internal texture to upload to
  51422. * @param data defines the data to load
  51423. * @param info defines the texture info retrieved through the GetEnvInfo method
  51424. * @returns a promise
  51425. */
  51426. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  51427. private static _OnImageReadyAsync;
  51428. /**
  51429. * Uploads the levels of image data to the GPU.
  51430. * @param texture defines the internal texture to upload to
  51431. * @param imageData defines the array buffer views of image data [mipmap][face]
  51432. * @returns a promise
  51433. */
  51434. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  51435. /**
  51436. * Uploads spherical polynomials information to the texture.
  51437. * @param texture defines the texture we are trying to upload the information to
  51438. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  51439. */
  51440. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  51441. /** @hidden */
  51442. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51443. }
  51444. }
  51445. declare module BABYLON {
  51446. /** @hidden */
  51447. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  51448. private _genericAttributeLocation;
  51449. private _varyingLocationCount;
  51450. private _varyingLocationMap;
  51451. private _replacements;
  51452. private _textureCount;
  51453. private _uniforms;
  51454. lineProcessor(line: string): string;
  51455. attributeProcessor(attribute: string): string;
  51456. varyingProcessor(varying: string, isFragment: boolean): string;
  51457. uniformProcessor(uniform: string): string;
  51458. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  51459. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  51460. }
  51461. }
  51462. declare module BABYLON {
  51463. /**
  51464. * Class used to inline functions in shader code
  51465. */
  51466. export class ShaderCodeInliner {
  51467. private static readonly _RegexpFindFunctionNameAndType;
  51468. private _sourceCode;
  51469. private _functionDescr;
  51470. private _numMaxIterations;
  51471. /** Gets or sets the token used to mark the functions to inline */
  51472. inlineToken: string;
  51473. /** Gets or sets the debug mode */
  51474. debug: boolean;
  51475. /** Gets the code after the inlining process */
  51476. get code(): string;
  51477. /**
  51478. * Initializes the inliner
  51479. * @param sourceCode shader code source to inline
  51480. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  51481. */
  51482. constructor(sourceCode: string, numMaxIterations?: number);
  51483. /**
  51484. * Start the processing of the shader code
  51485. */
  51486. processCode(): void;
  51487. private _collectFunctions;
  51488. private _processInlining;
  51489. private _extractBetweenMarkers;
  51490. private _skipWhitespaces;
  51491. private _removeComments;
  51492. private _replaceFunctionCallsByCode;
  51493. private _findBackward;
  51494. private _escapeRegExp;
  51495. private _replaceNames;
  51496. }
  51497. }
  51498. declare module BABYLON {
  51499. /**
  51500. * Container for accessors for natively-stored mesh data buffers.
  51501. */
  51502. class NativeDataBuffer extends DataBuffer {
  51503. /**
  51504. * Accessor value used to identify/retrieve a natively-stored index buffer.
  51505. */
  51506. nativeIndexBuffer?: any;
  51507. /**
  51508. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  51509. */
  51510. nativeVertexBuffer?: any;
  51511. }
  51512. /** @hidden */
  51513. class NativeTexture extends InternalTexture {
  51514. getInternalTexture(): InternalTexture;
  51515. getViewCount(): number;
  51516. }
  51517. /** @hidden */
  51518. export class NativeEngine extends Engine {
  51519. private readonly _native;
  51520. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  51521. private readonly INVALID_HANDLE;
  51522. getHardwareScalingLevel(): number;
  51523. constructor();
  51524. dispose(): void;
  51525. /**
  51526. * Can be used to override the current requestAnimationFrame requester.
  51527. * @hidden
  51528. */
  51529. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  51530. /**
  51531. * Override default engine behavior.
  51532. * @param color
  51533. * @param backBuffer
  51534. * @param depth
  51535. * @param stencil
  51536. */
  51537. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  51538. /**
  51539. * Gets host document
  51540. * @returns the host document object
  51541. */
  51542. getHostDocument(): Nullable<Document>;
  51543. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51544. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  51545. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  51546. recordVertexArrayObject(vertexBuffers: {
  51547. [key: string]: VertexBuffer;
  51548. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  51549. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51550. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51551. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51552. /**
  51553. * Draw a list of indexed primitives
  51554. * @param fillMode defines the primitive to use
  51555. * @param indexStart defines the starting index
  51556. * @param indexCount defines the number of index to draw
  51557. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51558. */
  51559. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  51560. /**
  51561. * Draw a list of unindexed primitives
  51562. * @param fillMode defines the primitive to use
  51563. * @param verticesStart defines the index of first vertex to draw
  51564. * @param verticesCount defines the count of vertices to draw
  51565. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51566. */
  51567. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  51568. createPipelineContext(): IPipelineContext;
  51569. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  51570. /** @hidden */
  51571. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  51572. /** @hidden */
  51573. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  51574. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51575. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51576. protected _setProgram(program: WebGLProgram): void;
  51577. _releaseEffect(effect: Effect): void;
  51578. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  51579. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  51580. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  51581. bindSamplers(effect: Effect): void;
  51582. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  51583. getRenderWidth(useScreen?: boolean): number;
  51584. getRenderHeight(useScreen?: boolean): number;
  51585. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  51586. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  51587. /**
  51588. * Set the z offset to apply to current rendering
  51589. * @param value defines the offset to apply
  51590. */
  51591. setZOffset(value: number): void;
  51592. /**
  51593. * Gets the current value of the zOffset
  51594. * @returns the current zOffset state
  51595. */
  51596. getZOffset(): number;
  51597. /**
  51598. * Enable or disable depth buffering
  51599. * @param enable defines the state to set
  51600. */
  51601. setDepthBuffer(enable: boolean): void;
  51602. /**
  51603. * Gets a boolean indicating if depth writing is enabled
  51604. * @returns the current depth writing state
  51605. */
  51606. getDepthWrite(): boolean;
  51607. /**
  51608. * Enable or disable depth writing
  51609. * @param enable defines the state to set
  51610. */
  51611. setDepthWrite(enable: boolean): void;
  51612. /**
  51613. * Enable or disable color writing
  51614. * @param enable defines the state to set
  51615. */
  51616. setColorWrite(enable: boolean): void;
  51617. /**
  51618. * Gets a boolean indicating if color writing is enabled
  51619. * @returns the current color writing state
  51620. */
  51621. getColorWrite(): boolean;
  51622. /**
  51623. * Sets alpha constants used by some alpha blending modes
  51624. * @param r defines the red component
  51625. * @param g defines the green component
  51626. * @param b defines the blue component
  51627. * @param a defines the alpha component
  51628. */
  51629. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  51630. /**
  51631. * Sets the current alpha mode
  51632. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  51633. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  51634. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51635. */
  51636. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  51637. /**
  51638. * Gets the current alpha mode
  51639. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51640. * @returns the current alpha mode
  51641. */
  51642. getAlphaMode(): number;
  51643. setInt(uniform: WebGLUniformLocation, int: number): void;
  51644. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  51645. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  51646. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  51647. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  51648. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  51649. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  51650. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  51651. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  51652. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  51653. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  51654. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  51655. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  51656. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  51657. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51658. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51659. setFloat(uniform: WebGLUniformLocation, value: number): void;
  51660. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  51661. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  51662. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  51663. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  51664. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  51665. wipeCaches(bruteForce?: boolean): void;
  51666. _createTexture(): WebGLTexture;
  51667. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  51668. /**
  51669. * Usually called from Texture.ts.
  51670. * Passed information to create a WebGLTexture
  51671. * @param url defines a value which contains one of the following:
  51672. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  51673. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  51674. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  51675. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  51676. * @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)
  51677. * @param scene needed for loading to the correct scene
  51678. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  51679. * @param onLoad optional callback to be called upon successful completion
  51680. * @param onError optional callback to be called upon failure
  51681. * @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
  51682. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  51683. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  51684. * @param forcedExtension defines the extension to use to pick the right loader
  51685. * @param mimeType defines an optional mime type
  51686. * @returns a InternalTexture for assignment back into BABYLON.Texture
  51687. */
  51688. 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;
  51689. /**
  51690. * Creates a cube texture
  51691. * @param rootUrl defines the url where the files to load is located
  51692. * @param scene defines the current scene
  51693. * @param files defines the list of files to load (1 per face)
  51694. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  51695. * @param onLoad defines an optional callback raised when the texture is loaded
  51696. * @param onError defines an optional callback raised if there is an issue to load the texture
  51697. * @param format defines the format of the data
  51698. * @param forcedExtension defines the extension to use to pick the right loader
  51699. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  51700. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51701. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51702. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  51703. * @returns the cube texture as an InternalTexture
  51704. */
  51705. 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;
  51706. private _getSamplingFilter;
  51707. private static _GetNativeTextureFormat;
  51708. createRenderTargetTexture(size: number | {
  51709. width: number;
  51710. height: number;
  51711. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  51712. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  51713. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  51714. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  51715. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  51716. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  51717. /**
  51718. * Updates a dynamic vertex buffer.
  51719. * @param vertexBuffer the vertex buffer to update
  51720. * @param data the data used to update the vertex buffer
  51721. * @param byteOffset the byte offset of the data (optional)
  51722. * @param byteLength the byte length of the data (optional)
  51723. */
  51724. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  51725. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  51726. private _updateAnisotropicLevel;
  51727. private _getAddressMode;
  51728. /** @hidden */
  51729. _bindTexture(channel: number, texture: InternalTexture): void;
  51730. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  51731. releaseEffects(): void;
  51732. /** @hidden */
  51733. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51734. /** @hidden */
  51735. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51736. /** @hidden */
  51737. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51738. /** @hidden */
  51739. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  51740. }
  51741. }
  51742. declare module BABYLON {
  51743. /**
  51744. * Gather the list of clipboard event types as constants.
  51745. */
  51746. export class ClipboardEventTypes {
  51747. /**
  51748. * The clipboard event is fired when a copy command is active (pressed).
  51749. */
  51750. static readonly COPY: number;
  51751. /**
  51752. * The clipboard event is fired when a cut command is active (pressed).
  51753. */
  51754. static readonly CUT: number;
  51755. /**
  51756. * The clipboard event is fired when a paste command is active (pressed).
  51757. */
  51758. static readonly PASTE: number;
  51759. }
  51760. /**
  51761. * This class is used to store clipboard related info for the onClipboardObservable event.
  51762. */
  51763. export class ClipboardInfo {
  51764. /**
  51765. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51766. */
  51767. type: number;
  51768. /**
  51769. * Defines the related dom event
  51770. */
  51771. event: ClipboardEvent;
  51772. /**
  51773. *Creates an instance of ClipboardInfo.
  51774. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  51775. * @param event Defines the related dom event
  51776. */
  51777. constructor(
  51778. /**
  51779. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51780. */
  51781. type: number,
  51782. /**
  51783. * Defines the related dom event
  51784. */
  51785. event: ClipboardEvent);
  51786. /**
  51787. * Get the clipboard event's type from the keycode.
  51788. * @param keyCode Defines the keyCode for the current keyboard event.
  51789. * @return {number}
  51790. */
  51791. static GetTypeFromCharacter(keyCode: number): number;
  51792. }
  51793. }
  51794. declare module BABYLON {
  51795. /**
  51796. * Google Daydream controller
  51797. */
  51798. export class DaydreamController extends WebVRController {
  51799. /**
  51800. * Base Url for the controller model.
  51801. */
  51802. static MODEL_BASE_URL: string;
  51803. /**
  51804. * File name for the controller model.
  51805. */
  51806. static MODEL_FILENAME: string;
  51807. /**
  51808. * Gamepad Id prefix used to identify Daydream Controller.
  51809. */
  51810. static readonly GAMEPAD_ID_PREFIX: string;
  51811. /**
  51812. * Creates a new DaydreamController from a gamepad
  51813. * @param vrGamepad the gamepad that the controller should be created from
  51814. */
  51815. constructor(vrGamepad: any);
  51816. /**
  51817. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51818. * @param scene scene in which to add meshes
  51819. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51820. */
  51821. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51822. /**
  51823. * Called once for each button that changed state since the last frame
  51824. * @param buttonIdx Which button index changed
  51825. * @param state New state of the button
  51826. * @param changes Which properties on the state changed since last frame
  51827. */
  51828. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51829. }
  51830. }
  51831. declare module BABYLON {
  51832. /**
  51833. * Gear VR Controller
  51834. */
  51835. export class GearVRController extends WebVRController {
  51836. /**
  51837. * Base Url for the controller model.
  51838. */
  51839. static MODEL_BASE_URL: string;
  51840. /**
  51841. * File name for the controller model.
  51842. */
  51843. static MODEL_FILENAME: string;
  51844. /**
  51845. * Gamepad Id prefix used to identify this controller.
  51846. */
  51847. static readonly GAMEPAD_ID_PREFIX: string;
  51848. private readonly _buttonIndexToObservableNameMap;
  51849. /**
  51850. * Creates a new GearVRController from a gamepad
  51851. * @param vrGamepad the gamepad that the controller should be created from
  51852. */
  51853. constructor(vrGamepad: any);
  51854. /**
  51855. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51856. * @param scene scene in which to add meshes
  51857. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51858. */
  51859. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51860. /**
  51861. * Called once for each button that changed state since the last frame
  51862. * @param buttonIdx Which button index changed
  51863. * @param state New state of the button
  51864. * @param changes Which properties on the state changed since last frame
  51865. */
  51866. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51867. }
  51868. }
  51869. declare module BABYLON {
  51870. /**
  51871. * Generic Controller
  51872. */
  51873. export class GenericController extends WebVRController {
  51874. /**
  51875. * Base Url for the controller model.
  51876. */
  51877. static readonly MODEL_BASE_URL: string;
  51878. /**
  51879. * File name for the controller model.
  51880. */
  51881. static readonly MODEL_FILENAME: string;
  51882. /**
  51883. * Creates a new GenericController from a gamepad
  51884. * @param vrGamepad the gamepad that the controller should be created from
  51885. */
  51886. constructor(vrGamepad: any);
  51887. /**
  51888. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51889. * @param scene scene in which to add meshes
  51890. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51891. */
  51892. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51893. /**
  51894. * Called once for each button that changed state since the last frame
  51895. * @param buttonIdx Which button index changed
  51896. * @param state New state of the button
  51897. * @param changes Which properties on the state changed since last frame
  51898. */
  51899. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51900. }
  51901. }
  51902. declare module BABYLON {
  51903. /**
  51904. * Oculus Touch Controller
  51905. */
  51906. export class OculusTouchController extends WebVRController {
  51907. /**
  51908. * Base Url for the controller model.
  51909. */
  51910. static MODEL_BASE_URL: string;
  51911. /**
  51912. * File name for the left controller model.
  51913. */
  51914. static MODEL_LEFT_FILENAME: string;
  51915. /**
  51916. * File name for the right controller model.
  51917. */
  51918. static MODEL_RIGHT_FILENAME: string;
  51919. /**
  51920. * Base Url for the Quest controller model.
  51921. */
  51922. static QUEST_MODEL_BASE_URL: string;
  51923. /**
  51924. * @hidden
  51925. * If the controllers are running on a device that needs the updated Quest controller models
  51926. */
  51927. static _IsQuest: boolean;
  51928. /**
  51929. * Fired when the secondary trigger on this controller is modified
  51930. */
  51931. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  51932. /**
  51933. * Fired when the thumb rest on this controller is modified
  51934. */
  51935. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  51936. /**
  51937. * Creates a new OculusTouchController from a gamepad
  51938. * @param vrGamepad the gamepad that the controller should be created from
  51939. */
  51940. constructor(vrGamepad: any);
  51941. /**
  51942. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51943. * @param scene scene in which to add meshes
  51944. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51945. */
  51946. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51947. /**
  51948. * Fired when the A button on this controller is modified
  51949. */
  51950. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51951. /**
  51952. * Fired when the B button on this controller is modified
  51953. */
  51954. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51955. /**
  51956. * Fired when the X button on this controller is modified
  51957. */
  51958. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51959. /**
  51960. * Fired when the Y button on this controller is modified
  51961. */
  51962. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51963. /**
  51964. * Called once for each button that changed state since the last frame
  51965. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  51966. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  51967. * 2) secondary trigger (same)
  51968. * 3) A (right) X (left), touch, pressed = value
  51969. * 4) B / Y
  51970. * 5) thumb rest
  51971. * @param buttonIdx Which button index changed
  51972. * @param state New state of the button
  51973. * @param changes Which properties on the state changed since last frame
  51974. */
  51975. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51976. }
  51977. }
  51978. declare module BABYLON {
  51979. /**
  51980. * Vive Controller
  51981. */
  51982. export class ViveController extends WebVRController {
  51983. /**
  51984. * Base Url for the controller model.
  51985. */
  51986. static MODEL_BASE_URL: string;
  51987. /**
  51988. * File name for the controller model.
  51989. */
  51990. static MODEL_FILENAME: string;
  51991. /**
  51992. * Creates a new ViveController from a gamepad
  51993. * @param vrGamepad the gamepad that the controller should be created from
  51994. */
  51995. constructor(vrGamepad: any);
  51996. /**
  51997. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51998. * @param scene scene in which to add meshes
  51999. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52000. */
  52001. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52002. /**
  52003. * Fired when the left button on this controller is modified
  52004. */
  52005. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52006. /**
  52007. * Fired when the right button on this controller is modified
  52008. */
  52009. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52010. /**
  52011. * Fired when the menu button on this controller is modified
  52012. */
  52013. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52014. /**
  52015. * Called once for each button that changed state since the last frame
  52016. * Vive mapping:
  52017. * 0: touchpad
  52018. * 1: trigger
  52019. * 2: left AND right buttons
  52020. * 3: menu button
  52021. * @param buttonIdx Which button index changed
  52022. * @param state New state of the button
  52023. * @param changes Which properties on the state changed since last frame
  52024. */
  52025. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52026. }
  52027. }
  52028. declare module BABYLON {
  52029. /**
  52030. * Defines the WindowsMotionController object that the state of the windows motion controller
  52031. */
  52032. export class WindowsMotionController extends WebVRController {
  52033. /**
  52034. * The base url used to load the left and right controller models
  52035. */
  52036. static MODEL_BASE_URL: string;
  52037. /**
  52038. * The name of the left controller model file
  52039. */
  52040. static MODEL_LEFT_FILENAME: string;
  52041. /**
  52042. * The name of the right controller model file
  52043. */
  52044. static MODEL_RIGHT_FILENAME: string;
  52045. /**
  52046. * The controller name prefix for this controller type
  52047. */
  52048. static readonly GAMEPAD_ID_PREFIX: string;
  52049. /**
  52050. * The controller id pattern for this controller type
  52051. */
  52052. private static readonly GAMEPAD_ID_PATTERN;
  52053. private _loadedMeshInfo;
  52054. protected readonly _mapping: {
  52055. buttons: string[];
  52056. buttonMeshNames: {
  52057. trigger: string;
  52058. menu: string;
  52059. grip: string;
  52060. thumbstick: string;
  52061. trackpad: string;
  52062. };
  52063. buttonObservableNames: {
  52064. trigger: string;
  52065. menu: string;
  52066. grip: string;
  52067. thumbstick: string;
  52068. trackpad: string;
  52069. };
  52070. axisMeshNames: string[];
  52071. pointingPoseMeshName: string;
  52072. };
  52073. /**
  52074. * Fired when the trackpad on this controller is clicked
  52075. */
  52076. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  52077. /**
  52078. * Fired when the trackpad on this controller is modified
  52079. */
  52080. onTrackpadValuesChangedObservable: Observable<StickValues>;
  52081. /**
  52082. * The current x and y values of this controller's trackpad
  52083. */
  52084. trackpad: StickValues;
  52085. /**
  52086. * Creates a new WindowsMotionController from a gamepad
  52087. * @param vrGamepad the gamepad that the controller should be created from
  52088. */
  52089. constructor(vrGamepad: any);
  52090. /**
  52091. * Fired when the trigger on this controller is modified
  52092. */
  52093. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52094. /**
  52095. * Fired when the menu button on this controller is modified
  52096. */
  52097. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52098. /**
  52099. * Fired when the grip button on this controller is modified
  52100. */
  52101. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52102. /**
  52103. * Fired when the thumbstick button on this controller is modified
  52104. */
  52105. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52106. /**
  52107. * Fired when the touchpad button on this controller is modified
  52108. */
  52109. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52110. /**
  52111. * Fired when the touchpad values on this controller are modified
  52112. */
  52113. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  52114. protected _updateTrackpad(): void;
  52115. /**
  52116. * Called once per frame by the engine.
  52117. */
  52118. update(): void;
  52119. /**
  52120. * Called once for each button that changed state since the last frame
  52121. * @param buttonIdx Which button index changed
  52122. * @param state New state of the button
  52123. * @param changes Which properties on the state changed since last frame
  52124. */
  52125. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52126. /**
  52127. * Moves the buttons on the controller mesh based on their current state
  52128. * @param buttonName the name of the button to move
  52129. * @param buttonValue the value of the button which determines the buttons new position
  52130. */
  52131. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  52132. /**
  52133. * Moves the axis on the controller mesh based on its current state
  52134. * @param axis the index of the axis
  52135. * @param axisValue the value of the axis which determines the meshes new position
  52136. * @hidden
  52137. */
  52138. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  52139. /**
  52140. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52141. * @param scene scene in which to add meshes
  52142. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52143. */
  52144. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  52145. /**
  52146. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  52147. * can be transformed by button presses and axes values, based on this._mapping.
  52148. *
  52149. * @param scene scene in which the meshes exist
  52150. * @param meshes list of meshes that make up the controller model to process
  52151. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  52152. */
  52153. private processModel;
  52154. private createMeshInfo;
  52155. /**
  52156. * Gets the ray of the controller in the direction the controller is pointing
  52157. * @param length the length the resulting ray should be
  52158. * @returns a ray in the direction the controller is pointing
  52159. */
  52160. getForwardRay(length?: number): Ray;
  52161. /**
  52162. * Disposes of the controller
  52163. */
  52164. dispose(): void;
  52165. }
  52166. /**
  52167. * This class represents a new windows motion controller in XR.
  52168. */
  52169. export class XRWindowsMotionController extends WindowsMotionController {
  52170. /**
  52171. * Changing the original WIndowsMotionController mapping to fir the new mapping
  52172. */
  52173. protected readonly _mapping: {
  52174. buttons: string[];
  52175. buttonMeshNames: {
  52176. trigger: string;
  52177. menu: string;
  52178. grip: string;
  52179. thumbstick: string;
  52180. trackpad: string;
  52181. };
  52182. buttonObservableNames: {
  52183. trigger: string;
  52184. menu: string;
  52185. grip: string;
  52186. thumbstick: string;
  52187. trackpad: string;
  52188. };
  52189. axisMeshNames: string[];
  52190. pointingPoseMeshName: string;
  52191. };
  52192. /**
  52193. * Construct a new XR-Based windows motion controller
  52194. *
  52195. * @param gamepadInfo the gamepad object from the browser
  52196. */
  52197. constructor(gamepadInfo: any);
  52198. /**
  52199. * holds the thumbstick values (X,Y)
  52200. */
  52201. thumbstickValues: StickValues;
  52202. /**
  52203. * Fired when the thumbstick on this controller is clicked
  52204. */
  52205. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  52206. /**
  52207. * Fired when the thumbstick on this controller is modified
  52208. */
  52209. onThumbstickValuesChangedObservable: Observable<StickValues>;
  52210. /**
  52211. * Fired when the touchpad button on this controller is modified
  52212. */
  52213. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  52214. /**
  52215. * Fired when the touchpad values on this controller are modified
  52216. */
  52217. onTrackpadValuesChangedObservable: Observable<StickValues>;
  52218. /**
  52219. * Fired when the thumbstick button on this controller is modified
  52220. * here to prevent breaking changes
  52221. */
  52222. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52223. /**
  52224. * updating the thumbstick(!) and not the trackpad.
  52225. * This is named this way due to the difference between WebVR and XR and to avoid
  52226. * changing the parent class.
  52227. */
  52228. protected _updateTrackpad(): void;
  52229. /**
  52230. * Disposes the class with joy
  52231. */
  52232. dispose(): void;
  52233. }
  52234. }
  52235. declare module BABYLON {
  52236. /**
  52237. * Class containing static functions to help procedurally build meshes
  52238. */
  52239. export class PolyhedronBuilder {
  52240. /**
  52241. * Creates a polyhedron mesh
  52242. * * 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
  52243. * * The parameter `size` (positive float, default 1) sets the polygon size
  52244. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  52245. * * 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`
  52246. * * 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
  52247. * * 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)`)
  52248. * * 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
  52249. * * 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
  52250. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52251. * * 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
  52252. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52253. * @param name defines the name of the mesh
  52254. * @param options defines the options used to create the mesh
  52255. * @param scene defines the hosting scene
  52256. * @returns the polyhedron mesh
  52257. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  52258. */
  52259. static CreatePolyhedron(name: string, options: {
  52260. type?: number;
  52261. size?: number;
  52262. sizeX?: number;
  52263. sizeY?: number;
  52264. sizeZ?: number;
  52265. custom?: any;
  52266. faceUV?: Vector4[];
  52267. faceColors?: Color4[];
  52268. flat?: boolean;
  52269. updatable?: boolean;
  52270. sideOrientation?: number;
  52271. frontUVs?: Vector4;
  52272. backUVs?: Vector4;
  52273. }, scene?: Nullable<Scene>): Mesh;
  52274. }
  52275. }
  52276. declare module BABYLON {
  52277. /**
  52278. * Gizmo that enables scaling a mesh along 3 axis
  52279. */
  52280. export class ScaleGizmo extends Gizmo {
  52281. /**
  52282. * Internal gizmo used for interactions on the x axis
  52283. */
  52284. xGizmo: AxisScaleGizmo;
  52285. /**
  52286. * Internal gizmo used for interactions on the y axis
  52287. */
  52288. yGizmo: AxisScaleGizmo;
  52289. /**
  52290. * Internal gizmo used for interactions on the z axis
  52291. */
  52292. zGizmo: AxisScaleGizmo;
  52293. /**
  52294. * Internal gizmo used to scale all axis equally
  52295. */
  52296. uniformScaleGizmo: AxisScaleGizmo;
  52297. private _meshAttached;
  52298. private _updateGizmoRotationToMatchAttachedMesh;
  52299. private _snapDistance;
  52300. private _scaleRatio;
  52301. private _uniformScalingMesh;
  52302. private _octahedron;
  52303. private _sensitivity;
  52304. /** Fires an event when any of it's sub gizmos are dragged */
  52305. onDragStartObservable: Observable<unknown>;
  52306. /** Fires an event when any of it's sub gizmos are released from dragging */
  52307. onDragEndObservable: Observable<unknown>;
  52308. get attachedMesh(): Nullable<AbstractMesh>;
  52309. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52310. /**
  52311. * Creates a ScaleGizmo
  52312. * @param gizmoLayer The utility layer the gizmo will be added to
  52313. */
  52314. constructor(gizmoLayer?: UtilityLayerRenderer);
  52315. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52316. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52317. /**
  52318. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52319. */
  52320. set snapDistance(value: number);
  52321. get snapDistance(): number;
  52322. /**
  52323. * Ratio for the scale of the gizmo (Default: 1)
  52324. */
  52325. set scaleRatio(value: number);
  52326. get scaleRatio(): number;
  52327. /**
  52328. * Sensitivity factor for dragging (Default: 1)
  52329. */
  52330. set sensitivity(value: number);
  52331. get sensitivity(): number;
  52332. /**
  52333. * Disposes of the gizmo
  52334. */
  52335. dispose(): void;
  52336. }
  52337. }
  52338. declare module BABYLON {
  52339. /**
  52340. * Single axis scale gizmo
  52341. */
  52342. export class AxisScaleGizmo extends Gizmo {
  52343. /**
  52344. * Drag behavior responsible for the gizmos dragging interactions
  52345. */
  52346. dragBehavior: PointerDragBehavior;
  52347. private _pointerObserver;
  52348. /**
  52349. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52350. */
  52351. snapDistance: number;
  52352. /**
  52353. * Event that fires each time the gizmo snaps to a new location.
  52354. * * snapDistance is the the change in distance
  52355. */
  52356. onSnapObservable: Observable<{
  52357. snapDistance: number;
  52358. }>;
  52359. /**
  52360. * If the scaling operation should be done on all axis (default: false)
  52361. */
  52362. uniformScaling: boolean;
  52363. /**
  52364. * Custom sensitivity value for the drag strength
  52365. */
  52366. sensitivity: number;
  52367. private _isEnabled;
  52368. private _parent;
  52369. private _arrow;
  52370. private _coloredMaterial;
  52371. private _hoverMaterial;
  52372. /**
  52373. * Creates an AxisScaleGizmo
  52374. * @param gizmoLayer The utility layer the gizmo will be added to
  52375. * @param dragAxis The axis which the gizmo will be able to scale on
  52376. * @param color The color of the gizmo
  52377. */
  52378. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  52379. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52380. /**
  52381. * If the gizmo is enabled
  52382. */
  52383. set isEnabled(value: boolean);
  52384. get isEnabled(): boolean;
  52385. /**
  52386. * Disposes of the gizmo
  52387. */
  52388. dispose(): void;
  52389. /**
  52390. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  52391. * @param mesh The mesh to replace the default mesh of the gizmo
  52392. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  52393. */
  52394. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  52395. }
  52396. }
  52397. declare module BABYLON {
  52398. /**
  52399. * Bounding box gizmo
  52400. */
  52401. export class BoundingBoxGizmo extends Gizmo {
  52402. private _lineBoundingBox;
  52403. private _rotateSpheresParent;
  52404. private _scaleBoxesParent;
  52405. private _boundingDimensions;
  52406. private _renderObserver;
  52407. private _pointerObserver;
  52408. private _scaleDragSpeed;
  52409. private _tmpQuaternion;
  52410. private _tmpVector;
  52411. private _tmpRotationMatrix;
  52412. /**
  52413. * 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)
  52414. */
  52415. ignoreChildren: boolean;
  52416. /**
  52417. * 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)
  52418. */
  52419. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  52420. /**
  52421. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  52422. */
  52423. rotationSphereSize: number;
  52424. /**
  52425. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  52426. */
  52427. scaleBoxSize: number;
  52428. /**
  52429. * 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)
  52430. */
  52431. fixedDragMeshScreenSize: boolean;
  52432. /**
  52433. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  52434. */
  52435. fixedDragMeshScreenSizeDistanceFactor: number;
  52436. /**
  52437. * Fired when a rotation sphere or scale box is dragged
  52438. */
  52439. onDragStartObservable: Observable<{}>;
  52440. /**
  52441. * Fired when a scale box is dragged
  52442. */
  52443. onScaleBoxDragObservable: Observable<{}>;
  52444. /**
  52445. * Fired when a scale box drag is ended
  52446. */
  52447. onScaleBoxDragEndObservable: Observable<{}>;
  52448. /**
  52449. * Fired when a rotation sphere is dragged
  52450. */
  52451. onRotationSphereDragObservable: Observable<{}>;
  52452. /**
  52453. * Fired when a rotation sphere drag is ended
  52454. */
  52455. onRotationSphereDragEndObservable: Observable<{}>;
  52456. /**
  52457. * Relative bounding box pivot used when scaling the attached mesh. When null object with scale from the opposite corner. 0.5,0.5,0.5 for center and 0.5,0,0.5 for bottom (Default: null)
  52458. */
  52459. scalePivot: Nullable<Vector3>;
  52460. /**
  52461. * Mesh used as a pivot to rotate the attached mesh
  52462. */
  52463. private _anchorMesh;
  52464. private _existingMeshScale;
  52465. private _dragMesh;
  52466. private pointerDragBehavior;
  52467. private coloredMaterial;
  52468. private hoverColoredMaterial;
  52469. /**
  52470. * Sets the color of the bounding box gizmo
  52471. * @param color the color to set
  52472. */
  52473. setColor(color: Color3): void;
  52474. /**
  52475. * Creates an BoundingBoxGizmo
  52476. * @param gizmoLayer The utility layer the gizmo will be added to
  52477. * @param color The color of the gizmo
  52478. */
  52479. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  52480. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52481. private _selectNode;
  52482. /**
  52483. * Updates the bounding box information for the Gizmo
  52484. */
  52485. updateBoundingBox(): void;
  52486. private _updateRotationSpheres;
  52487. private _updateScaleBoxes;
  52488. /**
  52489. * Enables rotation on the specified axis and disables rotation on the others
  52490. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  52491. */
  52492. setEnabledRotationAxis(axis: string): void;
  52493. /**
  52494. * Enables/disables scaling
  52495. * @param enable if scaling should be enabled
  52496. * @param homogeneousScaling defines if scaling should only be homogeneous
  52497. */
  52498. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  52499. private _updateDummy;
  52500. /**
  52501. * Enables a pointer drag behavior on the bounding box of the gizmo
  52502. */
  52503. enableDragBehavior(): void;
  52504. /**
  52505. * Disposes of the gizmo
  52506. */
  52507. dispose(): void;
  52508. /**
  52509. * 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)
  52510. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  52511. * @returns the bounding box mesh with the passed in mesh as a child
  52512. */
  52513. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  52514. /**
  52515. * CustomMeshes are not supported by this gizmo
  52516. * @param mesh The mesh to replace the default mesh of the gizmo
  52517. */
  52518. setCustomMesh(mesh: Mesh): void;
  52519. }
  52520. }
  52521. declare module BABYLON {
  52522. /**
  52523. * Single plane rotation gizmo
  52524. */
  52525. export class PlaneRotationGizmo extends Gizmo {
  52526. /**
  52527. * Drag behavior responsible for the gizmos dragging interactions
  52528. */
  52529. dragBehavior: PointerDragBehavior;
  52530. private _pointerObserver;
  52531. /**
  52532. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  52533. */
  52534. snapDistance: number;
  52535. /**
  52536. * Event that fires each time the gizmo snaps to a new location.
  52537. * * snapDistance is the the change in distance
  52538. */
  52539. onSnapObservable: Observable<{
  52540. snapDistance: number;
  52541. }>;
  52542. private _isEnabled;
  52543. private _parent;
  52544. /**
  52545. * Creates a PlaneRotationGizmo
  52546. * @param gizmoLayer The utility layer the gizmo will be added to
  52547. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  52548. * @param color The color of the gizmo
  52549. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52550. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52551. */
  52552. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  52553. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52554. /**
  52555. * If the gizmo is enabled
  52556. */
  52557. set isEnabled(value: boolean);
  52558. get isEnabled(): boolean;
  52559. /**
  52560. * Disposes of the gizmo
  52561. */
  52562. dispose(): void;
  52563. }
  52564. }
  52565. declare module BABYLON {
  52566. /**
  52567. * Gizmo that enables rotating a mesh along 3 axis
  52568. */
  52569. export class RotationGizmo extends Gizmo {
  52570. /**
  52571. * Internal gizmo used for interactions on the x axis
  52572. */
  52573. xGizmo: PlaneRotationGizmo;
  52574. /**
  52575. * Internal gizmo used for interactions on the y axis
  52576. */
  52577. yGizmo: PlaneRotationGizmo;
  52578. /**
  52579. * Internal gizmo used for interactions on the z axis
  52580. */
  52581. zGizmo: PlaneRotationGizmo;
  52582. /** Fires an event when any of it's sub gizmos are dragged */
  52583. onDragStartObservable: Observable<unknown>;
  52584. /** Fires an event when any of it's sub gizmos are released from dragging */
  52585. onDragEndObservable: Observable<unknown>;
  52586. private _meshAttached;
  52587. get attachedMesh(): Nullable<AbstractMesh>;
  52588. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52589. /**
  52590. * Creates a RotationGizmo
  52591. * @param gizmoLayer The utility layer the gizmo will be added to
  52592. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52593. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52594. */
  52595. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  52596. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52597. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52598. /**
  52599. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52600. */
  52601. set snapDistance(value: number);
  52602. get snapDistance(): number;
  52603. /**
  52604. * Ratio for the scale of the gizmo (Default: 1)
  52605. */
  52606. set scaleRatio(value: number);
  52607. get scaleRatio(): number;
  52608. /**
  52609. * Disposes of the gizmo
  52610. */
  52611. dispose(): void;
  52612. /**
  52613. * CustomMeshes are not supported by this gizmo
  52614. * @param mesh The mesh to replace the default mesh of the gizmo
  52615. */
  52616. setCustomMesh(mesh: Mesh): void;
  52617. }
  52618. }
  52619. declare module BABYLON {
  52620. /**
  52621. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  52622. */
  52623. export class GizmoManager implements IDisposable {
  52624. private scene;
  52625. /**
  52626. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  52627. */
  52628. gizmos: {
  52629. positionGizmo: Nullable<PositionGizmo>;
  52630. rotationGizmo: Nullable<RotationGizmo>;
  52631. scaleGizmo: Nullable<ScaleGizmo>;
  52632. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  52633. };
  52634. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  52635. clearGizmoOnEmptyPointerEvent: boolean;
  52636. /** Fires an event when the manager is attached to a mesh */
  52637. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  52638. private _gizmosEnabled;
  52639. private _pointerObserver;
  52640. private _attachedMesh;
  52641. private _boundingBoxColor;
  52642. private _defaultUtilityLayer;
  52643. private _defaultKeepDepthUtilityLayer;
  52644. /**
  52645. * When bounding box gizmo is enabled, this can be used to track drag/end events
  52646. */
  52647. boundingBoxDragBehavior: SixDofDragBehavior;
  52648. /**
  52649. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  52650. */
  52651. attachableMeshes: Nullable<Array<AbstractMesh>>;
  52652. /**
  52653. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  52654. */
  52655. usePointerToAttachGizmos: boolean;
  52656. /**
  52657. * Utility layer that the bounding box gizmo belongs to
  52658. */
  52659. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  52660. /**
  52661. * Utility layer that all gizmos besides bounding box belong to
  52662. */
  52663. get utilityLayer(): UtilityLayerRenderer;
  52664. /**
  52665. * Instatiates a gizmo manager
  52666. * @param scene the scene to overlay the gizmos on top of
  52667. */
  52668. constructor(scene: Scene);
  52669. /**
  52670. * Attaches a set of gizmos to the specified mesh
  52671. * @param mesh The mesh the gizmo's should be attached to
  52672. */
  52673. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52674. /**
  52675. * If the position gizmo is enabled
  52676. */
  52677. set positionGizmoEnabled(value: boolean);
  52678. get positionGizmoEnabled(): boolean;
  52679. /**
  52680. * If the rotation gizmo is enabled
  52681. */
  52682. set rotationGizmoEnabled(value: boolean);
  52683. get rotationGizmoEnabled(): boolean;
  52684. /**
  52685. * If the scale gizmo is enabled
  52686. */
  52687. set scaleGizmoEnabled(value: boolean);
  52688. get scaleGizmoEnabled(): boolean;
  52689. /**
  52690. * If the boundingBox gizmo is enabled
  52691. */
  52692. set boundingBoxGizmoEnabled(value: boolean);
  52693. get boundingBoxGizmoEnabled(): boolean;
  52694. /**
  52695. * Disposes of the gizmo manager
  52696. */
  52697. dispose(): void;
  52698. }
  52699. }
  52700. declare module BABYLON {
  52701. /**
  52702. * A directional light is defined by a direction (what a surprise!).
  52703. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  52704. * 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.
  52705. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52706. */
  52707. export class DirectionalLight extends ShadowLight {
  52708. private _shadowFrustumSize;
  52709. /**
  52710. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  52711. */
  52712. get shadowFrustumSize(): number;
  52713. /**
  52714. * Specifies a fix frustum size for the shadow generation.
  52715. */
  52716. set shadowFrustumSize(value: number);
  52717. private _shadowOrthoScale;
  52718. /**
  52719. * Gets the shadow projection scale against the optimal computed one.
  52720. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52721. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52722. */
  52723. get shadowOrthoScale(): number;
  52724. /**
  52725. * Sets the shadow projection scale against the optimal computed one.
  52726. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52727. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52728. */
  52729. set shadowOrthoScale(value: number);
  52730. /**
  52731. * Automatically compute the projection matrix to best fit (including all the casters)
  52732. * on each frame.
  52733. */
  52734. autoUpdateExtends: boolean;
  52735. /**
  52736. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  52737. * on each frame. autoUpdateExtends must be set to true for this to work
  52738. */
  52739. autoCalcShadowZBounds: boolean;
  52740. private _orthoLeft;
  52741. private _orthoRight;
  52742. private _orthoTop;
  52743. private _orthoBottom;
  52744. /**
  52745. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  52746. * The directional light is emitted from everywhere in the given direction.
  52747. * It can cast shadows.
  52748. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52749. * @param name The friendly name of the light
  52750. * @param direction The direction of the light
  52751. * @param scene The scene the light belongs to
  52752. */
  52753. constructor(name: string, direction: Vector3, scene: Scene);
  52754. /**
  52755. * Returns the string "DirectionalLight".
  52756. * @return The class name
  52757. */
  52758. getClassName(): string;
  52759. /**
  52760. * Returns the integer 1.
  52761. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52762. */
  52763. getTypeID(): number;
  52764. /**
  52765. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  52766. * Returns the DirectionalLight Shadow projection matrix.
  52767. */
  52768. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52769. /**
  52770. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  52771. * Returns the DirectionalLight Shadow projection matrix.
  52772. */
  52773. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  52774. /**
  52775. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  52776. * Returns the DirectionalLight Shadow projection matrix.
  52777. */
  52778. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52779. protected _buildUniformLayout(): void;
  52780. /**
  52781. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  52782. * @param effect The effect to update
  52783. * @param lightIndex The index of the light in the effect to update
  52784. * @returns The directional light
  52785. */
  52786. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  52787. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  52788. /**
  52789. * Gets the minZ used for shadow according to both the scene and the light.
  52790. *
  52791. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52792. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52793. * @param activeCamera The camera we are returning the min for
  52794. * @returns the depth min z
  52795. */
  52796. getDepthMinZ(activeCamera: Camera): number;
  52797. /**
  52798. * Gets the maxZ used for shadow according to both the scene and the light.
  52799. *
  52800. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52801. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52802. * @param activeCamera The camera we are returning the max for
  52803. * @returns the depth max z
  52804. */
  52805. getDepthMaxZ(activeCamera: Camera): number;
  52806. /**
  52807. * Prepares the list of defines specific to the light type.
  52808. * @param defines the list of defines
  52809. * @param lightIndex defines the index of the light for the effect
  52810. */
  52811. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52812. }
  52813. }
  52814. declare module BABYLON {
  52815. /**
  52816. * Class containing static functions to help procedurally build meshes
  52817. */
  52818. export class HemisphereBuilder {
  52819. /**
  52820. * Creates a hemisphere mesh
  52821. * @param name defines the name of the mesh
  52822. * @param options defines the options used to create the mesh
  52823. * @param scene defines the hosting scene
  52824. * @returns the hemisphere mesh
  52825. */
  52826. static CreateHemisphere(name: string, options: {
  52827. segments?: number;
  52828. diameter?: number;
  52829. sideOrientation?: number;
  52830. }, scene: any): Mesh;
  52831. }
  52832. }
  52833. declare module BABYLON {
  52834. /**
  52835. * A spot light is defined by a position, a direction, an angle, and an exponent.
  52836. * These values define a cone of light starting from the position, emitting toward the direction.
  52837. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  52838. * and the exponent defines the speed of the decay of the light with distance (reach).
  52839. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52840. */
  52841. export class SpotLight extends ShadowLight {
  52842. private _angle;
  52843. private _innerAngle;
  52844. private _cosHalfAngle;
  52845. private _lightAngleScale;
  52846. private _lightAngleOffset;
  52847. /**
  52848. * Gets the cone angle of the spot light in Radians.
  52849. */
  52850. get angle(): number;
  52851. /**
  52852. * Sets the cone angle of the spot light in Radians.
  52853. */
  52854. set angle(value: number);
  52855. /**
  52856. * Only used in gltf falloff mode, this defines the angle where
  52857. * the directional falloff will start before cutting at angle which could be seen
  52858. * as outer angle.
  52859. */
  52860. get innerAngle(): number;
  52861. /**
  52862. * Only used in gltf falloff mode, this defines the angle where
  52863. * the directional falloff will start before cutting at angle which could be seen
  52864. * as outer angle.
  52865. */
  52866. set innerAngle(value: number);
  52867. private _shadowAngleScale;
  52868. /**
  52869. * Allows scaling the angle of the light for shadow generation only.
  52870. */
  52871. get shadowAngleScale(): number;
  52872. /**
  52873. * Allows scaling the angle of the light for shadow generation only.
  52874. */
  52875. set shadowAngleScale(value: number);
  52876. /**
  52877. * The light decay speed with the distance from the emission spot.
  52878. */
  52879. exponent: number;
  52880. private _projectionTextureMatrix;
  52881. /**
  52882. * Allows reading the projecton texture
  52883. */
  52884. get projectionTextureMatrix(): Matrix;
  52885. protected _projectionTextureLightNear: number;
  52886. /**
  52887. * Gets the near clip of the Spotlight for texture projection.
  52888. */
  52889. get projectionTextureLightNear(): number;
  52890. /**
  52891. * Sets the near clip of the Spotlight for texture projection.
  52892. */
  52893. set projectionTextureLightNear(value: number);
  52894. protected _projectionTextureLightFar: number;
  52895. /**
  52896. * Gets the far clip of the Spotlight for texture projection.
  52897. */
  52898. get projectionTextureLightFar(): number;
  52899. /**
  52900. * Sets the far clip of the Spotlight for texture projection.
  52901. */
  52902. set projectionTextureLightFar(value: number);
  52903. protected _projectionTextureUpDirection: Vector3;
  52904. /**
  52905. * Gets the Up vector of the Spotlight for texture projection.
  52906. */
  52907. get projectionTextureUpDirection(): Vector3;
  52908. /**
  52909. * Sets the Up vector of the Spotlight for texture projection.
  52910. */
  52911. set projectionTextureUpDirection(value: Vector3);
  52912. private _projectionTexture;
  52913. /**
  52914. * Gets the projection texture of the light.
  52915. */
  52916. get projectionTexture(): Nullable<BaseTexture>;
  52917. /**
  52918. * Sets the projection texture of the light.
  52919. */
  52920. set projectionTexture(value: Nullable<BaseTexture>);
  52921. private _projectionTextureViewLightDirty;
  52922. private _projectionTextureProjectionLightDirty;
  52923. private _projectionTextureDirty;
  52924. private _projectionTextureViewTargetVector;
  52925. private _projectionTextureViewLightMatrix;
  52926. private _projectionTextureProjectionLightMatrix;
  52927. private _projectionTextureScalingMatrix;
  52928. /**
  52929. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  52930. * It can cast shadows.
  52931. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52932. * @param name The light friendly name
  52933. * @param position The position of the spot light in the scene
  52934. * @param direction The direction of the light in the scene
  52935. * @param angle The cone angle of the light in Radians
  52936. * @param exponent The light decay speed with the distance from the emission spot
  52937. * @param scene The scene the lights belongs to
  52938. */
  52939. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  52940. /**
  52941. * Returns the string "SpotLight".
  52942. * @returns the class name
  52943. */
  52944. getClassName(): string;
  52945. /**
  52946. * Returns the integer 2.
  52947. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52948. */
  52949. getTypeID(): number;
  52950. /**
  52951. * Overrides the direction setter to recompute the projection texture view light Matrix.
  52952. */
  52953. protected _setDirection(value: Vector3): void;
  52954. /**
  52955. * Overrides the position setter to recompute the projection texture view light Matrix.
  52956. */
  52957. protected _setPosition(value: Vector3): void;
  52958. /**
  52959. * 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.
  52960. * Returns the SpotLight.
  52961. */
  52962. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52963. protected _computeProjectionTextureViewLightMatrix(): void;
  52964. protected _computeProjectionTextureProjectionLightMatrix(): void;
  52965. /**
  52966. * Main function for light texture projection matrix computing.
  52967. */
  52968. protected _computeProjectionTextureMatrix(): void;
  52969. protected _buildUniformLayout(): void;
  52970. private _computeAngleValues;
  52971. /**
  52972. * Sets the passed Effect "effect" with the Light textures.
  52973. * @param effect The effect to update
  52974. * @param lightIndex The index of the light in the effect to update
  52975. * @returns The light
  52976. */
  52977. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  52978. /**
  52979. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  52980. * @param effect The effect to update
  52981. * @param lightIndex The index of the light in the effect to update
  52982. * @returns The spot light
  52983. */
  52984. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  52985. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52986. /**
  52987. * Disposes the light and the associated resources.
  52988. */
  52989. dispose(): void;
  52990. /**
  52991. * Prepares the list of defines specific to the light type.
  52992. * @param defines the list of defines
  52993. * @param lightIndex defines the index of the light for the effect
  52994. */
  52995. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52996. }
  52997. }
  52998. declare module BABYLON {
  52999. /**
  53000. * Gizmo that enables viewing a light
  53001. */
  53002. export class LightGizmo extends Gizmo {
  53003. private _lightMesh;
  53004. private _material;
  53005. private _cachedPosition;
  53006. private _cachedForward;
  53007. private _attachedMeshParent;
  53008. /**
  53009. * Creates a LightGizmo
  53010. * @param gizmoLayer The utility layer the gizmo will be added to
  53011. */
  53012. constructor(gizmoLayer?: UtilityLayerRenderer);
  53013. private _light;
  53014. /**
  53015. * The light that the gizmo is attached to
  53016. */
  53017. set light(light: Nullable<Light>);
  53018. get light(): Nullable<Light>;
  53019. /**
  53020. * Gets the material used to render the light gizmo
  53021. */
  53022. get material(): StandardMaterial;
  53023. /**
  53024. * @hidden
  53025. * Updates the gizmo to match the attached mesh's position/rotation
  53026. */
  53027. protected _update(): void;
  53028. private static _Scale;
  53029. /**
  53030. * Creates the lines for a light mesh
  53031. */
  53032. private static _CreateLightLines;
  53033. /**
  53034. * Disposes of the light gizmo
  53035. */
  53036. dispose(): void;
  53037. private static _CreateHemisphericLightMesh;
  53038. private static _CreatePointLightMesh;
  53039. private static _CreateSpotLightMesh;
  53040. private static _CreateDirectionalLightMesh;
  53041. }
  53042. }
  53043. declare module BABYLON {
  53044. /** @hidden */
  53045. export var backgroundFragmentDeclaration: {
  53046. name: string;
  53047. shader: string;
  53048. };
  53049. }
  53050. declare module BABYLON {
  53051. /** @hidden */
  53052. export var backgroundUboDeclaration: {
  53053. name: string;
  53054. shader: string;
  53055. };
  53056. }
  53057. declare module BABYLON {
  53058. /** @hidden */
  53059. export var backgroundPixelShader: {
  53060. name: string;
  53061. shader: string;
  53062. };
  53063. }
  53064. declare module BABYLON {
  53065. /** @hidden */
  53066. export var backgroundVertexDeclaration: {
  53067. name: string;
  53068. shader: string;
  53069. };
  53070. }
  53071. declare module BABYLON {
  53072. /** @hidden */
  53073. export var backgroundVertexShader: {
  53074. name: string;
  53075. shader: string;
  53076. };
  53077. }
  53078. declare module BABYLON {
  53079. /**
  53080. * Background material used to create an efficient environement around your scene.
  53081. */
  53082. export class BackgroundMaterial extends PushMaterial {
  53083. /**
  53084. * Standard reflectance value at parallel view angle.
  53085. */
  53086. static StandardReflectance0: number;
  53087. /**
  53088. * Standard reflectance value at grazing angle.
  53089. */
  53090. static StandardReflectance90: number;
  53091. protected _primaryColor: Color3;
  53092. /**
  53093. * Key light Color (multiply against the environement texture)
  53094. */
  53095. primaryColor: Color3;
  53096. protected __perceptualColor: Nullable<Color3>;
  53097. /**
  53098. * Experimental Internal Use Only.
  53099. *
  53100. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  53101. * This acts as a helper to set the primary color to a more "human friendly" value.
  53102. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  53103. * output color as close as possible from the chosen value.
  53104. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  53105. * part of lighting setup.)
  53106. */
  53107. get _perceptualColor(): Nullable<Color3>;
  53108. set _perceptualColor(value: Nullable<Color3>);
  53109. protected _primaryColorShadowLevel: float;
  53110. /**
  53111. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  53112. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  53113. */
  53114. get primaryColorShadowLevel(): float;
  53115. set primaryColorShadowLevel(value: float);
  53116. protected _primaryColorHighlightLevel: float;
  53117. /**
  53118. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  53119. * The primary color is used at the level chosen to define what the white area would look.
  53120. */
  53121. get primaryColorHighlightLevel(): float;
  53122. set primaryColorHighlightLevel(value: float);
  53123. protected _reflectionTexture: Nullable<BaseTexture>;
  53124. /**
  53125. * Reflection Texture used in the material.
  53126. * Should be author in a specific way for the best result (refer to the documentation).
  53127. */
  53128. reflectionTexture: Nullable<BaseTexture>;
  53129. protected _reflectionBlur: float;
  53130. /**
  53131. * Reflection Texture level of blur.
  53132. *
  53133. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  53134. * texture twice.
  53135. */
  53136. reflectionBlur: float;
  53137. protected _diffuseTexture: Nullable<BaseTexture>;
  53138. /**
  53139. * Diffuse Texture used in the material.
  53140. * Should be author in a specific way for the best result (refer to the documentation).
  53141. */
  53142. diffuseTexture: Nullable<BaseTexture>;
  53143. protected _shadowLights: Nullable<IShadowLight[]>;
  53144. /**
  53145. * Specify the list of lights casting shadow on the material.
  53146. * All scene shadow lights will be included if null.
  53147. */
  53148. shadowLights: Nullable<IShadowLight[]>;
  53149. protected _shadowLevel: float;
  53150. /**
  53151. * Helps adjusting the shadow to a softer level if required.
  53152. * 0 means black shadows and 1 means no shadows.
  53153. */
  53154. shadowLevel: float;
  53155. protected _sceneCenter: Vector3;
  53156. /**
  53157. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  53158. * It is usually zero but might be interesting to modify according to your setup.
  53159. */
  53160. sceneCenter: Vector3;
  53161. protected _opacityFresnel: boolean;
  53162. /**
  53163. * This helps specifying that the material is falling off to the sky box at grazing angle.
  53164. * This helps ensuring a nice transition when the camera goes under the ground.
  53165. */
  53166. opacityFresnel: boolean;
  53167. protected _reflectionFresnel: boolean;
  53168. /**
  53169. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  53170. * This helps adding a mirror texture on the ground.
  53171. */
  53172. reflectionFresnel: boolean;
  53173. protected _reflectionFalloffDistance: number;
  53174. /**
  53175. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  53176. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  53177. */
  53178. reflectionFalloffDistance: number;
  53179. protected _reflectionAmount: number;
  53180. /**
  53181. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  53182. */
  53183. reflectionAmount: number;
  53184. protected _reflectionReflectance0: number;
  53185. /**
  53186. * This specifies the weight of the reflection at grazing angle.
  53187. */
  53188. reflectionReflectance0: number;
  53189. protected _reflectionReflectance90: number;
  53190. /**
  53191. * This specifies the weight of the reflection at a perpendicular point of view.
  53192. */
  53193. reflectionReflectance90: number;
  53194. /**
  53195. * Sets the reflection reflectance fresnel values according to the default standard
  53196. * empirically know to work well :-)
  53197. */
  53198. set reflectionStandardFresnelWeight(value: number);
  53199. protected _useRGBColor: boolean;
  53200. /**
  53201. * Helps to directly use the maps channels instead of their level.
  53202. */
  53203. useRGBColor: boolean;
  53204. protected _enableNoise: boolean;
  53205. /**
  53206. * This helps reducing the banding effect that could occur on the background.
  53207. */
  53208. enableNoise: boolean;
  53209. /**
  53210. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53211. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  53212. * Recommended to be keep at 1.0 except for special cases.
  53213. */
  53214. get fovMultiplier(): number;
  53215. set fovMultiplier(value: number);
  53216. private _fovMultiplier;
  53217. /**
  53218. * Enable the FOV adjustment feature controlled by fovMultiplier.
  53219. */
  53220. useEquirectangularFOV: boolean;
  53221. private _maxSimultaneousLights;
  53222. /**
  53223. * Number of Simultaneous lights allowed on the material.
  53224. */
  53225. maxSimultaneousLights: int;
  53226. /**
  53227. * Default configuration related to image processing available in the Background Material.
  53228. */
  53229. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53230. /**
  53231. * Keep track of the image processing observer to allow dispose and replace.
  53232. */
  53233. private _imageProcessingObserver;
  53234. /**
  53235. * Attaches a new image processing configuration to the PBR Material.
  53236. * @param configuration (if null the scene configuration will be use)
  53237. */
  53238. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53239. /**
  53240. * Gets the image processing configuration used either in this material.
  53241. */
  53242. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  53243. /**
  53244. * Sets the Default image processing configuration used either in the this material.
  53245. *
  53246. * If sets to null, the scene one is in use.
  53247. */
  53248. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  53249. /**
  53250. * Gets wether the color curves effect is enabled.
  53251. */
  53252. get cameraColorCurvesEnabled(): boolean;
  53253. /**
  53254. * Sets wether the color curves effect is enabled.
  53255. */
  53256. set cameraColorCurvesEnabled(value: boolean);
  53257. /**
  53258. * Gets wether the color grading effect is enabled.
  53259. */
  53260. get cameraColorGradingEnabled(): boolean;
  53261. /**
  53262. * Gets wether the color grading effect is enabled.
  53263. */
  53264. set cameraColorGradingEnabled(value: boolean);
  53265. /**
  53266. * Gets wether tonemapping is enabled or not.
  53267. */
  53268. get cameraToneMappingEnabled(): boolean;
  53269. /**
  53270. * Sets wether tonemapping is enabled or not
  53271. */
  53272. set cameraToneMappingEnabled(value: boolean);
  53273. /**
  53274. * The camera exposure used on this material.
  53275. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53276. * This corresponds to a photographic exposure.
  53277. */
  53278. get cameraExposure(): float;
  53279. /**
  53280. * The camera exposure used on this material.
  53281. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53282. * This corresponds to a photographic exposure.
  53283. */
  53284. set cameraExposure(value: float);
  53285. /**
  53286. * Gets The camera contrast used on this material.
  53287. */
  53288. get cameraContrast(): float;
  53289. /**
  53290. * Sets The camera contrast used on this material.
  53291. */
  53292. set cameraContrast(value: float);
  53293. /**
  53294. * Gets the Color Grading 2D Lookup Texture.
  53295. */
  53296. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  53297. /**
  53298. * Sets the Color Grading 2D Lookup Texture.
  53299. */
  53300. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  53301. /**
  53302. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53303. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53304. * 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;
  53305. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53306. */
  53307. get cameraColorCurves(): Nullable<ColorCurves>;
  53308. /**
  53309. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53310. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53311. * 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;
  53312. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53313. */
  53314. set cameraColorCurves(value: Nullable<ColorCurves>);
  53315. /**
  53316. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  53317. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  53318. */
  53319. switchToBGR: boolean;
  53320. private _renderTargets;
  53321. private _reflectionControls;
  53322. private _white;
  53323. private _primaryShadowColor;
  53324. private _primaryHighlightColor;
  53325. /**
  53326. * Instantiates a Background Material in the given scene
  53327. * @param name The friendly name of the material
  53328. * @param scene The scene to add the material to
  53329. */
  53330. constructor(name: string, scene: Scene);
  53331. /**
  53332. * Gets a boolean indicating that current material needs to register RTT
  53333. */
  53334. get hasRenderTargetTextures(): boolean;
  53335. /**
  53336. * The entire material has been created in order to prevent overdraw.
  53337. * @returns false
  53338. */
  53339. needAlphaTesting(): boolean;
  53340. /**
  53341. * The entire material has been created in order to prevent overdraw.
  53342. * @returns true if blending is enable
  53343. */
  53344. needAlphaBlending(): boolean;
  53345. /**
  53346. * Checks wether the material is ready to be rendered for a given mesh.
  53347. * @param mesh The mesh to render
  53348. * @param subMesh The submesh to check against
  53349. * @param useInstances Specify wether or not the material is used with instances
  53350. * @returns true if all the dependencies are ready (Textures, Effects...)
  53351. */
  53352. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53353. /**
  53354. * Compute the primary color according to the chosen perceptual color.
  53355. */
  53356. private _computePrimaryColorFromPerceptualColor;
  53357. /**
  53358. * Compute the highlights and shadow colors according to their chosen levels.
  53359. */
  53360. private _computePrimaryColors;
  53361. /**
  53362. * Build the uniform buffer used in the material.
  53363. */
  53364. buildUniformLayout(): void;
  53365. /**
  53366. * Unbind the material.
  53367. */
  53368. unbind(): void;
  53369. /**
  53370. * Bind only the world matrix to the material.
  53371. * @param world The world matrix to bind.
  53372. */
  53373. bindOnlyWorldMatrix(world: Matrix): void;
  53374. /**
  53375. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  53376. * @param world The world matrix to bind.
  53377. * @param subMesh The submesh to bind for.
  53378. */
  53379. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53380. /**
  53381. * Checks to see if a texture is used in the material.
  53382. * @param texture - Base texture to use.
  53383. * @returns - Boolean specifying if a texture is used in the material.
  53384. */
  53385. hasTexture(texture: BaseTexture): boolean;
  53386. /**
  53387. * Dispose the material.
  53388. * @param forceDisposeEffect Force disposal of the associated effect.
  53389. * @param forceDisposeTextures Force disposal of the associated textures.
  53390. */
  53391. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53392. /**
  53393. * Clones the material.
  53394. * @param name The cloned name.
  53395. * @returns The cloned material.
  53396. */
  53397. clone(name: string): BackgroundMaterial;
  53398. /**
  53399. * Serializes the current material to its JSON representation.
  53400. * @returns The JSON representation.
  53401. */
  53402. serialize(): any;
  53403. /**
  53404. * Gets the class name of the material
  53405. * @returns "BackgroundMaterial"
  53406. */
  53407. getClassName(): string;
  53408. /**
  53409. * Parse a JSON input to create back a background material.
  53410. * @param source The JSON data to parse
  53411. * @param scene The scene to create the parsed material in
  53412. * @param rootUrl The root url of the assets the material depends upon
  53413. * @returns the instantiated BackgroundMaterial.
  53414. */
  53415. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  53416. }
  53417. }
  53418. declare module BABYLON {
  53419. /**
  53420. * Represents the different options available during the creation of
  53421. * a Environment helper.
  53422. *
  53423. * This can control the default ground, skybox and image processing setup of your scene.
  53424. */
  53425. export interface IEnvironmentHelperOptions {
  53426. /**
  53427. * Specifies whether or not to create a ground.
  53428. * True by default.
  53429. */
  53430. createGround: boolean;
  53431. /**
  53432. * Specifies the ground size.
  53433. * 15 by default.
  53434. */
  53435. groundSize: number;
  53436. /**
  53437. * The texture used on the ground for the main color.
  53438. * Comes from the BabylonJS CDN by default.
  53439. *
  53440. * Remarks: Can be either a texture or a url.
  53441. */
  53442. groundTexture: string | BaseTexture;
  53443. /**
  53444. * The color mixed in the ground texture by default.
  53445. * BabylonJS clearColor by default.
  53446. */
  53447. groundColor: Color3;
  53448. /**
  53449. * Specifies the ground opacity.
  53450. * 1 by default.
  53451. */
  53452. groundOpacity: number;
  53453. /**
  53454. * Enables the ground to receive shadows.
  53455. * True by default.
  53456. */
  53457. enableGroundShadow: boolean;
  53458. /**
  53459. * Helps preventing the shadow to be fully black on the ground.
  53460. * 0.5 by default.
  53461. */
  53462. groundShadowLevel: number;
  53463. /**
  53464. * Creates a mirror texture attach to the ground.
  53465. * false by default.
  53466. */
  53467. enableGroundMirror: boolean;
  53468. /**
  53469. * Specifies the ground mirror size ratio.
  53470. * 0.3 by default as the default kernel is 64.
  53471. */
  53472. groundMirrorSizeRatio: number;
  53473. /**
  53474. * Specifies the ground mirror blur kernel size.
  53475. * 64 by default.
  53476. */
  53477. groundMirrorBlurKernel: number;
  53478. /**
  53479. * Specifies the ground mirror visibility amount.
  53480. * 1 by default
  53481. */
  53482. groundMirrorAmount: number;
  53483. /**
  53484. * Specifies the ground mirror reflectance weight.
  53485. * This uses the standard weight of the background material to setup the fresnel effect
  53486. * of the mirror.
  53487. * 1 by default.
  53488. */
  53489. groundMirrorFresnelWeight: number;
  53490. /**
  53491. * Specifies the ground mirror Falloff distance.
  53492. * This can helps reducing the size of the reflection.
  53493. * 0 by Default.
  53494. */
  53495. groundMirrorFallOffDistance: number;
  53496. /**
  53497. * Specifies the ground mirror texture type.
  53498. * Unsigned Int by Default.
  53499. */
  53500. groundMirrorTextureType: number;
  53501. /**
  53502. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  53503. * the shown objects.
  53504. */
  53505. groundYBias: number;
  53506. /**
  53507. * Specifies whether or not to create a skybox.
  53508. * True by default.
  53509. */
  53510. createSkybox: boolean;
  53511. /**
  53512. * Specifies the skybox size.
  53513. * 20 by default.
  53514. */
  53515. skyboxSize: number;
  53516. /**
  53517. * The texture used on the skybox for the main color.
  53518. * Comes from the BabylonJS CDN by default.
  53519. *
  53520. * Remarks: Can be either a texture or a url.
  53521. */
  53522. skyboxTexture: string | BaseTexture;
  53523. /**
  53524. * The color mixed in the skybox texture by default.
  53525. * BabylonJS clearColor by default.
  53526. */
  53527. skyboxColor: Color3;
  53528. /**
  53529. * The background rotation around the Y axis of the scene.
  53530. * This helps aligning the key lights of your scene with the background.
  53531. * 0 by default.
  53532. */
  53533. backgroundYRotation: number;
  53534. /**
  53535. * Compute automatically the size of the elements to best fit with the scene.
  53536. */
  53537. sizeAuto: boolean;
  53538. /**
  53539. * Default position of the rootMesh if autoSize is not true.
  53540. */
  53541. rootPosition: Vector3;
  53542. /**
  53543. * Sets up the image processing in the scene.
  53544. * true by default.
  53545. */
  53546. setupImageProcessing: boolean;
  53547. /**
  53548. * The texture used as your environment texture in the scene.
  53549. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  53550. *
  53551. * Remarks: Can be either a texture or a url.
  53552. */
  53553. environmentTexture: string | BaseTexture;
  53554. /**
  53555. * The value of the exposure to apply to the scene.
  53556. * 0.6 by default if setupImageProcessing is true.
  53557. */
  53558. cameraExposure: number;
  53559. /**
  53560. * The value of the contrast to apply to the scene.
  53561. * 1.6 by default if setupImageProcessing is true.
  53562. */
  53563. cameraContrast: number;
  53564. /**
  53565. * Specifies whether or not tonemapping should be enabled in the scene.
  53566. * true by default if setupImageProcessing is true.
  53567. */
  53568. toneMappingEnabled: boolean;
  53569. }
  53570. /**
  53571. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  53572. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  53573. * It also helps with the default setup of your imageProcessing configuration.
  53574. */
  53575. export class EnvironmentHelper {
  53576. /**
  53577. * Default ground texture URL.
  53578. */
  53579. private static _groundTextureCDNUrl;
  53580. /**
  53581. * Default skybox texture URL.
  53582. */
  53583. private static _skyboxTextureCDNUrl;
  53584. /**
  53585. * Default environment texture URL.
  53586. */
  53587. private static _environmentTextureCDNUrl;
  53588. /**
  53589. * Creates the default options for the helper.
  53590. */
  53591. private static _getDefaultOptions;
  53592. private _rootMesh;
  53593. /**
  53594. * Gets the root mesh created by the helper.
  53595. */
  53596. get rootMesh(): Mesh;
  53597. private _skybox;
  53598. /**
  53599. * Gets the skybox created by the helper.
  53600. */
  53601. get skybox(): Nullable<Mesh>;
  53602. private _skyboxTexture;
  53603. /**
  53604. * Gets the skybox texture created by the helper.
  53605. */
  53606. get skyboxTexture(): Nullable<BaseTexture>;
  53607. private _skyboxMaterial;
  53608. /**
  53609. * Gets the skybox material created by the helper.
  53610. */
  53611. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  53612. private _ground;
  53613. /**
  53614. * Gets the ground mesh created by the helper.
  53615. */
  53616. get ground(): Nullable<Mesh>;
  53617. private _groundTexture;
  53618. /**
  53619. * Gets the ground texture created by the helper.
  53620. */
  53621. get groundTexture(): Nullable<BaseTexture>;
  53622. private _groundMirror;
  53623. /**
  53624. * Gets the ground mirror created by the helper.
  53625. */
  53626. get groundMirror(): Nullable<MirrorTexture>;
  53627. /**
  53628. * Gets the ground mirror render list to helps pushing the meshes
  53629. * you wish in the ground reflection.
  53630. */
  53631. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  53632. private _groundMaterial;
  53633. /**
  53634. * Gets the ground material created by the helper.
  53635. */
  53636. get groundMaterial(): Nullable<BackgroundMaterial>;
  53637. /**
  53638. * Stores the creation options.
  53639. */
  53640. private readonly _scene;
  53641. private _options;
  53642. /**
  53643. * This observable will be notified with any error during the creation of the environment,
  53644. * mainly texture creation errors.
  53645. */
  53646. onErrorObservable: Observable<{
  53647. message?: string;
  53648. exception?: any;
  53649. }>;
  53650. /**
  53651. * constructor
  53652. * @param options Defines the options we want to customize the helper
  53653. * @param scene The scene to add the material to
  53654. */
  53655. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  53656. /**
  53657. * Updates the background according to the new options
  53658. * @param options
  53659. */
  53660. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  53661. /**
  53662. * Sets the primary color of all the available elements.
  53663. * @param color the main color to affect to the ground and the background
  53664. */
  53665. setMainColor(color: Color3): void;
  53666. /**
  53667. * Setup the image processing according to the specified options.
  53668. */
  53669. private _setupImageProcessing;
  53670. /**
  53671. * Setup the environment texture according to the specified options.
  53672. */
  53673. private _setupEnvironmentTexture;
  53674. /**
  53675. * Setup the background according to the specified options.
  53676. */
  53677. private _setupBackground;
  53678. /**
  53679. * Get the scene sizes according to the setup.
  53680. */
  53681. private _getSceneSize;
  53682. /**
  53683. * Setup the ground according to the specified options.
  53684. */
  53685. private _setupGround;
  53686. /**
  53687. * Setup the ground material according to the specified options.
  53688. */
  53689. private _setupGroundMaterial;
  53690. /**
  53691. * Setup the ground diffuse texture according to the specified options.
  53692. */
  53693. private _setupGroundDiffuseTexture;
  53694. /**
  53695. * Setup the ground mirror texture according to the specified options.
  53696. */
  53697. private _setupGroundMirrorTexture;
  53698. /**
  53699. * Setup the ground to receive the mirror texture.
  53700. */
  53701. private _setupMirrorInGroundMaterial;
  53702. /**
  53703. * Setup the skybox according to the specified options.
  53704. */
  53705. private _setupSkybox;
  53706. /**
  53707. * Setup the skybox material according to the specified options.
  53708. */
  53709. private _setupSkyboxMaterial;
  53710. /**
  53711. * Setup the skybox reflection texture according to the specified options.
  53712. */
  53713. private _setupSkyboxReflectionTexture;
  53714. private _errorHandler;
  53715. /**
  53716. * Dispose all the elements created by the Helper.
  53717. */
  53718. dispose(): void;
  53719. }
  53720. }
  53721. declare module BABYLON {
  53722. /**
  53723. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  53724. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  53725. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  53726. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  53727. */
  53728. export class PhotoDome extends TransformNode {
  53729. /**
  53730. * Define the image as a Monoscopic panoramic 360 image.
  53731. */
  53732. static readonly MODE_MONOSCOPIC: number;
  53733. /**
  53734. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53735. */
  53736. static readonly MODE_TOPBOTTOM: number;
  53737. /**
  53738. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53739. */
  53740. static readonly MODE_SIDEBYSIDE: number;
  53741. private _useDirectMapping;
  53742. /**
  53743. * The texture being displayed on the sphere
  53744. */
  53745. protected _photoTexture: Texture;
  53746. /**
  53747. * Gets or sets the texture being displayed on the sphere
  53748. */
  53749. get photoTexture(): Texture;
  53750. set photoTexture(value: Texture);
  53751. /**
  53752. * Observable raised when an error occured while loading the 360 image
  53753. */
  53754. onLoadErrorObservable: Observable<string>;
  53755. /**
  53756. * The skybox material
  53757. */
  53758. protected _material: BackgroundMaterial;
  53759. /**
  53760. * The surface used for the skybox
  53761. */
  53762. protected _mesh: Mesh;
  53763. /**
  53764. * Gets the mesh used for the skybox.
  53765. */
  53766. get mesh(): Mesh;
  53767. /**
  53768. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53769. * Also see the options.resolution property.
  53770. */
  53771. get fovMultiplier(): number;
  53772. set fovMultiplier(value: number);
  53773. private _imageMode;
  53774. /**
  53775. * Gets or set the current video mode for the video. It can be:
  53776. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  53777. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53778. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53779. */
  53780. get imageMode(): number;
  53781. set imageMode(value: number);
  53782. /**
  53783. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  53784. * @param name Element's name, child elements will append suffixes for their own names.
  53785. * @param urlsOfPhoto defines the url of the photo to display
  53786. * @param options defines an object containing optional or exposed sub element properties
  53787. * @param onError defines a callback called when an error occured while loading the texture
  53788. */
  53789. constructor(name: string, urlOfPhoto: string, options: {
  53790. resolution?: number;
  53791. size?: number;
  53792. useDirectMapping?: boolean;
  53793. faceForward?: boolean;
  53794. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  53795. private _onBeforeCameraRenderObserver;
  53796. private _changeImageMode;
  53797. /**
  53798. * Releases resources associated with this node.
  53799. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53800. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53801. */
  53802. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53803. }
  53804. }
  53805. declare module BABYLON {
  53806. /**
  53807. * Class used to host RGBD texture specific utilities
  53808. */
  53809. export class RGBDTextureTools {
  53810. /**
  53811. * Expand the RGBD Texture from RGBD to Half Float if possible.
  53812. * @param texture the texture to expand.
  53813. */
  53814. static ExpandRGBDTexture(texture: Texture): void;
  53815. }
  53816. }
  53817. declare module BABYLON {
  53818. /**
  53819. * Class used to host texture specific utilities
  53820. */
  53821. export class BRDFTextureTools {
  53822. /**
  53823. * Prevents texture cache collision
  53824. */
  53825. private static _instanceNumber;
  53826. /**
  53827. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  53828. * @param scene defines the hosting scene
  53829. * @returns the environment BRDF texture
  53830. */
  53831. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  53832. private static _environmentBRDFBase64Texture;
  53833. }
  53834. }
  53835. declare module BABYLON {
  53836. /**
  53837. * @hidden
  53838. */
  53839. export interface IMaterialClearCoatDefines {
  53840. CLEARCOAT: boolean;
  53841. CLEARCOAT_DEFAULTIOR: boolean;
  53842. CLEARCOAT_TEXTURE: boolean;
  53843. CLEARCOAT_TEXTUREDIRECTUV: number;
  53844. CLEARCOAT_BUMP: boolean;
  53845. CLEARCOAT_BUMPDIRECTUV: number;
  53846. CLEARCOAT_TINT: boolean;
  53847. CLEARCOAT_TINT_TEXTURE: boolean;
  53848. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53849. /** @hidden */
  53850. _areTexturesDirty: boolean;
  53851. }
  53852. /**
  53853. * Define the code related to the clear coat parameters of the pbr material.
  53854. */
  53855. export class PBRClearCoatConfiguration {
  53856. /**
  53857. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53858. * The default fits with a polyurethane material.
  53859. */
  53860. private static readonly _DefaultIndexOfRefraction;
  53861. private _isEnabled;
  53862. /**
  53863. * Defines if the clear coat is enabled in the material.
  53864. */
  53865. isEnabled: boolean;
  53866. /**
  53867. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  53868. */
  53869. intensity: number;
  53870. /**
  53871. * Defines the clear coat layer roughness.
  53872. */
  53873. roughness: number;
  53874. private _indexOfRefraction;
  53875. /**
  53876. * Defines the index of refraction of the clear coat.
  53877. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53878. * The default fits with a polyurethane material.
  53879. * Changing the default value is more performance intensive.
  53880. */
  53881. indexOfRefraction: number;
  53882. private _texture;
  53883. /**
  53884. * Stores the clear coat values in a texture.
  53885. */
  53886. texture: Nullable<BaseTexture>;
  53887. private _bumpTexture;
  53888. /**
  53889. * Define the clear coat specific bump texture.
  53890. */
  53891. bumpTexture: Nullable<BaseTexture>;
  53892. private _isTintEnabled;
  53893. /**
  53894. * Defines if the clear coat tint is enabled in the material.
  53895. */
  53896. isTintEnabled: boolean;
  53897. /**
  53898. * Defines the clear coat tint of the material.
  53899. * This is only use if tint is enabled
  53900. */
  53901. tintColor: Color3;
  53902. /**
  53903. * Defines the distance at which the tint color should be found in the
  53904. * clear coat media.
  53905. * This is only use if tint is enabled
  53906. */
  53907. tintColorAtDistance: number;
  53908. /**
  53909. * Defines the clear coat layer thickness.
  53910. * This is only use if tint is enabled
  53911. */
  53912. tintThickness: number;
  53913. private _tintTexture;
  53914. /**
  53915. * Stores the clear tint values in a texture.
  53916. * rgb is tint
  53917. * a is a thickness factor
  53918. */
  53919. tintTexture: Nullable<BaseTexture>;
  53920. /** @hidden */
  53921. private _internalMarkAllSubMeshesAsTexturesDirty;
  53922. /** @hidden */
  53923. _markAllSubMeshesAsTexturesDirty(): void;
  53924. /**
  53925. * Instantiate a new istance of clear coat configuration.
  53926. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53927. */
  53928. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53929. /**
  53930. * Gets wehter the submesh is ready to be used or not.
  53931. * @param defines the list of "defines" to update.
  53932. * @param scene defines the scene the material belongs to.
  53933. * @param engine defines the engine the material belongs to.
  53934. * @param disableBumpMap defines wether the material disables bump or not.
  53935. * @returns - boolean indicating that the submesh is ready or not.
  53936. */
  53937. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  53938. /**
  53939. * Checks to see if a texture is used in the material.
  53940. * @param defines the list of "defines" to update.
  53941. * @param scene defines the scene to the material belongs to.
  53942. */
  53943. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  53944. /**
  53945. * Binds the material data.
  53946. * @param uniformBuffer defines the Uniform buffer to fill in.
  53947. * @param scene defines the scene the material belongs to.
  53948. * @param engine defines the engine the material belongs to.
  53949. * @param disableBumpMap defines wether the material disables bump or not.
  53950. * @param isFrozen defines wether the material is frozen or not.
  53951. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53952. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53953. */
  53954. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  53955. /**
  53956. * Checks to see if a texture is used in the material.
  53957. * @param texture - Base texture to use.
  53958. * @returns - Boolean specifying if a texture is used in the material.
  53959. */
  53960. hasTexture(texture: BaseTexture): boolean;
  53961. /**
  53962. * Returns an array of the actively used textures.
  53963. * @param activeTextures Array of BaseTextures
  53964. */
  53965. getActiveTextures(activeTextures: BaseTexture[]): void;
  53966. /**
  53967. * Returns the animatable textures.
  53968. * @param animatables Array of animatable textures.
  53969. */
  53970. getAnimatables(animatables: IAnimatable[]): void;
  53971. /**
  53972. * Disposes the resources of the material.
  53973. * @param forceDisposeTextures - Forces the disposal of all textures.
  53974. */
  53975. dispose(forceDisposeTextures?: boolean): void;
  53976. /**
  53977. * Get the current class name of the texture useful for serialization or dynamic coding.
  53978. * @returns "PBRClearCoatConfiguration"
  53979. */
  53980. getClassName(): string;
  53981. /**
  53982. * Add fallbacks to the effect fallbacks list.
  53983. * @param defines defines the Base texture to use.
  53984. * @param fallbacks defines the current fallback list.
  53985. * @param currentRank defines the current fallback rank.
  53986. * @returns the new fallback rank.
  53987. */
  53988. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53989. /**
  53990. * Add the required uniforms to the current list.
  53991. * @param uniforms defines the current uniform list.
  53992. */
  53993. static AddUniforms(uniforms: string[]): void;
  53994. /**
  53995. * Add the required samplers to the current list.
  53996. * @param samplers defines the current sampler list.
  53997. */
  53998. static AddSamplers(samplers: string[]): void;
  53999. /**
  54000. * Add the required uniforms to the current buffer.
  54001. * @param uniformBuffer defines the current uniform buffer.
  54002. */
  54003. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54004. /**
  54005. * Makes a duplicate of the current configuration into another one.
  54006. * @param clearCoatConfiguration define the config where to copy the info
  54007. */
  54008. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  54009. /**
  54010. * Serializes this clear coat configuration.
  54011. * @returns - An object with the serialized config.
  54012. */
  54013. serialize(): any;
  54014. /**
  54015. * Parses a anisotropy Configuration from a serialized object.
  54016. * @param source - Serialized object.
  54017. * @param scene Defines the scene we are parsing for
  54018. * @param rootUrl Defines the rootUrl to load from
  54019. */
  54020. parse(source: any, scene: Scene, rootUrl: string): void;
  54021. }
  54022. }
  54023. declare module BABYLON {
  54024. /**
  54025. * @hidden
  54026. */
  54027. export interface IMaterialAnisotropicDefines {
  54028. ANISOTROPIC: boolean;
  54029. ANISOTROPIC_TEXTURE: boolean;
  54030. ANISOTROPIC_TEXTUREDIRECTUV: number;
  54031. MAINUV1: boolean;
  54032. _areTexturesDirty: boolean;
  54033. _needUVs: boolean;
  54034. }
  54035. /**
  54036. * Define the code related to the anisotropic parameters of the pbr material.
  54037. */
  54038. export class PBRAnisotropicConfiguration {
  54039. private _isEnabled;
  54040. /**
  54041. * Defines if the anisotropy is enabled in the material.
  54042. */
  54043. isEnabled: boolean;
  54044. /**
  54045. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  54046. */
  54047. intensity: number;
  54048. /**
  54049. * Defines if the effect is along the tangents, bitangents or in between.
  54050. * By default, the effect is "strectching" the highlights along the tangents.
  54051. */
  54052. direction: Vector2;
  54053. private _texture;
  54054. /**
  54055. * Stores the anisotropy values in a texture.
  54056. * rg is direction (like normal from -1 to 1)
  54057. * b is a intensity
  54058. */
  54059. texture: Nullable<BaseTexture>;
  54060. /** @hidden */
  54061. private _internalMarkAllSubMeshesAsTexturesDirty;
  54062. /** @hidden */
  54063. _markAllSubMeshesAsTexturesDirty(): void;
  54064. /**
  54065. * Instantiate a new istance of anisotropy configuration.
  54066. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54067. */
  54068. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54069. /**
  54070. * Specifies that the submesh is ready to be used.
  54071. * @param defines the list of "defines" to update.
  54072. * @param scene defines the scene the material belongs to.
  54073. * @returns - boolean indicating that the submesh is ready or not.
  54074. */
  54075. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  54076. /**
  54077. * Checks to see if a texture is used in the material.
  54078. * @param defines the list of "defines" to update.
  54079. * @param mesh the mesh we are preparing the defines for.
  54080. * @param scene defines the scene the material belongs to.
  54081. */
  54082. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  54083. /**
  54084. * Binds the material data.
  54085. * @param uniformBuffer defines the Uniform buffer to fill in.
  54086. * @param scene defines the scene the material belongs to.
  54087. * @param isFrozen defines wether the material is frozen or not.
  54088. */
  54089. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  54090. /**
  54091. * Checks to see if a texture is used in the material.
  54092. * @param texture - Base texture to use.
  54093. * @returns - Boolean specifying if a texture is used in the material.
  54094. */
  54095. hasTexture(texture: BaseTexture): boolean;
  54096. /**
  54097. * Returns an array of the actively used textures.
  54098. * @param activeTextures Array of BaseTextures
  54099. */
  54100. getActiveTextures(activeTextures: BaseTexture[]): void;
  54101. /**
  54102. * Returns the animatable textures.
  54103. * @param animatables Array of animatable textures.
  54104. */
  54105. getAnimatables(animatables: IAnimatable[]): void;
  54106. /**
  54107. * Disposes the resources of the material.
  54108. * @param forceDisposeTextures - Forces the disposal of all textures.
  54109. */
  54110. dispose(forceDisposeTextures?: boolean): void;
  54111. /**
  54112. * Get the current class name of the texture useful for serialization or dynamic coding.
  54113. * @returns "PBRAnisotropicConfiguration"
  54114. */
  54115. getClassName(): string;
  54116. /**
  54117. * Add fallbacks to the effect fallbacks list.
  54118. * @param defines defines the Base texture to use.
  54119. * @param fallbacks defines the current fallback list.
  54120. * @param currentRank defines the current fallback rank.
  54121. * @returns the new fallback rank.
  54122. */
  54123. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54124. /**
  54125. * Add the required uniforms to the current list.
  54126. * @param uniforms defines the current uniform list.
  54127. */
  54128. static AddUniforms(uniforms: string[]): void;
  54129. /**
  54130. * Add the required uniforms to the current buffer.
  54131. * @param uniformBuffer defines the current uniform buffer.
  54132. */
  54133. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54134. /**
  54135. * Add the required samplers to the current list.
  54136. * @param samplers defines the current sampler list.
  54137. */
  54138. static AddSamplers(samplers: string[]): void;
  54139. /**
  54140. * Makes a duplicate of the current configuration into another one.
  54141. * @param anisotropicConfiguration define the config where to copy the info
  54142. */
  54143. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  54144. /**
  54145. * Serializes this anisotropy configuration.
  54146. * @returns - An object with the serialized config.
  54147. */
  54148. serialize(): any;
  54149. /**
  54150. * Parses a anisotropy Configuration from a serialized object.
  54151. * @param source - Serialized object.
  54152. * @param scene Defines the scene we are parsing for
  54153. * @param rootUrl Defines the rootUrl to load from
  54154. */
  54155. parse(source: any, scene: Scene, rootUrl: string): void;
  54156. }
  54157. }
  54158. declare module BABYLON {
  54159. /**
  54160. * @hidden
  54161. */
  54162. export interface IMaterialBRDFDefines {
  54163. BRDF_V_HEIGHT_CORRELATED: boolean;
  54164. MS_BRDF_ENERGY_CONSERVATION: boolean;
  54165. SPHERICAL_HARMONICS: boolean;
  54166. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  54167. /** @hidden */
  54168. _areMiscDirty: boolean;
  54169. }
  54170. /**
  54171. * Define the code related to the BRDF parameters of the pbr material.
  54172. */
  54173. export class PBRBRDFConfiguration {
  54174. /**
  54175. * Default value used for the energy conservation.
  54176. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  54177. */
  54178. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  54179. /**
  54180. * Default value used for the Smith Visibility Height Correlated mode.
  54181. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  54182. */
  54183. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  54184. /**
  54185. * Default value used for the IBL diffuse part.
  54186. * This can help switching back to the polynomials mode globally which is a tiny bit
  54187. * less GPU intensive at the drawback of a lower quality.
  54188. */
  54189. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  54190. /**
  54191. * Default value used for activating energy conservation for the specular workflow.
  54192. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  54193. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  54194. */
  54195. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  54196. private _useEnergyConservation;
  54197. /**
  54198. * Defines if the material uses energy conservation.
  54199. */
  54200. useEnergyConservation: boolean;
  54201. private _useSmithVisibilityHeightCorrelated;
  54202. /**
  54203. * LEGACY Mode set to false
  54204. * Defines if the material uses height smith correlated visibility term.
  54205. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  54206. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  54207. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  54208. * Not relying on height correlated will also disable energy conservation.
  54209. */
  54210. useSmithVisibilityHeightCorrelated: boolean;
  54211. private _useSphericalHarmonics;
  54212. /**
  54213. * LEGACY Mode set to false
  54214. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  54215. * diffuse part of the IBL.
  54216. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  54217. * to the ground truth.
  54218. */
  54219. useSphericalHarmonics: boolean;
  54220. private _useSpecularGlossinessInputEnergyConservation;
  54221. /**
  54222. * Defines if the material uses energy conservation, when the specular workflow is active.
  54223. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  54224. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  54225. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  54226. */
  54227. useSpecularGlossinessInputEnergyConservation: boolean;
  54228. /** @hidden */
  54229. private _internalMarkAllSubMeshesAsMiscDirty;
  54230. /** @hidden */
  54231. _markAllSubMeshesAsMiscDirty(): void;
  54232. /**
  54233. * Instantiate a new istance of clear coat configuration.
  54234. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  54235. */
  54236. constructor(markAllSubMeshesAsMiscDirty: () => void);
  54237. /**
  54238. * Checks to see if a texture is used in the material.
  54239. * @param defines the list of "defines" to update.
  54240. */
  54241. prepareDefines(defines: IMaterialBRDFDefines): void;
  54242. /**
  54243. * Get the current class name of the texture useful for serialization or dynamic coding.
  54244. * @returns "PBRClearCoatConfiguration"
  54245. */
  54246. getClassName(): string;
  54247. /**
  54248. * Makes a duplicate of the current configuration into another one.
  54249. * @param brdfConfiguration define the config where to copy the info
  54250. */
  54251. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  54252. /**
  54253. * Serializes this BRDF configuration.
  54254. * @returns - An object with the serialized config.
  54255. */
  54256. serialize(): any;
  54257. /**
  54258. * Parses a anisotropy Configuration from a serialized object.
  54259. * @param source - Serialized object.
  54260. * @param scene Defines the scene we are parsing for
  54261. * @param rootUrl Defines the rootUrl to load from
  54262. */
  54263. parse(source: any, scene: Scene, rootUrl: string): void;
  54264. }
  54265. }
  54266. declare module BABYLON {
  54267. /**
  54268. * @hidden
  54269. */
  54270. export interface IMaterialSheenDefines {
  54271. SHEEN: boolean;
  54272. SHEEN_TEXTURE: boolean;
  54273. SHEEN_TEXTUREDIRECTUV: number;
  54274. SHEEN_LINKWITHALBEDO: boolean;
  54275. SHEEN_ROUGHNESS: boolean;
  54276. SHEEN_ALBEDOSCALING: boolean;
  54277. /** @hidden */
  54278. _areTexturesDirty: boolean;
  54279. }
  54280. /**
  54281. * Define the code related to the Sheen parameters of the pbr material.
  54282. */
  54283. export class PBRSheenConfiguration {
  54284. private _isEnabled;
  54285. /**
  54286. * Defines if the material uses sheen.
  54287. */
  54288. isEnabled: boolean;
  54289. private _linkSheenWithAlbedo;
  54290. /**
  54291. * Defines if the sheen is linked to the sheen color.
  54292. */
  54293. linkSheenWithAlbedo: boolean;
  54294. /**
  54295. * Defines the sheen intensity.
  54296. */
  54297. intensity: number;
  54298. /**
  54299. * Defines the sheen color.
  54300. */
  54301. color: Color3;
  54302. private _texture;
  54303. /**
  54304. * Stores the sheen tint values in a texture.
  54305. * rgb is tint
  54306. * a is a intensity
  54307. */
  54308. texture: Nullable<BaseTexture>;
  54309. private _roughness;
  54310. /**
  54311. * Defines the sheen roughness.
  54312. * It is not taken into account if linkSheenWithAlbedo is true.
  54313. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  54314. */
  54315. roughness: Nullable<number>;
  54316. private _albedoScaling;
  54317. /**
  54318. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  54319. * It allows the strength of the sheen effect to not depend on the base color of the material,
  54320. * making it easier to setup and tweak the effect
  54321. */
  54322. albedoScaling: boolean;
  54323. /** @hidden */
  54324. private _internalMarkAllSubMeshesAsTexturesDirty;
  54325. /** @hidden */
  54326. _markAllSubMeshesAsTexturesDirty(): void;
  54327. /**
  54328. * Instantiate a new istance of clear coat configuration.
  54329. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54330. */
  54331. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54332. /**
  54333. * Specifies that the submesh is ready to be used.
  54334. * @param defines the list of "defines" to update.
  54335. * @param scene defines the scene the material belongs to.
  54336. * @returns - boolean indicating that the submesh is ready or not.
  54337. */
  54338. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  54339. /**
  54340. * Checks to see if a texture is used in the material.
  54341. * @param defines the list of "defines" to update.
  54342. * @param scene defines the scene the material belongs to.
  54343. */
  54344. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  54345. /**
  54346. * Binds the material data.
  54347. * @param uniformBuffer defines the Uniform buffer to fill in.
  54348. * @param scene defines the scene the material belongs to.
  54349. * @param isFrozen defines wether the material is frozen or not.
  54350. */
  54351. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  54352. /**
  54353. * Checks to see if a texture is used in the material.
  54354. * @param texture - Base texture to use.
  54355. * @returns - Boolean specifying if a texture is used in the material.
  54356. */
  54357. hasTexture(texture: BaseTexture): boolean;
  54358. /**
  54359. * Returns an array of the actively used textures.
  54360. * @param activeTextures Array of BaseTextures
  54361. */
  54362. getActiveTextures(activeTextures: BaseTexture[]): void;
  54363. /**
  54364. * Returns the animatable textures.
  54365. * @param animatables Array of animatable textures.
  54366. */
  54367. getAnimatables(animatables: IAnimatable[]): void;
  54368. /**
  54369. * Disposes the resources of the material.
  54370. * @param forceDisposeTextures - Forces the disposal of all textures.
  54371. */
  54372. dispose(forceDisposeTextures?: boolean): void;
  54373. /**
  54374. * Get the current class name of the texture useful for serialization or dynamic coding.
  54375. * @returns "PBRSheenConfiguration"
  54376. */
  54377. getClassName(): string;
  54378. /**
  54379. * Add fallbacks to the effect fallbacks list.
  54380. * @param defines defines the Base texture to use.
  54381. * @param fallbacks defines the current fallback list.
  54382. * @param currentRank defines the current fallback rank.
  54383. * @returns the new fallback rank.
  54384. */
  54385. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54386. /**
  54387. * Add the required uniforms to the current list.
  54388. * @param uniforms defines the current uniform list.
  54389. */
  54390. static AddUniforms(uniforms: string[]): void;
  54391. /**
  54392. * Add the required uniforms to the current buffer.
  54393. * @param uniformBuffer defines the current uniform buffer.
  54394. */
  54395. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54396. /**
  54397. * Add the required samplers to the current list.
  54398. * @param samplers defines the current sampler list.
  54399. */
  54400. static AddSamplers(samplers: string[]): void;
  54401. /**
  54402. * Makes a duplicate of the current configuration into another one.
  54403. * @param sheenConfiguration define the config where to copy the info
  54404. */
  54405. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  54406. /**
  54407. * Serializes this BRDF configuration.
  54408. * @returns - An object with the serialized config.
  54409. */
  54410. serialize(): any;
  54411. /**
  54412. * Parses a anisotropy Configuration from a serialized object.
  54413. * @param source - Serialized object.
  54414. * @param scene Defines the scene we are parsing for
  54415. * @param rootUrl Defines the rootUrl to load from
  54416. */
  54417. parse(source: any, scene: Scene, rootUrl: string): void;
  54418. }
  54419. }
  54420. declare module BABYLON {
  54421. /**
  54422. * @hidden
  54423. */
  54424. export interface IMaterialSubSurfaceDefines {
  54425. SUBSURFACE: boolean;
  54426. SS_REFRACTION: boolean;
  54427. SS_TRANSLUCENCY: boolean;
  54428. SS_SCATTERING: boolean;
  54429. SS_THICKNESSANDMASK_TEXTURE: boolean;
  54430. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  54431. SS_REFRACTIONMAP_3D: boolean;
  54432. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  54433. SS_LODINREFRACTIONALPHA: boolean;
  54434. SS_GAMMAREFRACTION: boolean;
  54435. SS_RGBDREFRACTION: boolean;
  54436. SS_LINEARSPECULARREFRACTION: boolean;
  54437. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  54438. SS_ALBEDOFORREFRACTIONTINT: boolean;
  54439. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  54440. /** @hidden */
  54441. _areTexturesDirty: boolean;
  54442. }
  54443. /**
  54444. * Define the code related to the sub surface parameters of the pbr material.
  54445. */
  54446. export class PBRSubSurfaceConfiguration {
  54447. private _isRefractionEnabled;
  54448. /**
  54449. * Defines if the refraction is enabled in the material.
  54450. */
  54451. isRefractionEnabled: boolean;
  54452. private _isTranslucencyEnabled;
  54453. /**
  54454. * Defines if the translucency is enabled in the material.
  54455. */
  54456. isTranslucencyEnabled: boolean;
  54457. private _isScatteringEnabled;
  54458. /**
  54459. * Defines the refraction intensity of the material.
  54460. * The refraction when enabled replaces the Diffuse part of the material.
  54461. * The intensity helps transitionning between diffuse and refraction.
  54462. */
  54463. refractionIntensity: number;
  54464. /**
  54465. * Defines the translucency intensity of the material.
  54466. * When translucency has been enabled, this defines how much of the "translucency"
  54467. * is addded to the diffuse part of the material.
  54468. */
  54469. translucencyIntensity: number;
  54470. /**
  54471. * Defines the scattering intensity of the material.
  54472. * When scattering has been enabled, this defines how much of the "scattered light"
  54473. * is addded to the diffuse part of the material.
  54474. */
  54475. scatteringIntensity: number;
  54476. /**
  54477. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  54478. */
  54479. useAlbedoToTintRefraction: boolean;
  54480. private _thicknessTexture;
  54481. /**
  54482. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  54483. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  54484. * 0 would mean minimumThickness
  54485. * 1 would mean maximumThickness
  54486. * The other channels might be use as a mask to vary the different effects intensity.
  54487. */
  54488. thicknessTexture: Nullable<BaseTexture>;
  54489. private _refractionTexture;
  54490. /**
  54491. * Defines the texture to use for refraction.
  54492. */
  54493. refractionTexture: Nullable<BaseTexture>;
  54494. private _indexOfRefraction;
  54495. /**
  54496. * Index of refraction of the material base layer.
  54497. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  54498. *
  54499. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  54500. *
  54501. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  54502. */
  54503. indexOfRefraction: number;
  54504. private _volumeIndexOfRefraction;
  54505. /**
  54506. * Index of refraction of the material's volume.
  54507. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  54508. *
  54509. * This ONLY impacts refraction. If not provided or given a non-valid value,
  54510. * the volume will use the same IOR as the surface.
  54511. */
  54512. get volumeIndexOfRefraction(): number;
  54513. set volumeIndexOfRefraction(value: number);
  54514. private _invertRefractionY;
  54515. /**
  54516. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54517. */
  54518. invertRefractionY: boolean;
  54519. private _linkRefractionWithTransparency;
  54520. /**
  54521. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54522. * Materials half opaque for instance using refraction could benefit from this control.
  54523. */
  54524. linkRefractionWithTransparency: boolean;
  54525. /**
  54526. * Defines the minimum thickness stored in the thickness map.
  54527. * If no thickness map is defined, this value will be used to simulate thickness.
  54528. */
  54529. minimumThickness: number;
  54530. /**
  54531. * Defines the maximum thickness stored in the thickness map.
  54532. */
  54533. maximumThickness: number;
  54534. /**
  54535. * Defines the volume tint of the material.
  54536. * This is used for both translucency and scattering.
  54537. */
  54538. tintColor: Color3;
  54539. /**
  54540. * Defines the distance at which the tint color should be found in the media.
  54541. * This is used for refraction only.
  54542. */
  54543. tintColorAtDistance: number;
  54544. /**
  54545. * Defines how far each channel transmit through the media.
  54546. * It is defined as a color to simplify it selection.
  54547. */
  54548. diffusionDistance: Color3;
  54549. private _useMaskFromThicknessTexture;
  54550. /**
  54551. * Stores the intensity of the different subsurface effects in the thickness texture.
  54552. * * the green channel is the translucency intensity.
  54553. * * the blue channel is the scattering intensity.
  54554. * * the alpha channel is the refraction intensity.
  54555. */
  54556. useMaskFromThicknessTexture: boolean;
  54557. /** @hidden */
  54558. private _internalMarkAllSubMeshesAsTexturesDirty;
  54559. /** @hidden */
  54560. _markAllSubMeshesAsTexturesDirty(): void;
  54561. /**
  54562. * Instantiate a new istance of sub surface configuration.
  54563. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54564. */
  54565. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54566. /**
  54567. * Gets wehter the submesh is ready to be used or not.
  54568. * @param defines the list of "defines" to update.
  54569. * @param scene defines the scene the material belongs to.
  54570. * @returns - boolean indicating that the submesh is ready or not.
  54571. */
  54572. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  54573. /**
  54574. * Checks to see if a texture is used in the material.
  54575. * @param defines the list of "defines" to update.
  54576. * @param scene defines the scene to the material belongs to.
  54577. */
  54578. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  54579. /**
  54580. * Binds the material data.
  54581. * @param uniformBuffer defines the Uniform buffer to fill in.
  54582. * @param scene defines the scene the material belongs to.
  54583. * @param engine defines the engine the material belongs to.
  54584. * @param isFrozen defines whether the material is frozen or not.
  54585. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  54586. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  54587. */
  54588. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  54589. /**
  54590. * Unbinds the material from the mesh.
  54591. * @param activeEffect defines the effect that should be unbound from.
  54592. * @returns true if unbound, otherwise false
  54593. */
  54594. unbind(activeEffect: Effect): boolean;
  54595. /**
  54596. * Returns the texture used for refraction or null if none is used.
  54597. * @param scene defines the scene the material belongs to.
  54598. * @returns - Refraction texture if present. If no refraction texture and refraction
  54599. * is linked with transparency, returns environment texture. Otherwise, returns null.
  54600. */
  54601. private _getRefractionTexture;
  54602. /**
  54603. * Returns true if alpha blending should be disabled.
  54604. */
  54605. get disableAlphaBlending(): boolean;
  54606. /**
  54607. * Fills the list of render target textures.
  54608. * @param renderTargets the list of render targets to update
  54609. */
  54610. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  54611. /**
  54612. * Checks to see if a texture is used in the material.
  54613. * @param texture - Base texture to use.
  54614. * @returns - Boolean specifying if a texture is used in the material.
  54615. */
  54616. hasTexture(texture: BaseTexture): boolean;
  54617. /**
  54618. * Gets a boolean indicating that current material needs to register RTT
  54619. * @returns true if this uses a render target otherwise false.
  54620. */
  54621. hasRenderTargetTextures(): boolean;
  54622. /**
  54623. * Returns an array of the actively used textures.
  54624. * @param activeTextures Array of BaseTextures
  54625. */
  54626. getActiveTextures(activeTextures: BaseTexture[]): void;
  54627. /**
  54628. * Returns the animatable textures.
  54629. * @param animatables Array of animatable textures.
  54630. */
  54631. getAnimatables(animatables: IAnimatable[]): void;
  54632. /**
  54633. * Disposes the resources of the material.
  54634. * @param forceDisposeTextures - Forces the disposal of all textures.
  54635. */
  54636. dispose(forceDisposeTextures?: boolean): void;
  54637. /**
  54638. * Get the current class name of the texture useful for serialization or dynamic coding.
  54639. * @returns "PBRSubSurfaceConfiguration"
  54640. */
  54641. getClassName(): string;
  54642. /**
  54643. * Add fallbacks to the effect fallbacks list.
  54644. * @param defines defines the Base texture to use.
  54645. * @param fallbacks defines the current fallback list.
  54646. * @param currentRank defines the current fallback rank.
  54647. * @returns the new fallback rank.
  54648. */
  54649. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54650. /**
  54651. * Add the required uniforms to the current list.
  54652. * @param uniforms defines the current uniform list.
  54653. */
  54654. static AddUniforms(uniforms: string[]): void;
  54655. /**
  54656. * Add the required samplers to the current list.
  54657. * @param samplers defines the current sampler list.
  54658. */
  54659. static AddSamplers(samplers: string[]): void;
  54660. /**
  54661. * Add the required uniforms to the current buffer.
  54662. * @param uniformBuffer defines the current uniform buffer.
  54663. */
  54664. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54665. /**
  54666. * Makes a duplicate of the current configuration into another one.
  54667. * @param configuration define the config where to copy the info
  54668. */
  54669. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  54670. /**
  54671. * Serializes this Sub Surface configuration.
  54672. * @returns - An object with the serialized config.
  54673. */
  54674. serialize(): any;
  54675. /**
  54676. * Parses a anisotropy Configuration from a serialized object.
  54677. * @param source - Serialized object.
  54678. * @param scene Defines the scene we are parsing for
  54679. * @param rootUrl Defines the rootUrl to load from
  54680. */
  54681. parse(source: any, scene: Scene, rootUrl: string): void;
  54682. }
  54683. }
  54684. declare module BABYLON {
  54685. /** @hidden */
  54686. export var pbrFragmentDeclaration: {
  54687. name: string;
  54688. shader: string;
  54689. };
  54690. }
  54691. declare module BABYLON {
  54692. /** @hidden */
  54693. export var pbrUboDeclaration: {
  54694. name: string;
  54695. shader: string;
  54696. };
  54697. }
  54698. declare module BABYLON {
  54699. /** @hidden */
  54700. export var pbrFragmentExtraDeclaration: {
  54701. name: string;
  54702. shader: string;
  54703. };
  54704. }
  54705. declare module BABYLON {
  54706. /** @hidden */
  54707. export var pbrFragmentSamplersDeclaration: {
  54708. name: string;
  54709. shader: string;
  54710. };
  54711. }
  54712. declare module BABYLON {
  54713. /** @hidden */
  54714. export var importanceSampling: {
  54715. name: string;
  54716. shader: string;
  54717. };
  54718. }
  54719. declare module BABYLON {
  54720. /** @hidden */
  54721. export var pbrHelperFunctions: {
  54722. name: string;
  54723. shader: string;
  54724. };
  54725. }
  54726. declare module BABYLON {
  54727. /** @hidden */
  54728. export var harmonicsFunctions: {
  54729. name: string;
  54730. shader: string;
  54731. };
  54732. }
  54733. declare module BABYLON {
  54734. /** @hidden */
  54735. export var pbrDirectLightingSetupFunctions: {
  54736. name: string;
  54737. shader: string;
  54738. };
  54739. }
  54740. declare module BABYLON {
  54741. /** @hidden */
  54742. export var pbrDirectLightingFalloffFunctions: {
  54743. name: string;
  54744. shader: string;
  54745. };
  54746. }
  54747. declare module BABYLON {
  54748. /** @hidden */
  54749. export var pbrBRDFFunctions: {
  54750. name: string;
  54751. shader: string;
  54752. };
  54753. }
  54754. declare module BABYLON {
  54755. /** @hidden */
  54756. export var hdrFilteringFunctions: {
  54757. name: string;
  54758. shader: string;
  54759. };
  54760. }
  54761. declare module BABYLON {
  54762. /** @hidden */
  54763. export var pbrDirectLightingFunctions: {
  54764. name: string;
  54765. shader: string;
  54766. };
  54767. }
  54768. declare module BABYLON {
  54769. /** @hidden */
  54770. export var pbrIBLFunctions: {
  54771. name: string;
  54772. shader: string;
  54773. };
  54774. }
  54775. declare module BABYLON {
  54776. /** @hidden */
  54777. export var pbrBlockAlbedoOpacity: {
  54778. name: string;
  54779. shader: string;
  54780. };
  54781. }
  54782. declare module BABYLON {
  54783. /** @hidden */
  54784. export var pbrBlockReflectivity: {
  54785. name: string;
  54786. shader: string;
  54787. };
  54788. }
  54789. declare module BABYLON {
  54790. /** @hidden */
  54791. export var pbrBlockAmbientOcclusion: {
  54792. name: string;
  54793. shader: string;
  54794. };
  54795. }
  54796. declare module BABYLON {
  54797. /** @hidden */
  54798. export var pbrBlockAlphaFresnel: {
  54799. name: string;
  54800. shader: string;
  54801. };
  54802. }
  54803. declare module BABYLON {
  54804. /** @hidden */
  54805. export var pbrBlockAnisotropic: {
  54806. name: string;
  54807. shader: string;
  54808. };
  54809. }
  54810. declare module BABYLON {
  54811. /** @hidden */
  54812. export var pbrBlockReflection: {
  54813. name: string;
  54814. shader: string;
  54815. };
  54816. }
  54817. declare module BABYLON {
  54818. /** @hidden */
  54819. export var pbrBlockSheen: {
  54820. name: string;
  54821. shader: string;
  54822. };
  54823. }
  54824. declare module BABYLON {
  54825. /** @hidden */
  54826. export var pbrBlockClearcoat: {
  54827. name: string;
  54828. shader: string;
  54829. };
  54830. }
  54831. declare module BABYLON {
  54832. /** @hidden */
  54833. export var pbrBlockSubSurface: {
  54834. name: string;
  54835. shader: string;
  54836. };
  54837. }
  54838. declare module BABYLON {
  54839. /** @hidden */
  54840. export var pbrBlockNormalGeometric: {
  54841. name: string;
  54842. shader: string;
  54843. };
  54844. }
  54845. declare module BABYLON {
  54846. /** @hidden */
  54847. export var pbrBlockNormalFinal: {
  54848. name: string;
  54849. shader: string;
  54850. };
  54851. }
  54852. declare module BABYLON {
  54853. /** @hidden */
  54854. export var pbrBlockGeometryInfo: {
  54855. name: string;
  54856. shader: string;
  54857. };
  54858. }
  54859. declare module BABYLON {
  54860. /** @hidden */
  54861. export var pbrBlockReflectance0: {
  54862. name: string;
  54863. shader: string;
  54864. };
  54865. }
  54866. declare module BABYLON {
  54867. /** @hidden */
  54868. export var pbrBlockReflectance: {
  54869. name: string;
  54870. shader: string;
  54871. };
  54872. }
  54873. declare module BABYLON {
  54874. /** @hidden */
  54875. export var pbrBlockDirectLighting: {
  54876. name: string;
  54877. shader: string;
  54878. };
  54879. }
  54880. declare module BABYLON {
  54881. /** @hidden */
  54882. export var pbrBlockFinalLitComponents: {
  54883. name: string;
  54884. shader: string;
  54885. };
  54886. }
  54887. declare module BABYLON {
  54888. /** @hidden */
  54889. export var pbrBlockFinalUnlitComponents: {
  54890. name: string;
  54891. shader: string;
  54892. };
  54893. }
  54894. declare module BABYLON {
  54895. /** @hidden */
  54896. export var pbrBlockFinalColorComposition: {
  54897. name: string;
  54898. shader: string;
  54899. };
  54900. }
  54901. declare module BABYLON {
  54902. /** @hidden */
  54903. export var pbrBlockImageProcessing: {
  54904. name: string;
  54905. shader: string;
  54906. };
  54907. }
  54908. declare module BABYLON {
  54909. /** @hidden */
  54910. export var pbrDebug: {
  54911. name: string;
  54912. shader: string;
  54913. };
  54914. }
  54915. declare module BABYLON {
  54916. /** @hidden */
  54917. export var pbrPixelShader: {
  54918. name: string;
  54919. shader: string;
  54920. };
  54921. }
  54922. declare module BABYLON {
  54923. /** @hidden */
  54924. export var pbrVertexDeclaration: {
  54925. name: string;
  54926. shader: string;
  54927. };
  54928. }
  54929. declare module BABYLON {
  54930. /** @hidden */
  54931. export var pbrVertexShader: {
  54932. name: string;
  54933. shader: string;
  54934. };
  54935. }
  54936. declare module BABYLON {
  54937. /**
  54938. * Manages the defines for the PBR Material.
  54939. * @hidden
  54940. */
  54941. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  54942. PBR: boolean;
  54943. NUM_SAMPLES: string;
  54944. REALTIME_FILTERING: boolean;
  54945. MAINUV1: boolean;
  54946. MAINUV2: boolean;
  54947. UV1: boolean;
  54948. UV2: boolean;
  54949. ALBEDO: boolean;
  54950. GAMMAALBEDO: boolean;
  54951. ALBEDODIRECTUV: number;
  54952. VERTEXCOLOR: boolean;
  54953. DETAIL: boolean;
  54954. DETAILDIRECTUV: number;
  54955. DETAIL_NORMALBLENDMETHOD: number;
  54956. AMBIENT: boolean;
  54957. AMBIENTDIRECTUV: number;
  54958. AMBIENTINGRAYSCALE: boolean;
  54959. OPACITY: boolean;
  54960. VERTEXALPHA: boolean;
  54961. OPACITYDIRECTUV: number;
  54962. OPACITYRGB: boolean;
  54963. ALPHATEST: boolean;
  54964. DEPTHPREPASS: boolean;
  54965. ALPHABLEND: boolean;
  54966. ALPHAFROMALBEDO: boolean;
  54967. ALPHATESTVALUE: string;
  54968. SPECULAROVERALPHA: boolean;
  54969. RADIANCEOVERALPHA: boolean;
  54970. ALPHAFRESNEL: boolean;
  54971. LINEARALPHAFRESNEL: boolean;
  54972. PREMULTIPLYALPHA: boolean;
  54973. EMISSIVE: boolean;
  54974. EMISSIVEDIRECTUV: number;
  54975. REFLECTIVITY: boolean;
  54976. REFLECTIVITYDIRECTUV: number;
  54977. SPECULARTERM: boolean;
  54978. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  54979. MICROSURFACEAUTOMATIC: boolean;
  54980. LODBASEDMICROSFURACE: boolean;
  54981. MICROSURFACEMAP: boolean;
  54982. MICROSURFACEMAPDIRECTUV: number;
  54983. METALLICWORKFLOW: boolean;
  54984. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  54985. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  54986. METALLNESSSTOREINMETALMAPBLUE: boolean;
  54987. AOSTOREINMETALMAPRED: boolean;
  54988. METALLIC_REFLECTANCE: boolean;
  54989. METALLIC_REFLECTANCEDIRECTUV: number;
  54990. ENVIRONMENTBRDF: boolean;
  54991. ENVIRONMENTBRDF_RGBD: boolean;
  54992. NORMAL: boolean;
  54993. TANGENT: boolean;
  54994. BUMP: boolean;
  54995. BUMPDIRECTUV: number;
  54996. OBJECTSPACE_NORMALMAP: boolean;
  54997. PARALLAX: boolean;
  54998. PARALLAXOCCLUSION: boolean;
  54999. NORMALXYSCALE: boolean;
  55000. LIGHTMAP: boolean;
  55001. LIGHTMAPDIRECTUV: number;
  55002. USELIGHTMAPASSHADOWMAP: boolean;
  55003. GAMMALIGHTMAP: boolean;
  55004. RGBDLIGHTMAP: boolean;
  55005. REFLECTION: boolean;
  55006. REFLECTIONMAP_3D: boolean;
  55007. REFLECTIONMAP_SPHERICAL: boolean;
  55008. REFLECTIONMAP_PLANAR: boolean;
  55009. REFLECTIONMAP_CUBIC: boolean;
  55010. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  55011. REFLECTIONMAP_PROJECTION: boolean;
  55012. REFLECTIONMAP_SKYBOX: boolean;
  55013. REFLECTIONMAP_EXPLICIT: boolean;
  55014. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  55015. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  55016. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  55017. INVERTCUBICMAP: boolean;
  55018. USESPHERICALFROMREFLECTIONMAP: boolean;
  55019. USEIRRADIANCEMAP: boolean;
  55020. SPHERICAL_HARMONICS: boolean;
  55021. USESPHERICALINVERTEX: boolean;
  55022. REFLECTIONMAP_OPPOSITEZ: boolean;
  55023. LODINREFLECTIONALPHA: boolean;
  55024. GAMMAREFLECTION: boolean;
  55025. RGBDREFLECTION: boolean;
  55026. LINEARSPECULARREFLECTION: boolean;
  55027. RADIANCEOCCLUSION: boolean;
  55028. HORIZONOCCLUSION: boolean;
  55029. INSTANCES: boolean;
  55030. THIN_INSTANCES: boolean;
  55031. NUM_BONE_INFLUENCERS: number;
  55032. BonesPerMesh: number;
  55033. BONETEXTURE: boolean;
  55034. NONUNIFORMSCALING: boolean;
  55035. MORPHTARGETS: boolean;
  55036. MORPHTARGETS_NORMAL: boolean;
  55037. MORPHTARGETS_TANGENT: boolean;
  55038. MORPHTARGETS_UV: boolean;
  55039. NUM_MORPH_INFLUENCERS: number;
  55040. IMAGEPROCESSING: boolean;
  55041. VIGNETTE: boolean;
  55042. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55043. VIGNETTEBLENDMODEOPAQUE: boolean;
  55044. TONEMAPPING: boolean;
  55045. TONEMAPPING_ACES: boolean;
  55046. CONTRAST: boolean;
  55047. COLORCURVES: boolean;
  55048. COLORGRADING: boolean;
  55049. COLORGRADING3D: boolean;
  55050. SAMPLER3DGREENDEPTH: boolean;
  55051. SAMPLER3DBGRMAP: boolean;
  55052. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55053. EXPOSURE: boolean;
  55054. MULTIVIEW: boolean;
  55055. USEPHYSICALLIGHTFALLOFF: boolean;
  55056. USEGLTFLIGHTFALLOFF: boolean;
  55057. TWOSIDEDLIGHTING: boolean;
  55058. SHADOWFLOAT: boolean;
  55059. CLIPPLANE: boolean;
  55060. CLIPPLANE2: boolean;
  55061. CLIPPLANE3: boolean;
  55062. CLIPPLANE4: boolean;
  55063. CLIPPLANE5: boolean;
  55064. CLIPPLANE6: boolean;
  55065. POINTSIZE: boolean;
  55066. FOG: boolean;
  55067. LOGARITHMICDEPTH: boolean;
  55068. FORCENORMALFORWARD: boolean;
  55069. SPECULARAA: boolean;
  55070. CLEARCOAT: boolean;
  55071. CLEARCOAT_DEFAULTIOR: boolean;
  55072. CLEARCOAT_TEXTURE: boolean;
  55073. CLEARCOAT_TEXTUREDIRECTUV: number;
  55074. CLEARCOAT_BUMP: boolean;
  55075. CLEARCOAT_BUMPDIRECTUV: number;
  55076. CLEARCOAT_TINT: boolean;
  55077. CLEARCOAT_TINT_TEXTURE: boolean;
  55078. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  55079. ANISOTROPIC: boolean;
  55080. ANISOTROPIC_TEXTURE: boolean;
  55081. ANISOTROPIC_TEXTUREDIRECTUV: number;
  55082. BRDF_V_HEIGHT_CORRELATED: boolean;
  55083. MS_BRDF_ENERGY_CONSERVATION: boolean;
  55084. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  55085. SHEEN: boolean;
  55086. SHEEN_TEXTURE: boolean;
  55087. SHEEN_TEXTUREDIRECTUV: number;
  55088. SHEEN_LINKWITHALBEDO: boolean;
  55089. SHEEN_ROUGHNESS: boolean;
  55090. SHEEN_ALBEDOSCALING: boolean;
  55091. SUBSURFACE: boolean;
  55092. SS_REFRACTION: boolean;
  55093. SS_TRANSLUCENCY: boolean;
  55094. SS_SCATTERING: boolean;
  55095. SS_THICKNESSANDMASK_TEXTURE: boolean;
  55096. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  55097. SS_REFRACTIONMAP_3D: boolean;
  55098. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  55099. SS_LODINREFRACTIONALPHA: boolean;
  55100. SS_GAMMAREFRACTION: boolean;
  55101. SS_RGBDREFRACTION: boolean;
  55102. SS_LINEARSPECULARREFRACTION: boolean;
  55103. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  55104. SS_ALBEDOFORREFRACTIONTINT: boolean;
  55105. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  55106. UNLIT: boolean;
  55107. DEBUGMODE: number;
  55108. /**
  55109. * Initializes the PBR Material defines.
  55110. */
  55111. constructor();
  55112. /**
  55113. * Resets the PBR Material defines.
  55114. */
  55115. reset(): void;
  55116. }
  55117. /**
  55118. * The Physically based material base class of BJS.
  55119. *
  55120. * This offers the main features of a standard PBR material.
  55121. * For more information, please refer to the documentation :
  55122. * https://doc.babylonjs.com/how_to/physically_based_rendering
  55123. */
  55124. export abstract class PBRBaseMaterial extends PushMaterial {
  55125. /**
  55126. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  55127. */
  55128. static readonly PBRMATERIAL_OPAQUE: number;
  55129. /**
  55130. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  55131. */
  55132. static readonly PBRMATERIAL_ALPHATEST: number;
  55133. /**
  55134. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55135. */
  55136. static readonly PBRMATERIAL_ALPHABLEND: number;
  55137. /**
  55138. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55139. * They are also discarded below the alpha cutoff threshold to improve performances.
  55140. */
  55141. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  55142. /**
  55143. * Defines the default value of how much AO map is occluding the analytical lights
  55144. * (point spot...).
  55145. */
  55146. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  55147. /**
  55148. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  55149. */
  55150. static readonly LIGHTFALLOFF_PHYSICAL: number;
  55151. /**
  55152. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  55153. * to enhance interoperability with other engines.
  55154. */
  55155. static readonly LIGHTFALLOFF_GLTF: number;
  55156. /**
  55157. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  55158. * to enhance interoperability with other materials.
  55159. */
  55160. static readonly LIGHTFALLOFF_STANDARD: number;
  55161. /**
  55162. * Intensity of the direct lights e.g. the four lights available in your scene.
  55163. * This impacts both the direct diffuse and specular highlights.
  55164. */
  55165. protected _directIntensity: number;
  55166. /**
  55167. * Intensity of the emissive part of the material.
  55168. * This helps controlling the emissive effect without modifying the emissive color.
  55169. */
  55170. protected _emissiveIntensity: number;
  55171. /**
  55172. * Intensity of the environment e.g. how much the environment will light the object
  55173. * either through harmonics for rough material or through the refelction for shiny ones.
  55174. */
  55175. protected _environmentIntensity: number;
  55176. /**
  55177. * This is a special control allowing the reduction of the specular highlights coming from the
  55178. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55179. */
  55180. protected _specularIntensity: number;
  55181. /**
  55182. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  55183. */
  55184. private _lightingInfos;
  55185. /**
  55186. * Debug Control allowing disabling the bump map on this material.
  55187. */
  55188. protected _disableBumpMap: boolean;
  55189. /**
  55190. * AKA Diffuse Texture in standard nomenclature.
  55191. */
  55192. protected _albedoTexture: Nullable<BaseTexture>;
  55193. /**
  55194. * AKA Occlusion Texture in other nomenclature.
  55195. */
  55196. protected _ambientTexture: Nullable<BaseTexture>;
  55197. /**
  55198. * AKA Occlusion Texture Intensity in other nomenclature.
  55199. */
  55200. protected _ambientTextureStrength: number;
  55201. /**
  55202. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55203. * 1 means it completely occludes it
  55204. * 0 mean it has no impact
  55205. */
  55206. protected _ambientTextureImpactOnAnalyticalLights: number;
  55207. /**
  55208. * Stores the alpha values in a texture.
  55209. */
  55210. protected _opacityTexture: Nullable<BaseTexture>;
  55211. /**
  55212. * Stores the reflection values in a texture.
  55213. */
  55214. protected _reflectionTexture: Nullable<BaseTexture>;
  55215. /**
  55216. * Stores the emissive values in a texture.
  55217. */
  55218. protected _emissiveTexture: Nullable<BaseTexture>;
  55219. /**
  55220. * AKA Specular texture in other nomenclature.
  55221. */
  55222. protected _reflectivityTexture: Nullable<BaseTexture>;
  55223. /**
  55224. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55225. */
  55226. protected _metallicTexture: Nullable<BaseTexture>;
  55227. /**
  55228. * Specifies the metallic scalar of the metallic/roughness workflow.
  55229. * Can also be used to scale the metalness values of the metallic texture.
  55230. */
  55231. protected _metallic: Nullable<number>;
  55232. /**
  55233. * Specifies the roughness scalar of the metallic/roughness workflow.
  55234. * Can also be used to scale the roughness values of the metallic texture.
  55235. */
  55236. protected _roughness: Nullable<number>;
  55237. /**
  55238. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55239. * By default the indexOfrefraction is used to compute F0;
  55240. *
  55241. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55242. *
  55243. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55244. * F90 = metallicReflectanceColor;
  55245. */
  55246. protected _metallicF0Factor: number;
  55247. /**
  55248. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55249. * By default the F90 is always 1;
  55250. *
  55251. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55252. *
  55253. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55254. * F90 = metallicReflectanceColor;
  55255. */
  55256. protected _metallicReflectanceColor: Color3;
  55257. /**
  55258. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55259. * This is multiply against the scalar values defined in the material.
  55260. */
  55261. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  55262. /**
  55263. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55264. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55265. */
  55266. protected _microSurfaceTexture: Nullable<BaseTexture>;
  55267. /**
  55268. * Stores surface normal data used to displace a mesh in a texture.
  55269. */
  55270. protected _bumpTexture: Nullable<BaseTexture>;
  55271. /**
  55272. * Stores the pre-calculated light information of a mesh in a texture.
  55273. */
  55274. protected _lightmapTexture: Nullable<BaseTexture>;
  55275. /**
  55276. * The color of a material in ambient lighting.
  55277. */
  55278. protected _ambientColor: Color3;
  55279. /**
  55280. * AKA Diffuse Color in other nomenclature.
  55281. */
  55282. protected _albedoColor: Color3;
  55283. /**
  55284. * AKA Specular Color in other nomenclature.
  55285. */
  55286. protected _reflectivityColor: Color3;
  55287. /**
  55288. * The color applied when light is reflected from a material.
  55289. */
  55290. protected _reflectionColor: Color3;
  55291. /**
  55292. * The color applied when light is emitted from a material.
  55293. */
  55294. protected _emissiveColor: Color3;
  55295. /**
  55296. * AKA Glossiness in other nomenclature.
  55297. */
  55298. protected _microSurface: number;
  55299. /**
  55300. * Specifies that the material will use the light map as a show map.
  55301. */
  55302. protected _useLightmapAsShadowmap: boolean;
  55303. /**
  55304. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  55305. * makes the reflect vector face the model (under horizon).
  55306. */
  55307. protected _useHorizonOcclusion: boolean;
  55308. /**
  55309. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  55310. * too much the area relying on ambient texture to define their ambient occlusion.
  55311. */
  55312. protected _useRadianceOcclusion: boolean;
  55313. /**
  55314. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  55315. */
  55316. protected _useAlphaFromAlbedoTexture: boolean;
  55317. /**
  55318. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  55319. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  55320. */
  55321. protected _useSpecularOverAlpha: boolean;
  55322. /**
  55323. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  55324. */
  55325. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  55326. /**
  55327. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  55328. */
  55329. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  55330. /**
  55331. * Specifies if the metallic texture contains the roughness information in its green channel.
  55332. */
  55333. protected _useRoughnessFromMetallicTextureGreen: boolean;
  55334. /**
  55335. * Specifies if the metallic texture contains the metallness information in its blue channel.
  55336. */
  55337. protected _useMetallnessFromMetallicTextureBlue: boolean;
  55338. /**
  55339. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  55340. */
  55341. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  55342. /**
  55343. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  55344. */
  55345. protected _useAmbientInGrayScale: boolean;
  55346. /**
  55347. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  55348. * The material will try to infer what glossiness each pixel should be.
  55349. */
  55350. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  55351. /**
  55352. * Defines the falloff type used in this material.
  55353. * It by default is Physical.
  55354. */
  55355. protected _lightFalloff: number;
  55356. /**
  55357. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  55358. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  55359. */
  55360. protected _useRadianceOverAlpha: boolean;
  55361. /**
  55362. * Allows using an object space normal map (instead of tangent space).
  55363. */
  55364. protected _useObjectSpaceNormalMap: boolean;
  55365. /**
  55366. * Allows using the bump map in parallax mode.
  55367. */
  55368. protected _useParallax: boolean;
  55369. /**
  55370. * Allows using the bump map in parallax occlusion mode.
  55371. */
  55372. protected _useParallaxOcclusion: boolean;
  55373. /**
  55374. * Controls the scale bias of the parallax mode.
  55375. */
  55376. protected _parallaxScaleBias: number;
  55377. /**
  55378. * If sets to true, disables all the lights affecting the material.
  55379. */
  55380. protected _disableLighting: boolean;
  55381. /**
  55382. * Number of Simultaneous lights allowed on the material.
  55383. */
  55384. protected _maxSimultaneousLights: number;
  55385. /**
  55386. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  55387. */
  55388. protected _invertNormalMapX: boolean;
  55389. /**
  55390. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  55391. */
  55392. protected _invertNormalMapY: boolean;
  55393. /**
  55394. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55395. */
  55396. protected _twoSidedLighting: boolean;
  55397. /**
  55398. * Defines the alpha limits in alpha test mode.
  55399. */
  55400. protected _alphaCutOff: number;
  55401. /**
  55402. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  55403. */
  55404. protected _forceAlphaTest: boolean;
  55405. /**
  55406. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55407. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  55408. */
  55409. protected _useAlphaFresnel: boolean;
  55410. /**
  55411. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55412. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  55413. */
  55414. protected _useLinearAlphaFresnel: boolean;
  55415. /**
  55416. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  55417. * from cos thetav and roughness:
  55418. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  55419. */
  55420. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  55421. /**
  55422. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  55423. */
  55424. protected _forceIrradianceInFragment: boolean;
  55425. private _realTimeFiltering;
  55426. /**
  55427. * Enables realtime filtering on the texture.
  55428. */
  55429. get realTimeFiltering(): boolean;
  55430. set realTimeFiltering(b: boolean);
  55431. private _realTimeFilteringQuality;
  55432. /**
  55433. * Quality switch for realtime filtering
  55434. */
  55435. get realTimeFilteringQuality(): number;
  55436. set realTimeFilteringQuality(n: number);
  55437. /**
  55438. * Force normal to face away from face.
  55439. */
  55440. protected _forceNormalForward: boolean;
  55441. /**
  55442. * Enables specular anti aliasing in the PBR shader.
  55443. * It will both interacts on the Geometry for analytical and IBL lighting.
  55444. * It also prefilter the roughness map based on the bump values.
  55445. */
  55446. protected _enableSpecularAntiAliasing: boolean;
  55447. /**
  55448. * Default configuration related to image processing available in the PBR Material.
  55449. */
  55450. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55451. /**
  55452. * Keep track of the image processing observer to allow dispose and replace.
  55453. */
  55454. private _imageProcessingObserver;
  55455. /**
  55456. * Attaches a new image processing configuration to the PBR Material.
  55457. * @param configuration
  55458. */
  55459. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55460. /**
  55461. * Stores the available render targets.
  55462. */
  55463. private _renderTargets;
  55464. /**
  55465. * Sets the global ambient color for the material used in lighting calculations.
  55466. */
  55467. private _globalAmbientColor;
  55468. /**
  55469. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  55470. */
  55471. private _useLogarithmicDepth;
  55472. /**
  55473. * If set to true, no lighting calculations will be applied.
  55474. */
  55475. private _unlit;
  55476. private _debugMode;
  55477. /**
  55478. * @hidden
  55479. * This is reserved for the inspector.
  55480. * Defines the material debug mode.
  55481. * It helps seeing only some components of the material while troubleshooting.
  55482. */
  55483. debugMode: number;
  55484. /**
  55485. * @hidden
  55486. * This is reserved for the inspector.
  55487. * Specify from where on screen the debug mode should start.
  55488. * The value goes from -1 (full screen) to 1 (not visible)
  55489. * It helps with side by side comparison against the final render
  55490. * This defaults to -1
  55491. */
  55492. private debugLimit;
  55493. /**
  55494. * @hidden
  55495. * This is reserved for the inspector.
  55496. * As the default viewing range might not be enough (if the ambient is really small for instance)
  55497. * You can use the factor to better multiply the final value.
  55498. */
  55499. private debugFactor;
  55500. /**
  55501. * Defines the clear coat layer parameters for the material.
  55502. */
  55503. readonly clearCoat: PBRClearCoatConfiguration;
  55504. /**
  55505. * Defines the anisotropic parameters for the material.
  55506. */
  55507. readonly anisotropy: PBRAnisotropicConfiguration;
  55508. /**
  55509. * Defines the BRDF parameters for the material.
  55510. */
  55511. readonly brdf: PBRBRDFConfiguration;
  55512. /**
  55513. * Defines the Sheen parameters for the material.
  55514. */
  55515. readonly sheen: PBRSheenConfiguration;
  55516. /**
  55517. * Defines the SubSurface parameters for the material.
  55518. */
  55519. readonly subSurface: PBRSubSurfaceConfiguration;
  55520. /**
  55521. * Defines the detail map parameters for the material.
  55522. */
  55523. readonly detailMap: DetailMapConfiguration;
  55524. protected _rebuildInParallel: boolean;
  55525. /**
  55526. * Instantiates a new PBRMaterial instance.
  55527. *
  55528. * @param name The material name
  55529. * @param scene The scene the material will be use in.
  55530. */
  55531. constructor(name: string, scene: Scene);
  55532. /**
  55533. * Gets a boolean indicating that current material needs to register RTT
  55534. */
  55535. get hasRenderTargetTextures(): boolean;
  55536. /**
  55537. * Gets the name of the material class.
  55538. */
  55539. getClassName(): string;
  55540. /**
  55541. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55542. */
  55543. get useLogarithmicDepth(): boolean;
  55544. /**
  55545. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55546. */
  55547. set useLogarithmicDepth(value: boolean);
  55548. /**
  55549. * Returns true if alpha blending should be disabled.
  55550. */
  55551. protected get _disableAlphaBlending(): boolean;
  55552. /**
  55553. * Specifies whether or not this material should be rendered in alpha blend mode.
  55554. */
  55555. needAlphaBlending(): boolean;
  55556. /**
  55557. * Specifies whether or not this material should be rendered in alpha test mode.
  55558. */
  55559. needAlphaTesting(): boolean;
  55560. /**
  55561. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  55562. */
  55563. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  55564. /**
  55565. * Gets the texture used for the alpha test.
  55566. */
  55567. getAlphaTestTexture(): Nullable<BaseTexture>;
  55568. /**
  55569. * Specifies that the submesh is ready to be used.
  55570. * @param mesh - BJS mesh.
  55571. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  55572. * @param useInstances - Specifies that instances should be used.
  55573. * @returns - boolean indicating that the submesh is ready or not.
  55574. */
  55575. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55576. /**
  55577. * Specifies if the material uses metallic roughness workflow.
  55578. * @returns boolean specifiying if the material uses metallic roughness workflow.
  55579. */
  55580. isMetallicWorkflow(): boolean;
  55581. private _prepareEffect;
  55582. private _prepareDefines;
  55583. /**
  55584. * Force shader compilation
  55585. */
  55586. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  55587. /**
  55588. * Initializes the uniform buffer layout for the shader.
  55589. */
  55590. buildUniformLayout(): void;
  55591. /**
  55592. * Unbinds the material from the mesh
  55593. */
  55594. unbind(): void;
  55595. /**
  55596. * Binds the submesh data.
  55597. * @param world - The world matrix.
  55598. * @param mesh - The BJS mesh.
  55599. * @param subMesh - A submesh of the BJS mesh.
  55600. */
  55601. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55602. /**
  55603. * Returns the animatable textures.
  55604. * @returns - Array of animatable textures.
  55605. */
  55606. getAnimatables(): IAnimatable[];
  55607. /**
  55608. * Returns the texture used for reflections.
  55609. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  55610. */
  55611. private _getReflectionTexture;
  55612. /**
  55613. * Returns an array of the actively used textures.
  55614. * @returns - Array of BaseTextures
  55615. */
  55616. getActiveTextures(): BaseTexture[];
  55617. /**
  55618. * Checks to see if a texture is used in the material.
  55619. * @param texture - Base texture to use.
  55620. * @returns - Boolean specifying if a texture is used in the material.
  55621. */
  55622. hasTexture(texture: BaseTexture): boolean;
  55623. /**
  55624. * Disposes the resources of the material.
  55625. * @param forceDisposeEffect - Forces the disposal of effects.
  55626. * @param forceDisposeTextures - Forces the disposal of all textures.
  55627. */
  55628. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  55629. }
  55630. }
  55631. declare module BABYLON {
  55632. /**
  55633. * The Physically based material of BJS.
  55634. *
  55635. * This offers the main features of a standard PBR material.
  55636. * For more information, please refer to the documentation :
  55637. * https://doc.babylonjs.com/how_to/physically_based_rendering
  55638. */
  55639. export class PBRMaterial extends PBRBaseMaterial {
  55640. /**
  55641. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  55642. */
  55643. static readonly PBRMATERIAL_OPAQUE: number;
  55644. /**
  55645. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  55646. */
  55647. static readonly PBRMATERIAL_ALPHATEST: number;
  55648. /**
  55649. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55650. */
  55651. static readonly PBRMATERIAL_ALPHABLEND: number;
  55652. /**
  55653. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55654. * They are also discarded below the alpha cutoff threshold to improve performances.
  55655. */
  55656. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  55657. /**
  55658. * Defines the default value of how much AO map is occluding the analytical lights
  55659. * (point spot...).
  55660. */
  55661. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  55662. /**
  55663. * Intensity of the direct lights e.g. the four lights available in your scene.
  55664. * This impacts both the direct diffuse and specular highlights.
  55665. */
  55666. directIntensity: number;
  55667. /**
  55668. * Intensity of the emissive part of the material.
  55669. * This helps controlling the emissive effect without modifying the emissive color.
  55670. */
  55671. emissiveIntensity: number;
  55672. /**
  55673. * Intensity of the environment e.g. how much the environment will light the object
  55674. * either through harmonics for rough material or through the refelction for shiny ones.
  55675. */
  55676. environmentIntensity: number;
  55677. /**
  55678. * This is a special control allowing the reduction of the specular highlights coming from the
  55679. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55680. */
  55681. specularIntensity: number;
  55682. /**
  55683. * Debug Control allowing disabling the bump map on this material.
  55684. */
  55685. disableBumpMap: boolean;
  55686. /**
  55687. * AKA Diffuse Texture in standard nomenclature.
  55688. */
  55689. albedoTexture: BaseTexture;
  55690. /**
  55691. * AKA Occlusion Texture in other nomenclature.
  55692. */
  55693. ambientTexture: BaseTexture;
  55694. /**
  55695. * AKA Occlusion Texture Intensity in other nomenclature.
  55696. */
  55697. ambientTextureStrength: number;
  55698. /**
  55699. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55700. * 1 means it completely occludes it
  55701. * 0 mean it has no impact
  55702. */
  55703. ambientTextureImpactOnAnalyticalLights: number;
  55704. /**
  55705. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  55706. */
  55707. opacityTexture: BaseTexture;
  55708. /**
  55709. * Stores the reflection values in a texture.
  55710. */
  55711. reflectionTexture: Nullable<BaseTexture>;
  55712. /**
  55713. * Stores the emissive values in a texture.
  55714. */
  55715. emissiveTexture: BaseTexture;
  55716. /**
  55717. * AKA Specular texture in other nomenclature.
  55718. */
  55719. reflectivityTexture: BaseTexture;
  55720. /**
  55721. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55722. */
  55723. metallicTexture: BaseTexture;
  55724. /**
  55725. * Specifies the metallic scalar of the metallic/roughness workflow.
  55726. * Can also be used to scale the metalness values of the metallic texture.
  55727. */
  55728. metallic: Nullable<number>;
  55729. /**
  55730. * Specifies the roughness scalar of the metallic/roughness workflow.
  55731. * Can also be used to scale the roughness values of the metallic texture.
  55732. */
  55733. roughness: Nullable<number>;
  55734. /**
  55735. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55736. * By default the indexOfrefraction is used to compute F0;
  55737. *
  55738. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55739. *
  55740. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55741. * F90 = metallicReflectanceColor;
  55742. */
  55743. metallicF0Factor: number;
  55744. /**
  55745. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55746. * By default the F90 is always 1;
  55747. *
  55748. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55749. *
  55750. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55751. * F90 = metallicReflectanceColor;
  55752. */
  55753. metallicReflectanceColor: Color3;
  55754. /**
  55755. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55756. * This is multiply against the scalar values defined in the material.
  55757. */
  55758. metallicReflectanceTexture: Nullable<BaseTexture>;
  55759. /**
  55760. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55761. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55762. */
  55763. microSurfaceTexture: BaseTexture;
  55764. /**
  55765. * Stores surface normal data used to displace a mesh in a texture.
  55766. */
  55767. bumpTexture: BaseTexture;
  55768. /**
  55769. * Stores the pre-calculated light information of a mesh in a texture.
  55770. */
  55771. lightmapTexture: BaseTexture;
  55772. /**
  55773. * Stores the refracted light information in a texture.
  55774. */
  55775. get refractionTexture(): Nullable<BaseTexture>;
  55776. set refractionTexture(value: Nullable<BaseTexture>);
  55777. /**
  55778. * The color of a material in ambient lighting.
  55779. */
  55780. ambientColor: Color3;
  55781. /**
  55782. * AKA Diffuse Color in other nomenclature.
  55783. */
  55784. albedoColor: Color3;
  55785. /**
  55786. * AKA Specular Color in other nomenclature.
  55787. */
  55788. reflectivityColor: Color3;
  55789. /**
  55790. * The color reflected from the material.
  55791. */
  55792. reflectionColor: Color3;
  55793. /**
  55794. * The color emitted from the material.
  55795. */
  55796. emissiveColor: Color3;
  55797. /**
  55798. * AKA Glossiness in other nomenclature.
  55799. */
  55800. microSurface: number;
  55801. /**
  55802. * Index of refraction of the material base layer.
  55803. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55804. *
  55805. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  55806. *
  55807. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  55808. */
  55809. get indexOfRefraction(): number;
  55810. set indexOfRefraction(value: number);
  55811. /**
  55812. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55813. */
  55814. get invertRefractionY(): boolean;
  55815. set invertRefractionY(value: boolean);
  55816. /**
  55817. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  55818. * Materials half opaque for instance using refraction could benefit from this control.
  55819. */
  55820. get linkRefractionWithTransparency(): boolean;
  55821. set linkRefractionWithTransparency(value: boolean);
  55822. /**
  55823. * If true, the light map contains occlusion information instead of lighting info.
  55824. */
  55825. useLightmapAsShadowmap: boolean;
  55826. /**
  55827. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  55828. */
  55829. useAlphaFromAlbedoTexture: boolean;
  55830. /**
  55831. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  55832. */
  55833. forceAlphaTest: boolean;
  55834. /**
  55835. * Defines the alpha limits in alpha test mode.
  55836. */
  55837. alphaCutOff: number;
  55838. /**
  55839. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  55840. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  55841. */
  55842. useSpecularOverAlpha: boolean;
  55843. /**
  55844. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  55845. */
  55846. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  55847. /**
  55848. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  55849. */
  55850. useRoughnessFromMetallicTextureAlpha: boolean;
  55851. /**
  55852. * Specifies if the metallic texture contains the roughness information in its green channel.
  55853. */
  55854. useRoughnessFromMetallicTextureGreen: boolean;
  55855. /**
  55856. * Specifies if the metallic texture contains the metallness information in its blue channel.
  55857. */
  55858. useMetallnessFromMetallicTextureBlue: boolean;
  55859. /**
  55860. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  55861. */
  55862. useAmbientOcclusionFromMetallicTextureRed: boolean;
  55863. /**
  55864. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  55865. */
  55866. useAmbientInGrayScale: boolean;
  55867. /**
  55868. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  55869. * The material will try to infer what glossiness each pixel should be.
  55870. */
  55871. useAutoMicroSurfaceFromReflectivityMap: boolean;
  55872. /**
  55873. * BJS is using an harcoded light falloff based on a manually sets up range.
  55874. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  55875. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  55876. */
  55877. get usePhysicalLightFalloff(): boolean;
  55878. /**
  55879. * BJS is using an harcoded light falloff based on a manually sets up range.
  55880. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  55881. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  55882. */
  55883. set usePhysicalLightFalloff(value: boolean);
  55884. /**
  55885. * In order to support the falloff compatibility with gltf, a special mode has been added
  55886. * to reproduce the gltf light falloff.
  55887. */
  55888. get useGLTFLightFalloff(): boolean;
  55889. /**
  55890. * In order to support the falloff compatibility with gltf, a special mode has been added
  55891. * to reproduce the gltf light falloff.
  55892. */
  55893. set useGLTFLightFalloff(value: boolean);
  55894. /**
  55895. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  55896. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  55897. */
  55898. useRadianceOverAlpha: boolean;
  55899. /**
  55900. * Allows using an object space normal map (instead of tangent space).
  55901. */
  55902. useObjectSpaceNormalMap: boolean;
  55903. /**
  55904. * Allows using the bump map in parallax mode.
  55905. */
  55906. useParallax: boolean;
  55907. /**
  55908. * Allows using the bump map in parallax occlusion mode.
  55909. */
  55910. useParallaxOcclusion: boolean;
  55911. /**
  55912. * Controls the scale bias of the parallax mode.
  55913. */
  55914. parallaxScaleBias: number;
  55915. /**
  55916. * If sets to true, disables all the lights affecting the material.
  55917. */
  55918. disableLighting: boolean;
  55919. /**
  55920. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  55921. */
  55922. forceIrradianceInFragment: boolean;
  55923. /**
  55924. * Number of Simultaneous lights allowed on the material.
  55925. */
  55926. maxSimultaneousLights: number;
  55927. /**
  55928. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55929. */
  55930. invertNormalMapX: boolean;
  55931. /**
  55932. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55933. */
  55934. invertNormalMapY: boolean;
  55935. /**
  55936. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55937. */
  55938. twoSidedLighting: boolean;
  55939. /**
  55940. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55941. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  55942. */
  55943. useAlphaFresnel: boolean;
  55944. /**
  55945. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55946. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  55947. */
  55948. useLinearAlphaFresnel: boolean;
  55949. /**
  55950. * Let user defines the brdf lookup texture used for IBL.
  55951. * A default 8bit version is embedded but you could point at :
  55952. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  55953. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  55954. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  55955. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  55956. */
  55957. environmentBRDFTexture: Nullable<BaseTexture>;
  55958. /**
  55959. * Force normal to face away from face.
  55960. */
  55961. forceNormalForward: boolean;
  55962. /**
  55963. * Enables specular anti aliasing in the PBR shader.
  55964. * It will both interacts on the Geometry for analytical and IBL lighting.
  55965. * It also prefilter the roughness map based on the bump values.
  55966. */
  55967. enableSpecularAntiAliasing: boolean;
  55968. /**
  55969. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  55970. * makes the reflect vector face the model (under horizon).
  55971. */
  55972. useHorizonOcclusion: boolean;
  55973. /**
  55974. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  55975. * too much the area relying on ambient texture to define their ambient occlusion.
  55976. */
  55977. useRadianceOcclusion: boolean;
  55978. /**
  55979. * If set to true, no lighting calculations will be applied.
  55980. */
  55981. unlit: boolean;
  55982. /**
  55983. * Gets the image processing configuration used either in this material.
  55984. */
  55985. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  55986. /**
  55987. * Sets the Default image processing configuration used either in the this material.
  55988. *
  55989. * If sets to null, the scene one is in use.
  55990. */
  55991. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  55992. /**
  55993. * Gets wether the color curves effect is enabled.
  55994. */
  55995. get cameraColorCurvesEnabled(): boolean;
  55996. /**
  55997. * Sets wether the color curves effect is enabled.
  55998. */
  55999. set cameraColorCurvesEnabled(value: boolean);
  56000. /**
  56001. * Gets wether the color grading effect is enabled.
  56002. */
  56003. get cameraColorGradingEnabled(): boolean;
  56004. /**
  56005. * Gets wether the color grading effect is enabled.
  56006. */
  56007. set cameraColorGradingEnabled(value: boolean);
  56008. /**
  56009. * Gets wether tonemapping is enabled or not.
  56010. */
  56011. get cameraToneMappingEnabled(): boolean;
  56012. /**
  56013. * Sets wether tonemapping is enabled or not
  56014. */
  56015. set cameraToneMappingEnabled(value: boolean);
  56016. /**
  56017. * The camera exposure used on this material.
  56018. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56019. * This corresponds to a photographic exposure.
  56020. */
  56021. get cameraExposure(): number;
  56022. /**
  56023. * The camera exposure used on this material.
  56024. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56025. * This corresponds to a photographic exposure.
  56026. */
  56027. set cameraExposure(value: number);
  56028. /**
  56029. * Gets The camera contrast used on this material.
  56030. */
  56031. get cameraContrast(): number;
  56032. /**
  56033. * Sets The camera contrast used on this material.
  56034. */
  56035. set cameraContrast(value: number);
  56036. /**
  56037. * Gets the Color Grading 2D Lookup Texture.
  56038. */
  56039. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  56040. /**
  56041. * Sets the Color Grading 2D Lookup Texture.
  56042. */
  56043. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  56044. /**
  56045. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56046. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56047. * 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;
  56048. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56049. */
  56050. get cameraColorCurves(): Nullable<ColorCurves>;
  56051. /**
  56052. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56053. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56054. * 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;
  56055. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56056. */
  56057. set cameraColorCurves(value: Nullable<ColorCurves>);
  56058. /**
  56059. * Instantiates a new PBRMaterial instance.
  56060. *
  56061. * @param name The material name
  56062. * @param scene The scene the material will be use in.
  56063. */
  56064. constructor(name: string, scene: Scene);
  56065. /**
  56066. * Returns the name of this material class.
  56067. */
  56068. getClassName(): string;
  56069. /**
  56070. * Makes a duplicate of the current material.
  56071. * @param name - name to use for the new material.
  56072. */
  56073. clone(name: string): PBRMaterial;
  56074. /**
  56075. * Serializes this PBR Material.
  56076. * @returns - An object with the serialized material.
  56077. */
  56078. serialize(): any;
  56079. /**
  56080. * Parses a PBR Material from a serialized object.
  56081. * @param source - Serialized object.
  56082. * @param scene - BJS scene instance.
  56083. * @param rootUrl - url for the scene object
  56084. * @returns - PBRMaterial
  56085. */
  56086. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  56087. }
  56088. }
  56089. declare module BABYLON {
  56090. /**
  56091. * Direct draw surface info
  56092. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  56093. */
  56094. export interface DDSInfo {
  56095. /**
  56096. * Width of the texture
  56097. */
  56098. width: number;
  56099. /**
  56100. * Width of the texture
  56101. */
  56102. height: number;
  56103. /**
  56104. * Number of Mipmaps for the texture
  56105. * @see https://en.wikipedia.org/wiki/Mipmap
  56106. */
  56107. mipmapCount: number;
  56108. /**
  56109. * If the textures format is a known fourCC format
  56110. * @see https://www.fourcc.org/
  56111. */
  56112. isFourCC: boolean;
  56113. /**
  56114. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  56115. */
  56116. isRGB: boolean;
  56117. /**
  56118. * If the texture is a lumincance format
  56119. */
  56120. isLuminance: boolean;
  56121. /**
  56122. * If this is a cube texture
  56123. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  56124. */
  56125. isCube: boolean;
  56126. /**
  56127. * If the texture is a compressed format eg. FOURCC_DXT1
  56128. */
  56129. isCompressed: boolean;
  56130. /**
  56131. * The dxgiFormat of the texture
  56132. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  56133. */
  56134. dxgiFormat: number;
  56135. /**
  56136. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  56137. */
  56138. textureType: number;
  56139. /**
  56140. * Sphericle polynomial created for the dds texture
  56141. */
  56142. sphericalPolynomial?: SphericalPolynomial;
  56143. }
  56144. /**
  56145. * Class used to provide DDS decompression tools
  56146. */
  56147. export class DDSTools {
  56148. /**
  56149. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  56150. */
  56151. static StoreLODInAlphaChannel: boolean;
  56152. /**
  56153. * Gets DDS information from an array buffer
  56154. * @param data defines the array buffer view to read data from
  56155. * @returns the DDS information
  56156. */
  56157. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  56158. private static _FloatView;
  56159. private static _Int32View;
  56160. private static _ToHalfFloat;
  56161. private static _FromHalfFloat;
  56162. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  56163. private static _GetHalfFloatRGBAArrayBuffer;
  56164. private static _GetFloatRGBAArrayBuffer;
  56165. private static _GetFloatAsUIntRGBAArrayBuffer;
  56166. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  56167. private static _GetRGBAArrayBuffer;
  56168. private static _ExtractLongWordOrder;
  56169. private static _GetRGBArrayBuffer;
  56170. private static _GetLuminanceArrayBuffer;
  56171. /**
  56172. * Uploads DDS Levels to a Babylon Texture
  56173. * @hidden
  56174. */
  56175. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  56176. }
  56177. interface ThinEngine {
  56178. /**
  56179. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  56180. * @param rootUrl defines the url where the file to load is located
  56181. * @param scene defines the current scene
  56182. * @param lodScale defines scale to apply to the mip map selection
  56183. * @param lodOffset defines offset to apply to the mip map selection
  56184. * @param onLoad defines an optional callback raised when the texture is loaded
  56185. * @param onError defines an optional callback raised if there is an issue to load the texture
  56186. * @param format defines the format of the data
  56187. * @param forcedExtension defines the extension to use to pick the right loader
  56188. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  56189. * @returns the cube texture as an InternalTexture
  56190. */
  56191. 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;
  56192. }
  56193. }
  56194. declare module BABYLON {
  56195. /**
  56196. * Implementation of the DDS Texture Loader.
  56197. * @hidden
  56198. */
  56199. export class _DDSTextureLoader implements IInternalTextureLoader {
  56200. /**
  56201. * Defines wether the loader supports cascade loading the different faces.
  56202. */
  56203. readonly supportCascades: boolean;
  56204. /**
  56205. * This returns if the loader support the current file information.
  56206. * @param extension defines the file extension of the file being loaded
  56207. * @returns true if the loader can load the specified file
  56208. */
  56209. canLoad(extension: string): boolean;
  56210. /**
  56211. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56212. * @param data contains the texture data
  56213. * @param texture defines the BabylonJS internal texture
  56214. * @param createPolynomials will be true if polynomials have been requested
  56215. * @param onLoad defines the callback to trigger once the texture is ready
  56216. * @param onError defines the callback to trigger in case of error
  56217. */
  56218. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56219. /**
  56220. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56221. * @param data contains the texture data
  56222. * @param texture defines the BabylonJS internal texture
  56223. * @param callback defines the method to call once ready to upload
  56224. */
  56225. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56226. }
  56227. }
  56228. declare module BABYLON {
  56229. /**
  56230. * Implementation of the ENV Texture Loader.
  56231. * @hidden
  56232. */
  56233. export class _ENVTextureLoader implements IInternalTextureLoader {
  56234. /**
  56235. * Defines wether the loader supports cascade loading the different faces.
  56236. */
  56237. readonly supportCascades: boolean;
  56238. /**
  56239. * This returns if the loader support the current file information.
  56240. * @param extension defines the file extension of the file being loaded
  56241. * @returns true if the loader can load the specified file
  56242. */
  56243. canLoad(extension: string): boolean;
  56244. /**
  56245. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56246. * @param data contains the texture data
  56247. * @param texture defines the BabylonJS internal texture
  56248. * @param createPolynomials will be true if polynomials have been requested
  56249. * @param onLoad defines the callback to trigger once the texture is ready
  56250. * @param onError defines the callback to trigger in case of error
  56251. */
  56252. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56253. /**
  56254. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56255. * @param data contains the texture data
  56256. * @param texture defines the BabylonJS internal texture
  56257. * @param callback defines the method to call once ready to upload
  56258. */
  56259. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56260. }
  56261. }
  56262. declare module BABYLON {
  56263. /**
  56264. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  56265. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  56266. */
  56267. export class KhronosTextureContainer {
  56268. /** contents of the KTX container file */
  56269. data: ArrayBufferView;
  56270. private static HEADER_LEN;
  56271. private static COMPRESSED_2D;
  56272. private static COMPRESSED_3D;
  56273. private static TEX_2D;
  56274. private static TEX_3D;
  56275. /**
  56276. * Gets the openGL type
  56277. */
  56278. glType: number;
  56279. /**
  56280. * Gets the openGL type size
  56281. */
  56282. glTypeSize: number;
  56283. /**
  56284. * Gets the openGL format
  56285. */
  56286. glFormat: number;
  56287. /**
  56288. * Gets the openGL internal format
  56289. */
  56290. glInternalFormat: number;
  56291. /**
  56292. * Gets the base internal format
  56293. */
  56294. glBaseInternalFormat: number;
  56295. /**
  56296. * Gets image width in pixel
  56297. */
  56298. pixelWidth: number;
  56299. /**
  56300. * Gets image height in pixel
  56301. */
  56302. pixelHeight: number;
  56303. /**
  56304. * Gets image depth in pixels
  56305. */
  56306. pixelDepth: number;
  56307. /**
  56308. * Gets the number of array elements
  56309. */
  56310. numberOfArrayElements: number;
  56311. /**
  56312. * Gets the number of faces
  56313. */
  56314. numberOfFaces: number;
  56315. /**
  56316. * Gets the number of mipmap levels
  56317. */
  56318. numberOfMipmapLevels: number;
  56319. /**
  56320. * Gets the bytes of key value data
  56321. */
  56322. bytesOfKeyValueData: number;
  56323. /**
  56324. * Gets the load type
  56325. */
  56326. loadType: number;
  56327. /**
  56328. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  56329. */
  56330. isInvalid: boolean;
  56331. /**
  56332. * Creates a new KhronosTextureContainer
  56333. * @param data contents of the KTX container file
  56334. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  56335. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  56336. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  56337. */
  56338. constructor(
  56339. /** contents of the KTX container file */
  56340. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  56341. /**
  56342. * Uploads KTX content to a Babylon Texture.
  56343. * It is assumed that the texture has already been created & is currently bound
  56344. * @hidden
  56345. */
  56346. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  56347. private _upload2DCompressedLevels;
  56348. /**
  56349. * Checks if the given data starts with a KTX file identifier.
  56350. * @param data the data to check
  56351. * @returns true if the data is a KTX file or false otherwise
  56352. */
  56353. static IsValid(data: ArrayBufferView): boolean;
  56354. }
  56355. }
  56356. declare module BABYLON {
  56357. /**
  56358. * Class for loading KTX2 files
  56359. * !!! Experimental Extension Subject to Changes !!!
  56360. * @hidden
  56361. */
  56362. export class KhronosTextureContainer2 {
  56363. private static _ModulePromise;
  56364. private static _TranscodeFormat;
  56365. constructor(engine: ThinEngine);
  56366. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  56367. private _determineTranscodeFormat;
  56368. /**
  56369. * Checks if the given data starts with a KTX2 file identifier.
  56370. * @param data the data to check
  56371. * @returns true if the data is a KTX2 file or false otherwise
  56372. */
  56373. static IsValid(data: ArrayBufferView): boolean;
  56374. }
  56375. }
  56376. declare module BABYLON {
  56377. /**
  56378. * Implementation of the KTX Texture Loader.
  56379. * @hidden
  56380. */
  56381. export class _KTXTextureLoader implements IInternalTextureLoader {
  56382. /**
  56383. * Defines wether the loader supports cascade loading the different faces.
  56384. */
  56385. readonly supportCascades: boolean;
  56386. /**
  56387. * This returns if the loader support the current file information.
  56388. * @param extension defines the file extension of the file being loaded
  56389. * @returns true if the loader can load the specified file
  56390. */
  56391. canLoad(extension: string): boolean;
  56392. /**
  56393. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56394. * @param data contains the texture data
  56395. * @param texture defines the BabylonJS internal texture
  56396. * @param createPolynomials will be true if polynomials have been requested
  56397. * @param onLoad defines the callback to trigger once the texture is ready
  56398. * @param onError defines the callback to trigger in case of error
  56399. */
  56400. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56401. /**
  56402. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56403. * @param data contains the texture data
  56404. * @param texture defines the BabylonJS internal texture
  56405. * @param callback defines the method to call once ready to upload
  56406. */
  56407. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  56408. }
  56409. }
  56410. declare module BABYLON {
  56411. /** @hidden */
  56412. export var _forceSceneHelpersToBundle: boolean;
  56413. interface Scene {
  56414. /**
  56415. * Creates a default light for the scene.
  56416. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  56417. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  56418. */
  56419. createDefaultLight(replace?: boolean): void;
  56420. /**
  56421. * Creates a default camera for the scene.
  56422. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  56423. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  56424. * @param replace has default false, when true replaces the active camera in the scene
  56425. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  56426. */
  56427. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  56428. /**
  56429. * Creates a default camera and a default light.
  56430. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  56431. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  56432. * @param replace has the default false, when true replaces the active camera/light in the scene
  56433. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  56434. */
  56435. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  56436. /**
  56437. * Creates a new sky box
  56438. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  56439. * @param environmentTexture defines the texture to use as environment texture
  56440. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  56441. * @param scale defines the overall scale of the skybox
  56442. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  56443. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  56444. * @returns a new mesh holding the sky box
  56445. */
  56446. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  56447. /**
  56448. * Creates a new environment
  56449. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  56450. * @param options defines the options you can use to configure the environment
  56451. * @returns the new EnvironmentHelper
  56452. */
  56453. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  56454. /**
  56455. * Creates a new VREXperienceHelper
  56456. * @see http://doc.babylonjs.com/how_to/webvr_helper
  56457. * @param webVROptions defines the options used to create the new VREXperienceHelper
  56458. * @returns a new VREXperienceHelper
  56459. */
  56460. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  56461. /**
  56462. * Creates a new WebXRDefaultExperience
  56463. * @see http://doc.babylonjs.com/how_to/webxr
  56464. * @param options experience options
  56465. * @returns a promise for a new WebXRDefaultExperience
  56466. */
  56467. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  56468. }
  56469. }
  56470. declare module BABYLON {
  56471. /**
  56472. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  56473. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  56474. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  56475. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  56476. */
  56477. export class VideoDome extends TransformNode {
  56478. /**
  56479. * Define the video source as a Monoscopic panoramic 360 video.
  56480. */
  56481. static readonly MODE_MONOSCOPIC: number;
  56482. /**
  56483. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  56484. */
  56485. static readonly MODE_TOPBOTTOM: number;
  56486. /**
  56487. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  56488. */
  56489. static readonly MODE_SIDEBYSIDE: number;
  56490. private _halfDome;
  56491. private _useDirectMapping;
  56492. /**
  56493. * The video texture being displayed on the sphere
  56494. */
  56495. protected _videoTexture: VideoTexture;
  56496. /**
  56497. * Gets the video texture being displayed on the sphere
  56498. */
  56499. get videoTexture(): VideoTexture;
  56500. /**
  56501. * The skybox material
  56502. */
  56503. protected _material: BackgroundMaterial;
  56504. /**
  56505. * The surface used for the skybox
  56506. */
  56507. protected _mesh: Mesh;
  56508. /**
  56509. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  56510. */
  56511. private _halfDomeMask;
  56512. /**
  56513. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56514. * Also see the options.resolution property.
  56515. */
  56516. get fovMultiplier(): number;
  56517. set fovMultiplier(value: number);
  56518. private _videoMode;
  56519. /**
  56520. * Gets or set the current video mode for the video. It can be:
  56521. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  56522. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  56523. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  56524. */
  56525. get videoMode(): number;
  56526. set videoMode(value: number);
  56527. /**
  56528. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  56529. *
  56530. */
  56531. get halfDome(): boolean;
  56532. /**
  56533. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  56534. */
  56535. set halfDome(enabled: boolean);
  56536. /**
  56537. * Oberserver used in Stereoscopic VR Mode.
  56538. */
  56539. private _onBeforeCameraRenderObserver;
  56540. /**
  56541. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  56542. * @param name Element's name, child elements will append suffixes for their own names.
  56543. * @param urlsOrVideo defines the url(s) or the video element to use
  56544. * @param options An object containing optional or exposed sub element properties
  56545. */
  56546. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  56547. resolution?: number;
  56548. clickToPlay?: boolean;
  56549. autoPlay?: boolean;
  56550. loop?: boolean;
  56551. size?: number;
  56552. poster?: string;
  56553. faceForward?: boolean;
  56554. useDirectMapping?: boolean;
  56555. halfDomeMode?: boolean;
  56556. }, scene: Scene);
  56557. private _changeVideoMode;
  56558. /**
  56559. * Releases resources associated with this node.
  56560. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  56561. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  56562. */
  56563. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  56564. }
  56565. }
  56566. declare module BABYLON {
  56567. /**
  56568. * This class can be used to get instrumentation data from a Babylon engine
  56569. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56570. */
  56571. export class EngineInstrumentation implements IDisposable {
  56572. /**
  56573. * Define the instrumented engine.
  56574. */
  56575. engine: Engine;
  56576. private _captureGPUFrameTime;
  56577. private _gpuFrameTimeToken;
  56578. private _gpuFrameTime;
  56579. private _captureShaderCompilationTime;
  56580. private _shaderCompilationTime;
  56581. private _onBeginFrameObserver;
  56582. private _onEndFrameObserver;
  56583. private _onBeforeShaderCompilationObserver;
  56584. private _onAfterShaderCompilationObserver;
  56585. /**
  56586. * Gets the perf counter used for GPU frame time
  56587. */
  56588. get gpuFrameTimeCounter(): PerfCounter;
  56589. /**
  56590. * Gets the GPU frame time capture status
  56591. */
  56592. get captureGPUFrameTime(): boolean;
  56593. /**
  56594. * Enable or disable the GPU frame time capture
  56595. */
  56596. set captureGPUFrameTime(value: boolean);
  56597. /**
  56598. * Gets the perf counter used for shader compilation time
  56599. */
  56600. get shaderCompilationTimeCounter(): PerfCounter;
  56601. /**
  56602. * Gets the shader compilation time capture status
  56603. */
  56604. get captureShaderCompilationTime(): boolean;
  56605. /**
  56606. * Enable or disable the shader compilation time capture
  56607. */
  56608. set captureShaderCompilationTime(value: boolean);
  56609. /**
  56610. * Instantiates a new engine instrumentation.
  56611. * This class can be used to get instrumentation data from a Babylon engine
  56612. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56613. * @param engine Defines the engine to instrument
  56614. */
  56615. constructor(
  56616. /**
  56617. * Define the instrumented engine.
  56618. */
  56619. engine: Engine);
  56620. /**
  56621. * Dispose and release associated resources.
  56622. */
  56623. dispose(): void;
  56624. }
  56625. }
  56626. declare module BABYLON {
  56627. /**
  56628. * This class can be used to get instrumentation data from a Babylon engine
  56629. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56630. */
  56631. export class SceneInstrumentation implements IDisposable {
  56632. /**
  56633. * Defines the scene to instrument
  56634. */
  56635. scene: Scene;
  56636. private _captureActiveMeshesEvaluationTime;
  56637. private _activeMeshesEvaluationTime;
  56638. private _captureRenderTargetsRenderTime;
  56639. private _renderTargetsRenderTime;
  56640. private _captureFrameTime;
  56641. private _frameTime;
  56642. private _captureRenderTime;
  56643. private _renderTime;
  56644. private _captureInterFrameTime;
  56645. private _interFrameTime;
  56646. private _captureParticlesRenderTime;
  56647. private _particlesRenderTime;
  56648. private _captureSpritesRenderTime;
  56649. private _spritesRenderTime;
  56650. private _capturePhysicsTime;
  56651. private _physicsTime;
  56652. private _captureAnimationsTime;
  56653. private _animationsTime;
  56654. private _captureCameraRenderTime;
  56655. private _cameraRenderTime;
  56656. private _onBeforeActiveMeshesEvaluationObserver;
  56657. private _onAfterActiveMeshesEvaluationObserver;
  56658. private _onBeforeRenderTargetsRenderObserver;
  56659. private _onAfterRenderTargetsRenderObserver;
  56660. private _onAfterRenderObserver;
  56661. private _onBeforeDrawPhaseObserver;
  56662. private _onAfterDrawPhaseObserver;
  56663. private _onBeforeAnimationsObserver;
  56664. private _onBeforeParticlesRenderingObserver;
  56665. private _onAfterParticlesRenderingObserver;
  56666. private _onBeforeSpritesRenderingObserver;
  56667. private _onAfterSpritesRenderingObserver;
  56668. private _onBeforePhysicsObserver;
  56669. private _onAfterPhysicsObserver;
  56670. private _onAfterAnimationsObserver;
  56671. private _onBeforeCameraRenderObserver;
  56672. private _onAfterCameraRenderObserver;
  56673. /**
  56674. * Gets the perf counter used for active meshes evaluation time
  56675. */
  56676. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  56677. /**
  56678. * Gets the active meshes evaluation time capture status
  56679. */
  56680. get captureActiveMeshesEvaluationTime(): boolean;
  56681. /**
  56682. * Enable or disable the active meshes evaluation time capture
  56683. */
  56684. set captureActiveMeshesEvaluationTime(value: boolean);
  56685. /**
  56686. * Gets the perf counter used for render targets render time
  56687. */
  56688. get renderTargetsRenderTimeCounter(): PerfCounter;
  56689. /**
  56690. * Gets the render targets render time capture status
  56691. */
  56692. get captureRenderTargetsRenderTime(): boolean;
  56693. /**
  56694. * Enable or disable the render targets render time capture
  56695. */
  56696. set captureRenderTargetsRenderTime(value: boolean);
  56697. /**
  56698. * Gets the perf counter used for particles render time
  56699. */
  56700. get particlesRenderTimeCounter(): PerfCounter;
  56701. /**
  56702. * Gets the particles render time capture status
  56703. */
  56704. get captureParticlesRenderTime(): boolean;
  56705. /**
  56706. * Enable or disable the particles render time capture
  56707. */
  56708. set captureParticlesRenderTime(value: boolean);
  56709. /**
  56710. * Gets the perf counter used for sprites render time
  56711. */
  56712. get spritesRenderTimeCounter(): PerfCounter;
  56713. /**
  56714. * Gets the sprites render time capture status
  56715. */
  56716. get captureSpritesRenderTime(): boolean;
  56717. /**
  56718. * Enable or disable the sprites render time capture
  56719. */
  56720. set captureSpritesRenderTime(value: boolean);
  56721. /**
  56722. * Gets the perf counter used for physics time
  56723. */
  56724. get physicsTimeCounter(): PerfCounter;
  56725. /**
  56726. * Gets the physics time capture status
  56727. */
  56728. get capturePhysicsTime(): boolean;
  56729. /**
  56730. * Enable or disable the physics time capture
  56731. */
  56732. set capturePhysicsTime(value: boolean);
  56733. /**
  56734. * Gets the perf counter used for animations time
  56735. */
  56736. get animationsTimeCounter(): PerfCounter;
  56737. /**
  56738. * Gets the animations time capture status
  56739. */
  56740. get captureAnimationsTime(): boolean;
  56741. /**
  56742. * Enable or disable the animations time capture
  56743. */
  56744. set captureAnimationsTime(value: boolean);
  56745. /**
  56746. * Gets the perf counter used for frame time capture
  56747. */
  56748. get frameTimeCounter(): PerfCounter;
  56749. /**
  56750. * Gets the frame time capture status
  56751. */
  56752. get captureFrameTime(): boolean;
  56753. /**
  56754. * Enable or disable the frame time capture
  56755. */
  56756. set captureFrameTime(value: boolean);
  56757. /**
  56758. * Gets the perf counter used for inter-frames time capture
  56759. */
  56760. get interFrameTimeCounter(): PerfCounter;
  56761. /**
  56762. * Gets the inter-frames time capture status
  56763. */
  56764. get captureInterFrameTime(): boolean;
  56765. /**
  56766. * Enable or disable the inter-frames time capture
  56767. */
  56768. set captureInterFrameTime(value: boolean);
  56769. /**
  56770. * Gets the perf counter used for render time capture
  56771. */
  56772. get renderTimeCounter(): PerfCounter;
  56773. /**
  56774. * Gets the render time capture status
  56775. */
  56776. get captureRenderTime(): boolean;
  56777. /**
  56778. * Enable or disable the render time capture
  56779. */
  56780. set captureRenderTime(value: boolean);
  56781. /**
  56782. * Gets the perf counter used for camera render time capture
  56783. */
  56784. get cameraRenderTimeCounter(): PerfCounter;
  56785. /**
  56786. * Gets the camera render time capture status
  56787. */
  56788. get captureCameraRenderTime(): boolean;
  56789. /**
  56790. * Enable or disable the camera render time capture
  56791. */
  56792. set captureCameraRenderTime(value: boolean);
  56793. /**
  56794. * Gets the perf counter used for draw calls
  56795. */
  56796. get drawCallsCounter(): PerfCounter;
  56797. /**
  56798. * Instantiates a new scene instrumentation.
  56799. * This class can be used to get instrumentation data from a Babylon engine
  56800. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56801. * @param scene Defines the scene to instrument
  56802. */
  56803. constructor(
  56804. /**
  56805. * Defines the scene to instrument
  56806. */
  56807. scene: Scene);
  56808. /**
  56809. * Dispose and release associated resources.
  56810. */
  56811. dispose(): void;
  56812. }
  56813. }
  56814. declare module BABYLON {
  56815. /** @hidden */
  56816. export var glowMapGenerationPixelShader: {
  56817. name: string;
  56818. shader: string;
  56819. };
  56820. }
  56821. declare module BABYLON {
  56822. /** @hidden */
  56823. export var glowMapGenerationVertexShader: {
  56824. name: string;
  56825. shader: string;
  56826. };
  56827. }
  56828. declare module BABYLON {
  56829. /**
  56830. * Effect layer options. This helps customizing the behaviour
  56831. * of the effect layer.
  56832. */
  56833. export interface IEffectLayerOptions {
  56834. /**
  56835. * Multiplication factor apply to the canvas size to compute the render target size
  56836. * used to generated the objects (the smaller the faster).
  56837. */
  56838. mainTextureRatio: number;
  56839. /**
  56840. * Enforces a fixed size texture to ensure effect stability across devices.
  56841. */
  56842. mainTextureFixedSize?: number;
  56843. /**
  56844. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  56845. */
  56846. alphaBlendingMode: number;
  56847. /**
  56848. * The camera attached to the layer.
  56849. */
  56850. camera: Nullable<Camera>;
  56851. /**
  56852. * The rendering group to draw the layer in.
  56853. */
  56854. renderingGroupId: number;
  56855. }
  56856. /**
  56857. * The effect layer Helps adding post process effect blended with the main pass.
  56858. *
  56859. * This can be for instance use to generate glow or higlight effects on the scene.
  56860. *
  56861. * The effect layer class can not be used directly and is intented to inherited from to be
  56862. * customized per effects.
  56863. */
  56864. export abstract class EffectLayer {
  56865. private _vertexBuffers;
  56866. private _indexBuffer;
  56867. private _cachedDefines;
  56868. private _effectLayerMapGenerationEffect;
  56869. private _effectLayerOptions;
  56870. private _mergeEffect;
  56871. protected _scene: Scene;
  56872. protected _engine: Engine;
  56873. protected _maxSize: number;
  56874. protected _mainTextureDesiredSize: ISize;
  56875. protected _mainTexture: RenderTargetTexture;
  56876. protected _shouldRender: boolean;
  56877. protected _postProcesses: PostProcess[];
  56878. protected _textures: BaseTexture[];
  56879. protected _emissiveTextureAndColor: {
  56880. texture: Nullable<BaseTexture>;
  56881. color: Color4;
  56882. };
  56883. /**
  56884. * The name of the layer
  56885. */
  56886. name: string;
  56887. /**
  56888. * The clear color of the texture used to generate the glow map.
  56889. */
  56890. neutralColor: Color4;
  56891. /**
  56892. * Specifies whether the highlight layer is enabled or not.
  56893. */
  56894. isEnabled: boolean;
  56895. /**
  56896. * Gets the camera attached to the layer.
  56897. */
  56898. get camera(): Nullable<Camera>;
  56899. /**
  56900. * Gets the rendering group id the layer should render in.
  56901. */
  56902. get renderingGroupId(): number;
  56903. set renderingGroupId(renderingGroupId: number);
  56904. /**
  56905. * An event triggered when the effect layer has been disposed.
  56906. */
  56907. onDisposeObservable: Observable<EffectLayer>;
  56908. /**
  56909. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  56910. */
  56911. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  56912. /**
  56913. * An event triggered when the generated texture is being merged in the scene.
  56914. */
  56915. onBeforeComposeObservable: Observable<EffectLayer>;
  56916. /**
  56917. * An event triggered when the mesh is rendered into the effect render target.
  56918. */
  56919. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  56920. /**
  56921. * An event triggered after the mesh has been rendered into the effect render target.
  56922. */
  56923. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  56924. /**
  56925. * An event triggered when the generated texture has been merged in the scene.
  56926. */
  56927. onAfterComposeObservable: Observable<EffectLayer>;
  56928. /**
  56929. * An event triggered when the efffect layer changes its size.
  56930. */
  56931. onSizeChangedObservable: Observable<EffectLayer>;
  56932. /** @hidden */
  56933. static _SceneComponentInitialization: (scene: Scene) => void;
  56934. /**
  56935. * Instantiates a new effect Layer and references it in the scene.
  56936. * @param name The name of the layer
  56937. * @param scene The scene to use the layer in
  56938. */
  56939. constructor(
  56940. /** The Friendly of the effect in the scene */
  56941. name: string, scene: Scene);
  56942. /**
  56943. * Get the effect name of the layer.
  56944. * @return The effect name
  56945. */
  56946. abstract getEffectName(): string;
  56947. /**
  56948. * Checks for the readiness of the element composing the layer.
  56949. * @param subMesh the mesh to check for
  56950. * @param useInstances specify whether or not to use instances to render the mesh
  56951. * @return true if ready otherwise, false
  56952. */
  56953. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56954. /**
  56955. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56956. * @returns true if the effect requires stencil during the main canvas render pass.
  56957. */
  56958. abstract needStencil(): boolean;
  56959. /**
  56960. * Create the merge effect. This is the shader use to blit the information back
  56961. * to the main canvas at the end of the scene rendering.
  56962. * @returns The effect containing the shader used to merge the effect on the main canvas
  56963. */
  56964. protected abstract _createMergeEffect(): Effect;
  56965. /**
  56966. * Creates the render target textures and post processes used in the effect layer.
  56967. */
  56968. protected abstract _createTextureAndPostProcesses(): void;
  56969. /**
  56970. * Implementation specific of rendering the generating effect on the main canvas.
  56971. * @param effect The effect used to render through
  56972. */
  56973. protected abstract _internalRender(effect: Effect): void;
  56974. /**
  56975. * Sets the required values for both the emissive texture and and the main color.
  56976. */
  56977. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56978. /**
  56979. * Free any resources and references associated to a mesh.
  56980. * Internal use
  56981. * @param mesh The mesh to free.
  56982. */
  56983. abstract _disposeMesh(mesh: Mesh): void;
  56984. /**
  56985. * Serializes this layer (Glow or Highlight for example)
  56986. * @returns a serialized layer object
  56987. */
  56988. abstract serialize?(): any;
  56989. /**
  56990. * Initializes the effect layer with the required options.
  56991. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  56992. */
  56993. protected _init(options: Partial<IEffectLayerOptions>): void;
  56994. /**
  56995. * Generates the index buffer of the full screen quad blending to the main canvas.
  56996. */
  56997. private _generateIndexBuffer;
  56998. /**
  56999. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  57000. */
  57001. private _generateVertexBuffer;
  57002. /**
  57003. * Sets the main texture desired size which is the closest power of two
  57004. * of the engine canvas size.
  57005. */
  57006. private _setMainTextureSize;
  57007. /**
  57008. * Creates the main texture for the effect layer.
  57009. */
  57010. protected _createMainTexture(): void;
  57011. /**
  57012. * Adds specific effects defines.
  57013. * @param defines The defines to add specifics to.
  57014. */
  57015. protected _addCustomEffectDefines(defines: string[]): void;
  57016. /**
  57017. * Checks for the readiness of the element composing the layer.
  57018. * @param subMesh the mesh to check for
  57019. * @param useInstances specify whether or not to use instances to render the mesh
  57020. * @param emissiveTexture the associated emissive texture used to generate the glow
  57021. * @return true if ready otherwise, false
  57022. */
  57023. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  57024. /**
  57025. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  57026. */
  57027. render(): void;
  57028. /**
  57029. * Determine if a given mesh will be used in the current effect.
  57030. * @param mesh mesh to test
  57031. * @returns true if the mesh will be used
  57032. */
  57033. hasMesh(mesh: AbstractMesh): boolean;
  57034. /**
  57035. * Returns true if the layer contains information to display, otherwise false.
  57036. * @returns true if the glow layer should be rendered
  57037. */
  57038. shouldRender(): boolean;
  57039. /**
  57040. * Returns true if the mesh should render, otherwise false.
  57041. * @param mesh The mesh to render
  57042. * @returns true if it should render otherwise false
  57043. */
  57044. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  57045. /**
  57046. * Returns true if the mesh can be rendered, otherwise false.
  57047. * @param mesh The mesh to render
  57048. * @param material The material used on the mesh
  57049. * @returns true if it can be rendered otherwise false
  57050. */
  57051. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  57052. /**
  57053. * Returns true if the mesh should render, otherwise false.
  57054. * @param mesh The mesh to render
  57055. * @returns true if it should render otherwise false
  57056. */
  57057. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  57058. /**
  57059. * Renders the submesh passed in parameter to the generation map.
  57060. */
  57061. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  57062. /**
  57063. * Defines whether the current material of the mesh should be use to render the effect.
  57064. * @param mesh defines the current mesh to render
  57065. */
  57066. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  57067. /**
  57068. * Rebuild the required buffers.
  57069. * @hidden Internal use only.
  57070. */
  57071. _rebuild(): void;
  57072. /**
  57073. * Dispose only the render target textures and post process.
  57074. */
  57075. private _disposeTextureAndPostProcesses;
  57076. /**
  57077. * Dispose the highlight layer and free resources.
  57078. */
  57079. dispose(): void;
  57080. /**
  57081. * Gets the class name of the effect layer
  57082. * @returns the string with the class name of the effect layer
  57083. */
  57084. getClassName(): string;
  57085. /**
  57086. * Creates an effect layer from parsed effect layer data
  57087. * @param parsedEffectLayer defines effect layer data
  57088. * @param scene defines the current scene
  57089. * @param rootUrl defines the root URL containing the effect layer information
  57090. * @returns a parsed effect Layer
  57091. */
  57092. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  57093. }
  57094. }
  57095. declare module BABYLON {
  57096. interface AbstractScene {
  57097. /**
  57098. * The list of effect layers (highlights/glow) added to the scene
  57099. * @see http://doc.babylonjs.com/how_to/highlight_layer
  57100. * @see http://doc.babylonjs.com/how_to/glow_layer
  57101. */
  57102. effectLayers: Array<EffectLayer>;
  57103. /**
  57104. * Removes the given effect layer from this scene.
  57105. * @param toRemove defines the effect layer to remove
  57106. * @returns the index of the removed effect layer
  57107. */
  57108. removeEffectLayer(toRemove: EffectLayer): number;
  57109. /**
  57110. * Adds the given effect layer to this scene
  57111. * @param newEffectLayer defines the effect layer to add
  57112. */
  57113. addEffectLayer(newEffectLayer: EffectLayer): void;
  57114. }
  57115. /**
  57116. * Defines the layer scene component responsible to manage any effect layers
  57117. * in a given scene.
  57118. */
  57119. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  57120. /**
  57121. * The component name helpfull to identify the component in the list of scene components.
  57122. */
  57123. readonly name: string;
  57124. /**
  57125. * The scene the component belongs to.
  57126. */
  57127. scene: Scene;
  57128. private _engine;
  57129. private _renderEffects;
  57130. private _needStencil;
  57131. private _previousStencilState;
  57132. /**
  57133. * Creates a new instance of the component for the given scene
  57134. * @param scene Defines the scene to register the component in
  57135. */
  57136. constructor(scene: Scene);
  57137. /**
  57138. * Registers the component in a given scene
  57139. */
  57140. register(): void;
  57141. /**
  57142. * Rebuilds the elements related to this component in case of
  57143. * context lost for instance.
  57144. */
  57145. rebuild(): void;
  57146. /**
  57147. * Serializes the component data to the specified json object
  57148. * @param serializationObject The object to serialize to
  57149. */
  57150. serialize(serializationObject: any): void;
  57151. /**
  57152. * Adds all the elements from the container to the scene
  57153. * @param container the container holding the elements
  57154. */
  57155. addFromContainer(container: AbstractScene): void;
  57156. /**
  57157. * Removes all the elements in the container from the scene
  57158. * @param container contains the elements to remove
  57159. * @param dispose if the removed element should be disposed (default: false)
  57160. */
  57161. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57162. /**
  57163. * Disposes the component and the associated ressources.
  57164. */
  57165. dispose(): void;
  57166. private _isReadyForMesh;
  57167. private _renderMainTexture;
  57168. private _setStencil;
  57169. private _setStencilBack;
  57170. private _draw;
  57171. private _drawCamera;
  57172. private _drawRenderingGroup;
  57173. }
  57174. }
  57175. declare module BABYLON {
  57176. /** @hidden */
  57177. export var glowMapMergePixelShader: {
  57178. name: string;
  57179. shader: string;
  57180. };
  57181. }
  57182. declare module BABYLON {
  57183. /** @hidden */
  57184. export var glowMapMergeVertexShader: {
  57185. name: string;
  57186. shader: string;
  57187. };
  57188. }
  57189. declare module BABYLON {
  57190. interface AbstractScene {
  57191. /**
  57192. * Return a the first highlight layer of the scene with a given name.
  57193. * @param name The name of the highlight layer to look for.
  57194. * @return The highlight layer if found otherwise null.
  57195. */
  57196. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  57197. }
  57198. /**
  57199. * Glow layer options. This helps customizing the behaviour
  57200. * of the glow layer.
  57201. */
  57202. export interface IGlowLayerOptions {
  57203. /**
  57204. * Multiplication factor apply to the canvas size to compute the render target size
  57205. * used to generated the glowing objects (the smaller the faster).
  57206. */
  57207. mainTextureRatio: number;
  57208. /**
  57209. * Enforces a fixed size texture to ensure resize independant blur.
  57210. */
  57211. mainTextureFixedSize?: number;
  57212. /**
  57213. * How big is the kernel of the blur texture.
  57214. */
  57215. blurKernelSize: number;
  57216. /**
  57217. * The camera attached to the layer.
  57218. */
  57219. camera: Nullable<Camera>;
  57220. /**
  57221. * Enable MSAA by chosing the number of samples.
  57222. */
  57223. mainTextureSamples?: number;
  57224. /**
  57225. * The rendering group to draw the layer in.
  57226. */
  57227. renderingGroupId: number;
  57228. }
  57229. /**
  57230. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  57231. *
  57232. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  57233. *
  57234. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  57235. */
  57236. export class GlowLayer extends EffectLayer {
  57237. /**
  57238. * Effect Name of the layer.
  57239. */
  57240. static readonly EffectName: string;
  57241. /**
  57242. * The default blur kernel size used for the glow.
  57243. */
  57244. static DefaultBlurKernelSize: number;
  57245. /**
  57246. * The default texture size ratio used for the glow.
  57247. */
  57248. static DefaultTextureRatio: number;
  57249. /**
  57250. * Sets the kernel size of the blur.
  57251. */
  57252. set blurKernelSize(value: number);
  57253. /**
  57254. * Gets the kernel size of the blur.
  57255. */
  57256. get blurKernelSize(): number;
  57257. /**
  57258. * Sets the glow intensity.
  57259. */
  57260. set intensity(value: number);
  57261. /**
  57262. * Gets the glow intensity.
  57263. */
  57264. get intensity(): number;
  57265. private _options;
  57266. private _intensity;
  57267. private _horizontalBlurPostprocess1;
  57268. private _verticalBlurPostprocess1;
  57269. private _horizontalBlurPostprocess2;
  57270. private _verticalBlurPostprocess2;
  57271. private _blurTexture1;
  57272. private _blurTexture2;
  57273. private _postProcesses1;
  57274. private _postProcesses2;
  57275. private _includedOnlyMeshes;
  57276. private _excludedMeshes;
  57277. private _meshesUsingTheirOwnMaterials;
  57278. /**
  57279. * Callback used to let the user override the color selection on a per mesh basis
  57280. */
  57281. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  57282. /**
  57283. * Callback used to let the user override the texture selection on a per mesh basis
  57284. */
  57285. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  57286. /**
  57287. * Instantiates a new glow Layer and references it to the scene.
  57288. * @param name The name of the layer
  57289. * @param scene The scene to use the layer in
  57290. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  57291. */
  57292. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  57293. /**
  57294. * Get the effect name of the layer.
  57295. * @return The effect name
  57296. */
  57297. getEffectName(): string;
  57298. /**
  57299. * Create the merge effect. This is the shader use to blit the information back
  57300. * to the main canvas at the end of the scene rendering.
  57301. */
  57302. protected _createMergeEffect(): Effect;
  57303. /**
  57304. * Creates the render target textures and post processes used in the glow layer.
  57305. */
  57306. protected _createTextureAndPostProcesses(): void;
  57307. /**
  57308. * Checks for the readiness of the element composing the layer.
  57309. * @param subMesh the mesh to check for
  57310. * @param useInstances specify wether or not to use instances to render the mesh
  57311. * @param emissiveTexture the associated emissive texture used to generate the glow
  57312. * @return true if ready otherwise, false
  57313. */
  57314. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57315. /**
  57316. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  57317. */
  57318. needStencil(): boolean;
  57319. /**
  57320. * Returns true if the mesh can be rendered, otherwise false.
  57321. * @param mesh The mesh to render
  57322. * @param material The material used on the mesh
  57323. * @returns true if it can be rendered otherwise false
  57324. */
  57325. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  57326. /**
  57327. * Implementation specific of rendering the generating effect on the main canvas.
  57328. * @param effect The effect used to render through
  57329. */
  57330. protected _internalRender(effect: Effect): void;
  57331. /**
  57332. * Sets the required values for both the emissive texture and and the main color.
  57333. */
  57334. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57335. /**
  57336. * Returns true if the mesh should render, otherwise false.
  57337. * @param mesh The mesh to render
  57338. * @returns true if it should render otherwise false
  57339. */
  57340. protected _shouldRenderMesh(mesh: Mesh): boolean;
  57341. /**
  57342. * Adds specific effects defines.
  57343. * @param defines The defines to add specifics to.
  57344. */
  57345. protected _addCustomEffectDefines(defines: string[]): void;
  57346. /**
  57347. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  57348. * @param mesh The mesh to exclude from the glow layer
  57349. */
  57350. addExcludedMesh(mesh: Mesh): void;
  57351. /**
  57352. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  57353. * @param mesh The mesh to remove
  57354. */
  57355. removeExcludedMesh(mesh: Mesh): void;
  57356. /**
  57357. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  57358. * @param mesh The mesh to include in the glow layer
  57359. */
  57360. addIncludedOnlyMesh(mesh: Mesh): void;
  57361. /**
  57362. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  57363. * @param mesh The mesh to remove
  57364. */
  57365. removeIncludedOnlyMesh(mesh: Mesh): void;
  57366. /**
  57367. * Determine if a given mesh will be used in the glow layer
  57368. * @param mesh The mesh to test
  57369. * @returns true if the mesh will be highlighted by the current glow layer
  57370. */
  57371. hasMesh(mesh: AbstractMesh): boolean;
  57372. /**
  57373. * Defines whether the current material of the mesh should be use to render the effect.
  57374. * @param mesh defines the current mesh to render
  57375. */
  57376. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  57377. /**
  57378. * Add a mesh to be rendered through its own material and not with emissive only.
  57379. * @param mesh The mesh for which we need to use its material
  57380. */
  57381. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  57382. /**
  57383. * Remove a mesh from being rendered through its own material and not with emissive only.
  57384. * @param mesh The mesh for which we need to not use its material
  57385. */
  57386. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  57387. /**
  57388. * Free any resources and references associated to a mesh.
  57389. * Internal use
  57390. * @param mesh The mesh to free.
  57391. * @hidden
  57392. */
  57393. _disposeMesh(mesh: Mesh): void;
  57394. /**
  57395. * Gets the class name of the effect layer
  57396. * @returns the string with the class name of the effect layer
  57397. */
  57398. getClassName(): string;
  57399. /**
  57400. * Serializes this glow layer
  57401. * @returns a serialized glow layer object
  57402. */
  57403. serialize(): any;
  57404. /**
  57405. * Creates a Glow Layer from parsed glow layer data
  57406. * @param parsedGlowLayer defines glow layer data
  57407. * @param scene defines the current scene
  57408. * @param rootUrl defines the root URL containing the glow layer information
  57409. * @returns a parsed Glow Layer
  57410. */
  57411. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  57412. }
  57413. }
  57414. declare module BABYLON {
  57415. /** @hidden */
  57416. export var glowBlurPostProcessPixelShader: {
  57417. name: string;
  57418. shader: string;
  57419. };
  57420. }
  57421. declare module BABYLON {
  57422. interface AbstractScene {
  57423. /**
  57424. * Return a the first highlight layer of the scene with a given name.
  57425. * @param name The name of the highlight layer to look for.
  57426. * @return The highlight layer if found otherwise null.
  57427. */
  57428. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  57429. }
  57430. /**
  57431. * Highlight layer options. This helps customizing the behaviour
  57432. * of the highlight layer.
  57433. */
  57434. export interface IHighlightLayerOptions {
  57435. /**
  57436. * Multiplication factor apply to the canvas size to compute the render target size
  57437. * used to generated the glowing objects (the smaller the faster).
  57438. */
  57439. mainTextureRatio: number;
  57440. /**
  57441. * Enforces a fixed size texture to ensure resize independant blur.
  57442. */
  57443. mainTextureFixedSize?: number;
  57444. /**
  57445. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  57446. * of the picture to blur (the smaller the faster).
  57447. */
  57448. blurTextureSizeRatio: number;
  57449. /**
  57450. * How big in texel of the blur texture is the vertical blur.
  57451. */
  57452. blurVerticalSize: number;
  57453. /**
  57454. * How big in texel of the blur texture is the horizontal blur.
  57455. */
  57456. blurHorizontalSize: number;
  57457. /**
  57458. * Alpha blending mode used to apply the blur. Default is combine.
  57459. */
  57460. alphaBlendingMode: number;
  57461. /**
  57462. * The camera attached to the layer.
  57463. */
  57464. camera: Nullable<Camera>;
  57465. /**
  57466. * Should we display highlight as a solid stroke?
  57467. */
  57468. isStroke?: boolean;
  57469. /**
  57470. * The rendering group to draw the layer in.
  57471. */
  57472. renderingGroupId: number;
  57473. }
  57474. /**
  57475. * The highlight layer Helps adding a glow effect around a mesh.
  57476. *
  57477. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  57478. * glowy meshes to your scene.
  57479. *
  57480. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  57481. */
  57482. export class HighlightLayer extends EffectLayer {
  57483. name: string;
  57484. /**
  57485. * Effect Name of the highlight layer.
  57486. */
  57487. static readonly EffectName: string;
  57488. /**
  57489. * The neutral color used during the preparation of the glow effect.
  57490. * This is black by default as the blend operation is a blend operation.
  57491. */
  57492. static NeutralColor: Color4;
  57493. /**
  57494. * Stencil value used for glowing meshes.
  57495. */
  57496. static GlowingMeshStencilReference: number;
  57497. /**
  57498. * Stencil value used for the other meshes in the scene.
  57499. */
  57500. static NormalMeshStencilReference: number;
  57501. /**
  57502. * Specifies whether or not the inner glow is ACTIVE in the layer.
  57503. */
  57504. innerGlow: boolean;
  57505. /**
  57506. * Specifies whether or not the outer glow is ACTIVE in the layer.
  57507. */
  57508. outerGlow: boolean;
  57509. /**
  57510. * Specifies the horizontal size of the blur.
  57511. */
  57512. set blurHorizontalSize(value: number);
  57513. /**
  57514. * Specifies the vertical size of the blur.
  57515. */
  57516. set blurVerticalSize(value: number);
  57517. /**
  57518. * Gets the horizontal size of the blur.
  57519. */
  57520. get blurHorizontalSize(): number;
  57521. /**
  57522. * Gets the vertical size of the blur.
  57523. */
  57524. get blurVerticalSize(): number;
  57525. /**
  57526. * An event triggered when the highlight layer is being blurred.
  57527. */
  57528. onBeforeBlurObservable: Observable<HighlightLayer>;
  57529. /**
  57530. * An event triggered when the highlight layer has been blurred.
  57531. */
  57532. onAfterBlurObservable: Observable<HighlightLayer>;
  57533. private _instanceGlowingMeshStencilReference;
  57534. private _options;
  57535. private _downSamplePostprocess;
  57536. private _horizontalBlurPostprocess;
  57537. private _verticalBlurPostprocess;
  57538. private _blurTexture;
  57539. private _meshes;
  57540. private _excludedMeshes;
  57541. /**
  57542. * Instantiates a new highlight Layer and references it to the scene..
  57543. * @param name The name of the layer
  57544. * @param scene The scene to use the layer in
  57545. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  57546. */
  57547. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  57548. /**
  57549. * Get the effect name of the layer.
  57550. * @return The effect name
  57551. */
  57552. getEffectName(): string;
  57553. /**
  57554. * Create the merge effect. This is the shader use to blit the information back
  57555. * to the main canvas at the end of the scene rendering.
  57556. */
  57557. protected _createMergeEffect(): Effect;
  57558. /**
  57559. * Creates the render target textures and post processes used in the highlight layer.
  57560. */
  57561. protected _createTextureAndPostProcesses(): void;
  57562. /**
  57563. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  57564. */
  57565. needStencil(): boolean;
  57566. /**
  57567. * Checks for the readiness of the element composing the layer.
  57568. * @param subMesh the mesh to check for
  57569. * @param useInstances specify wether or not to use instances to render the mesh
  57570. * @param emissiveTexture the associated emissive texture used to generate the glow
  57571. * @return true if ready otherwise, false
  57572. */
  57573. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57574. /**
  57575. * Implementation specific of rendering the generating effect on the main canvas.
  57576. * @param effect The effect used to render through
  57577. */
  57578. protected _internalRender(effect: Effect): void;
  57579. /**
  57580. * Returns true if the layer contains information to display, otherwise false.
  57581. */
  57582. shouldRender(): boolean;
  57583. /**
  57584. * Returns true if the mesh should render, otherwise false.
  57585. * @param mesh The mesh to render
  57586. * @returns true if it should render otherwise false
  57587. */
  57588. protected _shouldRenderMesh(mesh: Mesh): boolean;
  57589. /**
  57590. * Adds specific effects defines.
  57591. * @param defines The defines to add specifics to.
  57592. */
  57593. protected _addCustomEffectDefines(defines: string[]): void;
  57594. /**
  57595. * Sets the required values for both the emissive texture and and the main color.
  57596. */
  57597. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57598. /**
  57599. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  57600. * @param mesh The mesh to exclude from the highlight layer
  57601. */
  57602. addExcludedMesh(mesh: Mesh): void;
  57603. /**
  57604. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  57605. * @param mesh The mesh to highlight
  57606. */
  57607. removeExcludedMesh(mesh: Mesh): void;
  57608. /**
  57609. * Determine if a given mesh will be highlighted by the current HighlightLayer
  57610. * @param mesh mesh to test
  57611. * @returns true if the mesh will be highlighted by the current HighlightLayer
  57612. */
  57613. hasMesh(mesh: AbstractMesh): boolean;
  57614. /**
  57615. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  57616. * @param mesh The mesh to highlight
  57617. * @param color The color of the highlight
  57618. * @param glowEmissiveOnly Extract the glow from the emissive texture
  57619. */
  57620. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  57621. /**
  57622. * Remove a mesh from the highlight layer in order to make it stop glowing.
  57623. * @param mesh The mesh to highlight
  57624. */
  57625. removeMesh(mesh: Mesh): void;
  57626. /**
  57627. * Remove all the meshes currently referenced in the highlight layer
  57628. */
  57629. removeAllMeshes(): void;
  57630. /**
  57631. * Force the stencil to the normal expected value for none glowing parts
  57632. */
  57633. private _defaultStencilReference;
  57634. /**
  57635. * Free any resources and references associated to a mesh.
  57636. * Internal use
  57637. * @param mesh The mesh to free.
  57638. * @hidden
  57639. */
  57640. _disposeMesh(mesh: Mesh): void;
  57641. /**
  57642. * Dispose the highlight layer and free resources.
  57643. */
  57644. dispose(): void;
  57645. /**
  57646. * Gets the class name of the effect layer
  57647. * @returns the string with the class name of the effect layer
  57648. */
  57649. getClassName(): string;
  57650. /**
  57651. * Serializes this Highlight layer
  57652. * @returns a serialized Highlight layer object
  57653. */
  57654. serialize(): any;
  57655. /**
  57656. * Creates a Highlight layer from parsed Highlight layer data
  57657. * @param parsedHightlightLayer defines the Highlight layer data
  57658. * @param scene defines the current scene
  57659. * @param rootUrl defines the root URL containing the Highlight layer information
  57660. * @returns a parsed Highlight layer
  57661. */
  57662. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  57663. }
  57664. }
  57665. declare module BABYLON {
  57666. interface AbstractScene {
  57667. /**
  57668. * The list of layers (background and foreground) of the scene
  57669. */
  57670. layers: Array<Layer>;
  57671. }
  57672. /**
  57673. * Defines the layer scene component responsible to manage any layers
  57674. * in a given scene.
  57675. */
  57676. export class LayerSceneComponent implements ISceneComponent {
  57677. /**
  57678. * The component name helpfull to identify the component in the list of scene components.
  57679. */
  57680. readonly name: string;
  57681. /**
  57682. * The scene the component belongs to.
  57683. */
  57684. scene: Scene;
  57685. private _engine;
  57686. /**
  57687. * Creates a new instance of the component for the given scene
  57688. * @param scene Defines the scene to register the component in
  57689. */
  57690. constructor(scene: Scene);
  57691. /**
  57692. * Registers the component in a given scene
  57693. */
  57694. register(): void;
  57695. /**
  57696. * Rebuilds the elements related to this component in case of
  57697. * context lost for instance.
  57698. */
  57699. rebuild(): void;
  57700. /**
  57701. * Disposes the component and the associated ressources.
  57702. */
  57703. dispose(): void;
  57704. private _draw;
  57705. private _drawCameraPredicate;
  57706. private _drawCameraBackground;
  57707. private _drawCameraForeground;
  57708. private _drawRenderTargetPredicate;
  57709. private _drawRenderTargetBackground;
  57710. private _drawRenderTargetForeground;
  57711. /**
  57712. * Adds all the elements from the container to the scene
  57713. * @param container the container holding the elements
  57714. */
  57715. addFromContainer(container: AbstractScene): void;
  57716. /**
  57717. * Removes all the elements in the container from the scene
  57718. * @param container contains the elements to remove
  57719. * @param dispose if the removed element should be disposed (default: false)
  57720. */
  57721. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57722. }
  57723. }
  57724. declare module BABYLON {
  57725. /** @hidden */
  57726. export var layerPixelShader: {
  57727. name: string;
  57728. shader: string;
  57729. };
  57730. }
  57731. declare module BABYLON {
  57732. /** @hidden */
  57733. export var layerVertexShader: {
  57734. name: string;
  57735. shader: string;
  57736. };
  57737. }
  57738. declare module BABYLON {
  57739. /**
  57740. * This represents a full screen 2d layer.
  57741. * This can be useful to display a picture in the background of your scene for instance.
  57742. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57743. */
  57744. export class Layer {
  57745. /**
  57746. * Define the name of the layer.
  57747. */
  57748. name: string;
  57749. /**
  57750. * Define the texture the layer should display.
  57751. */
  57752. texture: Nullable<Texture>;
  57753. /**
  57754. * Is the layer in background or foreground.
  57755. */
  57756. isBackground: boolean;
  57757. /**
  57758. * Define the color of the layer (instead of texture).
  57759. */
  57760. color: Color4;
  57761. /**
  57762. * Define the scale of the layer in order to zoom in out of the texture.
  57763. */
  57764. scale: Vector2;
  57765. /**
  57766. * Define an offset for the layer in order to shift the texture.
  57767. */
  57768. offset: Vector2;
  57769. /**
  57770. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  57771. */
  57772. alphaBlendingMode: number;
  57773. /**
  57774. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  57775. * Alpha test will not mix with the background color in case of transparency.
  57776. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  57777. */
  57778. alphaTest: boolean;
  57779. /**
  57780. * Define a mask to restrict the layer to only some of the scene cameras.
  57781. */
  57782. layerMask: number;
  57783. /**
  57784. * Define the list of render target the layer is visible into.
  57785. */
  57786. renderTargetTextures: RenderTargetTexture[];
  57787. /**
  57788. * Define if the layer is only used in renderTarget or if it also
  57789. * renders in the main frame buffer of the canvas.
  57790. */
  57791. renderOnlyInRenderTargetTextures: boolean;
  57792. private _scene;
  57793. private _vertexBuffers;
  57794. private _indexBuffer;
  57795. private _effect;
  57796. private _previousDefines;
  57797. /**
  57798. * An event triggered when the layer is disposed.
  57799. */
  57800. onDisposeObservable: Observable<Layer>;
  57801. private _onDisposeObserver;
  57802. /**
  57803. * Back compatibility with callback before the onDisposeObservable existed.
  57804. * The set callback will be triggered when the layer has been disposed.
  57805. */
  57806. set onDispose(callback: () => void);
  57807. /**
  57808. * An event triggered before rendering the scene
  57809. */
  57810. onBeforeRenderObservable: Observable<Layer>;
  57811. private _onBeforeRenderObserver;
  57812. /**
  57813. * Back compatibility with callback before the onBeforeRenderObservable existed.
  57814. * The set callback will be triggered just before rendering the layer.
  57815. */
  57816. set onBeforeRender(callback: () => void);
  57817. /**
  57818. * An event triggered after rendering the scene
  57819. */
  57820. onAfterRenderObservable: Observable<Layer>;
  57821. private _onAfterRenderObserver;
  57822. /**
  57823. * Back compatibility with callback before the onAfterRenderObservable existed.
  57824. * The set callback will be triggered just after rendering the layer.
  57825. */
  57826. set onAfterRender(callback: () => void);
  57827. /**
  57828. * Instantiates a new layer.
  57829. * This represents a full screen 2d layer.
  57830. * This can be useful to display a picture in the background of your scene for instance.
  57831. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57832. * @param name Define the name of the layer in the scene
  57833. * @param imgUrl Define the url of the texture to display in the layer
  57834. * @param scene Define the scene the layer belongs to
  57835. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  57836. * @param color Defines a color for the layer
  57837. */
  57838. constructor(
  57839. /**
  57840. * Define the name of the layer.
  57841. */
  57842. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  57843. private _createIndexBuffer;
  57844. /** @hidden */
  57845. _rebuild(): void;
  57846. /**
  57847. * Renders the layer in the scene.
  57848. */
  57849. render(): void;
  57850. /**
  57851. * Disposes and releases the associated ressources.
  57852. */
  57853. dispose(): void;
  57854. }
  57855. }
  57856. declare module BABYLON {
  57857. /** @hidden */
  57858. export var lensFlarePixelShader: {
  57859. name: string;
  57860. shader: string;
  57861. };
  57862. }
  57863. declare module BABYLON {
  57864. /** @hidden */
  57865. export var lensFlareVertexShader: {
  57866. name: string;
  57867. shader: string;
  57868. };
  57869. }
  57870. declare module BABYLON {
  57871. /**
  57872. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57873. * It is usually composed of several `lensFlare`.
  57874. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57875. */
  57876. export class LensFlareSystem {
  57877. /**
  57878. * Define the name of the lens flare system
  57879. */
  57880. name: string;
  57881. /**
  57882. * List of lens flares used in this system.
  57883. */
  57884. lensFlares: LensFlare[];
  57885. /**
  57886. * Define a limit from the border the lens flare can be visible.
  57887. */
  57888. borderLimit: number;
  57889. /**
  57890. * Define a viewport border we do not want to see the lens flare in.
  57891. */
  57892. viewportBorder: number;
  57893. /**
  57894. * Define a predicate which could limit the list of meshes able to occlude the effect.
  57895. */
  57896. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  57897. /**
  57898. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  57899. */
  57900. layerMask: number;
  57901. /**
  57902. * Define the id of the lens flare system in the scene.
  57903. * (equal to name by default)
  57904. */
  57905. id: string;
  57906. private _scene;
  57907. private _emitter;
  57908. private _vertexBuffers;
  57909. private _indexBuffer;
  57910. private _effect;
  57911. private _positionX;
  57912. private _positionY;
  57913. private _isEnabled;
  57914. /** @hidden */
  57915. static _SceneComponentInitialization: (scene: Scene) => void;
  57916. /**
  57917. * Instantiates a lens flare system.
  57918. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57919. * It is usually composed of several `lensFlare`.
  57920. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57921. * @param name Define the name of the lens flare system in the scene
  57922. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  57923. * @param scene Define the scene the lens flare system belongs to
  57924. */
  57925. constructor(
  57926. /**
  57927. * Define the name of the lens flare system
  57928. */
  57929. name: string, emitter: any, scene: Scene);
  57930. /**
  57931. * Define if the lens flare system is enabled.
  57932. */
  57933. get isEnabled(): boolean;
  57934. set isEnabled(value: boolean);
  57935. /**
  57936. * Get the scene the effects belongs to.
  57937. * @returns the scene holding the lens flare system
  57938. */
  57939. getScene(): Scene;
  57940. /**
  57941. * Get the emitter of the lens flare system.
  57942. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57943. * @returns the emitter of the lens flare system
  57944. */
  57945. getEmitter(): any;
  57946. /**
  57947. * Set the emitter of the lens flare system.
  57948. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57949. * @param newEmitter Define the new emitter of the system
  57950. */
  57951. setEmitter(newEmitter: any): void;
  57952. /**
  57953. * Get the lens flare system emitter position.
  57954. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  57955. * @returns the position
  57956. */
  57957. getEmitterPosition(): Vector3;
  57958. /**
  57959. * @hidden
  57960. */
  57961. computeEffectivePosition(globalViewport: Viewport): boolean;
  57962. /** @hidden */
  57963. _isVisible(): boolean;
  57964. /**
  57965. * @hidden
  57966. */
  57967. render(): boolean;
  57968. /**
  57969. * Dispose and release the lens flare with its associated resources.
  57970. */
  57971. dispose(): void;
  57972. /**
  57973. * Parse a lens flare system from a JSON repressentation
  57974. * @param parsedLensFlareSystem Define the JSON to parse
  57975. * @param scene Define the scene the parsed system should be instantiated in
  57976. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  57977. * @returns the parsed system
  57978. */
  57979. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  57980. /**
  57981. * Serialize the current Lens Flare System into a JSON representation.
  57982. * @returns the serialized JSON
  57983. */
  57984. serialize(): any;
  57985. }
  57986. }
  57987. declare module BABYLON {
  57988. /**
  57989. * This represents one of the lens effect in a `lensFlareSystem`.
  57990. * It controls one of the indiviual texture used in the effect.
  57991. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57992. */
  57993. export class LensFlare {
  57994. /**
  57995. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57996. */
  57997. size: number;
  57998. /**
  57999. * 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.
  58000. */
  58001. position: number;
  58002. /**
  58003. * Define the lens color.
  58004. */
  58005. color: Color3;
  58006. /**
  58007. * Define the lens texture.
  58008. */
  58009. texture: Nullable<Texture>;
  58010. /**
  58011. * Define the alpha mode to render this particular lens.
  58012. */
  58013. alphaMode: number;
  58014. private _system;
  58015. /**
  58016. * Creates a new Lens Flare.
  58017. * This represents one of the lens effect in a `lensFlareSystem`.
  58018. * It controls one of the indiviual texture used in the effect.
  58019. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58020. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  58021. * @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.
  58022. * @param color Define the lens color
  58023. * @param imgUrl Define the lens texture url
  58024. * @param system Define the `lensFlareSystem` this flare is part of
  58025. * @returns The newly created Lens Flare
  58026. */
  58027. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  58028. /**
  58029. * Instantiates a new Lens Flare.
  58030. * This represents one of the lens effect in a `lensFlareSystem`.
  58031. * It controls one of the indiviual texture used in the effect.
  58032. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58033. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  58034. * @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.
  58035. * @param color Define the lens color
  58036. * @param imgUrl Define the lens texture url
  58037. * @param system Define the `lensFlareSystem` this flare is part of
  58038. */
  58039. constructor(
  58040. /**
  58041. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  58042. */
  58043. size: number,
  58044. /**
  58045. * 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.
  58046. */
  58047. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  58048. /**
  58049. * Dispose and release the lens flare with its associated resources.
  58050. */
  58051. dispose(): void;
  58052. }
  58053. }
  58054. declare module BABYLON {
  58055. interface AbstractScene {
  58056. /**
  58057. * The list of lens flare system added to the scene
  58058. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58059. */
  58060. lensFlareSystems: Array<LensFlareSystem>;
  58061. /**
  58062. * Removes the given lens flare system from this scene.
  58063. * @param toRemove The lens flare system to remove
  58064. * @returns The index of the removed lens flare system
  58065. */
  58066. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  58067. /**
  58068. * Adds the given lens flare system to this scene
  58069. * @param newLensFlareSystem The lens flare system to add
  58070. */
  58071. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  58072. /**
  58073. * Gets a lens flare system using its name
  58074. * @param name defines the name to look for
  58075. * @returns the lens flare system or null if not found
  58076. */
  58077. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  58078. /**
  58079. * Gets a lens flare system using its id
  58080. * @param id defines the id to look for
  58081. * @returns the lens flare system or null if not found
  58082. */
  58083. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  58084. }
  58085. /**
  58086. * Defines the lens flare scene component responsible to manage any lens flares
  58087. * in a given scene.
  58088. */
  58089. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  58090. /**
  58091. * The component name helpfull to identify the component in the list of scene components.
  58092. */
  58093. readonly name: string;
  58094. /**
  58095. * The scene the component belongs to.
  58096. */
  58097. scene: Scene;
  58098. /**
  58099. * Creates a new instance of the component for the given scene
  58100. * @param scene Defines the scene to register the component in
  58101. */
  58102. constructor(scene: Scene);
  58103. /**
  58104. * Registers the component in a given scene
  58105. */
  58106. register(): void;
  58107. /**
  58108. * Rebuilds the elements related to this component in case of
  58109. * context lost for instance.
  58110. */
  58111. rebuild(): void;
  58112. /**
  58113. * Adds all the elements from the container to the scene
  58114. * @param container the container holding the elements
  58115. */
  58116. addFromContainer(container: AbstractScene): void;
  58117. /**
  58118. * Removes all the elements in the container from the scene
  58119. * @param container contains the elements to remove
  58120. * @param dispose if the removed element should be disposed (default: false)
  58121. */
  58122. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58123. /**
  58124. * Serializes the component data to the specified json object
  58125. * @param serializationObject The object to serialize to
  58126. */
  58127. serialize(serializationObject: any): void;
  58128. /**
  58129. * Disposes the component and the associated ressources.
  58130. */
  58131. dispose(): void;
  58132. private _draw;
  58133. }
  58134. }
  58135. declare module BABYLON {
  58136. /** @hidden */
  58137. export var depthPixelShader: {
  58138. name: string;
  58139. shader: string;
  58140. };
  58141. }
  58142. declare module BABYLON {
  58143. /** @hidden */
  58144. export var depthVertexShader: {
  58145. name: string;
  58146. shader: string;
  58147. };
  58148. }
  58149. declare module BABYLON {
  58150. /**
  58151. * This represents a depth renderer in Babylon.
  58152. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  58153. */
  58154. export class DepthRenderer {
  58155. private _scene;
  58156. private _depthMap;
  58157. private _effect;
  58158. private readonly _storeNonLinearDepth;
  58159. private readonly _clearColor;
  58160. /** Get if the depth renderer is using packed depth or not */
  58161. readonly isPacked: boolean;
  58162. private _cachedDefines;
  58163. private _camera;
  58164. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  58165. enabled: boolean;
  58166. /**
  58167. * Specifiess that the depth renderer will only be used within
  58168. * the camera it is created for.
  58169. * This can help forcing its rendering during the camera processing.
  58170. */
  58171. useOnlyInActiveCamera: boolean;
  58172. /** @hidden */
  58173. static _SceneComponentInitialization: (scene: Scene) => void;
  58174. /**
  58175. * Instantiates a depth renderer
  58176. * @param scene The scene the renderer belongs to
  58177. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  58178. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  58179. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  58180. */
  58181. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  58182. /**
  58183. * Creates the depth rendering effect and checks if the effect is ready.
  58184. * @param subMesh The submesh to be used to render the depth map of
  58185. * @param useInstances If multiple world instances should be used
  58186. * @returns if the depth renderer is ready to render the depth map
  58187. */
  58188. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58189. /**
  58190. * Gets the texture which the depth map will be written to.
  58191. * @returns The depth map texture
  58192. */
  58193. getDepthMap(): RenderTargetTexture;
  58194. /**
  58195. * Disposes of the depth renderer.
  58196. */
  58197. dispose(): void;
  58198. }
  58199. }
  58200. declare module BABYLON {
  58201. /** @hidden */
  58202. export var minmaxReduxPixelShader: {
  58203. name: string;
  58204. shader: string;
  58205. };
  58206. }
  58207. declare module BABYLON {
  58208. /**
  58209. * This class computes a min/max reduction from a texture: it means it computes the minimum
  58210. * and maximum values from all values of the texture.
  58211. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  58212. * The source values are read from the red channel of the texture.
  58213. */
  58214. export class MinMaxReducer {
  58215. /**
  58216. * Observable triggered when the computation has been performed
  58217. */
  58218. onAfterReductionPerformed: Observable<{
  58219. min: number;
  58220. max: number;
  58221. }>;
  58222. protected _camera: Camera;
  58223. protected _sourceTexture: Nullable<RenderTargetTexture>;
  58224. protected _reductionSteps: Nullable<Array<PostProcess>>;
  58225. protected _postProcessManager: PostProcessManager;
  58226. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  58227. protected _forceFullscreenViewport: boolean;
  58228. /**
  58229. * Creates a min/max reducer
  58230. * @param camera The camera to use for the post processes
  58231. */
  58232. constructor(camera: Camera);
  58233. /**
  58234. * Gets the texture used to read the values from.
  58235. */
  58236. get sourceTexture(): Nullable<RenderTargetTexture>;
  58237. /**
  58238. * Sets the source texture to read the values from.
  58239. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  58240. * because in such textures '1' value must not be taken into account to compute the maximum
  58241. * as this value is used to clear the texture.
  58242. * Note that the computation is not activated by calling this function, you must call activate() for that!
  58243. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  58244. * @param depthRedux Indicates if the texture is a depth texture or not
  58245. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  58246. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  58247. */
  58248. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  58249. /**
  58250. * Defines the refresh rate of the computation.
  58251. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  58252. */
  58253. get refreshRate(): number;
  58254. set refreshRate(value: number);
  58255. protected _activated: boolean;
  58256. /**
  58257. * Gets the activation status of the reducer
  58258. */
  58259. get activated(): boolean;
  58260. /**
  58261. * Activates the reduction computation.
  58262. * When activated, the observers registered in onAfterReductionPerformed are
  58263. * called after the compuation is performed
  58264. */
  58265. activate(): void;
  58266. /**
  58267. * Deactivates the reduction computation.
  58268. */
  58269. deactivate(): void;
  58270. /**
  58271. * Disposes the min/max reducer
  58272. * @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.
  58273. */
  58274. dispose(disposeAll?: boolean): void;
  58275. }
  58276. }
  58277. declare module BABYLON {
  58278. /**
  58279. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  58280. */
  58281. export class DepthReducer extends MinMaxReducer {
  58282. private _depthRenderer;
  58283. private _depthRendererId;
  58284. /**
  58285. * Gets the depth renderer used for the computation.
  58286. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  58287. */
  58288. get depthRenderer(): Nullable<DepthRenderer>;
  58289. /**
  58290. * Creates a depth reducer
  58291. * @param camera The camera used to render the depth texture
  58292. */
  58293. constructor(camera: Camera);
  58294. /**
  58295. * Sets the depth renderer to use to generate the depth map
  58296. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  58297. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  58298. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  58299. */
  58300. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  58301. /** @hidden */
  58302. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  58303. /**
  58304. * Activates the reduction computation.
  58305. * When activated, the observers registered in onAfterReductionPerformed are
  58306. * called after the compuation is performed
  58307. */
  58308. activate(): void;
  58309. /**
  58310. * Deactivates the reduction computation.
  58311. */
  58312. deactivate(): void;
  58313. /**
  58314. * Disposes the depth reducer
  58315. * @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.
  58316. */
  58317. dispose(disposeAll?: boolean): void;
  58318. }
  58319. }
  58320. declare module BABYLON {
  58321. /**
  58322. * A CSM implementation allowing casting shadows on large scenes.
  58323. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  58324. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  58325. */
  58326. export class CascadedShadowGenerator extends ShadowGenerator {
  58327. private static readonly frustumCornersNDCSpace;
  58328. /**
  58329. * Name of the CSM class
  58330. */
  58331. static CLASSNAME: string;
  58332. /**
  58333. * Defines the default number of cascades used by the CSM.
  58334. */
  58335. static readonly DEFAULT_CASCADES_COUNT: number;
  58336. /**
  58337. * Defines the minimum number of cascades used by the CSM.
  58338. */
  58339. static readonly MIN_CASCADES_COUNT: number;
  58340. /**
  58341. * Defines the maximum number of cascades used by the CSM.
  58342. */
  58343. static readonly MAX_CASCADES_COUNT: number;
  58344. protected _validateFilter(filter: number): number;
  58345. /**
  58346. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  58347. */
  58348. penumbraDarkness: number;
  58349. private _numCascades;
  58350. /**
  58351. * Gets or set the number of cascades used by the CSM.
  58352. */
  58353. get numCascades(): number;
  58354. set numCascades(value: number);
  58355. /**
  58356. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  58357. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  58358. */
  58359. stabilizeCascades: boolean;
  58360. private _freezeShadowCastersBoundingInfo;
  58361. private _freezeShadowCastersBoundingInfoObservable;
  58362. /**
  58363. * Enables or disables the shadow casters bounding info computation.
  58364. * If your shadow casters don't move, you can disable this feature.
  58365. * If it is enabled, the bounding box computation is done every frame.
  58366. */
  58367. get freezeShadowCastersBoundingInfo(): boolean;
  58368. set freezeShadowCastersBoundingInfo(freeze: boolean);
  58369. private _scbiMin;
  58370. private _scbiMax;
  58371. protected _computeShadowCastersBoundingInfo(): void;
  58372. protected _shadowCastersBoundingInfo: BoundingInfo;
  58373. /**
  58374. * Gets or sets the shadow casters bounding info.
  58375. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  58376. * so that the system won't overwrite the bounds you provide
  58377. */
  58378. get shadowCastersBoundingInfo(): BoundingInfo;
  58379. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  58380. protected _breaksAreDirty: boolean;
  58381. protected _minDistance: number;
  58382. protected _maxDistance: number;
  58383. /**
  58384. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  58385. *
  58386. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  58387. * If you don't know these values, simply leave them to their defaults and don't call this function.
  58388. * @param min minimal distance for the breaks (default to 0.)
  58389. * @param max maximal distance for the breaks (default to 1.)
  58390. */
  58391. setMinMaxDistance(min: number, max: number): void;
  58392. /** Gets the minimal distance used in the cascade break computation */
  58393. get minDistance(): number;
  58394. /** Gets the maximal distance used in the cascade break computation */
  58395. get maxDistance(): number;
  58396. /**
  58397. * Gets the class name of that object
  58398. * @returns "CascadedShadowGenerator"
  58399. */
  58400. getClassName(): string;
  58401. private _cascadeMinExtents;
  58402. private _cascadeMaxExtents;
  58403. /**
  58404. * Gets a cascade minimum extents
  58405. * @param cascadeIndex index of the cascade
  58406. * @returns the minimum cascade extents
  58407. */
  58408. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  58409. /**
  58410. * Gets a cascade maximum extents
  58411. * @param cascadeIndex index of the cascade
  58412. * @returns the maximum cascade extents
  58413. */
  58414. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  58415. private _cascades;
  58416. private _currentLayer;
  58417. private _viewSpaceFrustumsZ;
  58418. private _viewMatrices;
  58419. private _projectionMatrices;
  58420. private _transformMatrices;
  58421. private _transformMatricesAsArray;
  58422. private _frustumLengths;
  58423. private _lightSizeUVCorrection;
  58424. private _depthCorrection;
  58425. private _frustumCornersWorldSpace;
  58426. private _frustumCenter;
  58427. private _shadowCameraPos;
  58428. private _shadowMaxZ;
  58429. /**
  58430. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  58431. * It defaults to camera.maxZ
  58432. */
  58433. get shadowMaxZ(): number;
  58434. /**
  58435. * Sets the shadow max z distance.
  58436. */
  58437. set shadowMaxZ(value: number);
  58438. protected _debug: boolean;
  58439. /**
  58440. * Gets or sets the debug flag.
  58441. * When enabled, the cascades are materialized by different colors on the screen.
  58442. */
  58443. get debug(): boolean;
  58444. set debug(dbg: boolean);
  58445. private _depthClamp;
  58446. /**
  58447. * Gets or sets the depth clamping value.
  58448. *
  58449. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  58450. * to account for the shadow casters far away.
  58451. *
  58452. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  58453. */
  58454. get depthClamp(): boolean;
  58455. set depthClamp(value: boolean);
  58456. private _cascadeBlendPercentage;
  58457. /**
  58458. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  58459. * It defaults to 0.1 (10% blending).
  58460. */
  58461. get cascadeBlendPercentage(): number;
  58462. set cascadeBlendPercentage(value: number);
  58463. private _lambda;
  58464. /**
  58465. * Gets or set the lambda parameter.
  58466. * This parameter is used to split the camera frustum and create the cascades.
  58467. * 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.
  58468. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  58469. */
  58470. get lambda(): number;
  58471. set lambda(value: number);
  58472. /**
  58473. * Gets the view matrix corresponding to a given cascade
  58474. * @param cascadeNum cascade to retrieve the view matrix from
  58475. * @returns the cascade view matrix
  58476. */
  58477. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  58478. /**
  58479. * Gets the projection matrix corresponding to a given cascade
  58480. * @param cascadeNum cascade to retrieve the projection matrix from
  58481. * @returns the cascade projection matrix
  58482. */
  58483. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  58484. /**
  58485. * Gets the transformation matrix corresponding to a given cascade
  58486. * @param cascadeNum cascade to retrieve the transformation matrix from
  58487. * @returns the cascade transformation matrix
  58488. */
  58489. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  58490. private _depthRenderer;
  58491. /**
  58492. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  58493. *
  58494. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  58495. *
  58496. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  58497. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  58498. * @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
  58499. */
  58500. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  58501. private _depthReducer;
  58502. private _autoCalcDepthBounds;
  58503. /**
  58504. * Gets or sets the autoCalcDepthBounds property.
  58505. *
  58506. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  58507. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  58508. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  58509. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  58510. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  58511. */
  58512. get autoCalcDepthBounds(): boolean;
  58513. set autoCalcDepthBounds(value: boolean);
  58514. /**
  58515. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  58516. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  58517. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  58518. * for setting the refresh rate on the renderer yourself!
  58519. */
  58520. get autoCalcDepthBoundsRefreshRate(): number;
  58521. set autoCalcDepthBoundsRefreshRate(value: number);
  58522. /**
  58523. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  58524. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  58525. * you change the camera near/far planes!
  58526. */
  58527. splitFrustum(): void;
  58528. private _splitFrustum;
  58529. private _computeMatrices;
  58530. private _computeFrustumInWorldSpace;
  58531. private _computeCascadeFrustum;
  58532. /**
  58533. * Support test.
  58534. */
  58535. static get IsSupported(): boolean;
  58536. /** @hidden */
  58537. static _SceneComponentInitialization: (scene: Scene) => void;
  58538. /**
  58539. * Creates a Cascaded Shadow Generator object.
  58540. * A ShadowGenerator is the required tool to use the shadows.
  58541. * Each directional light casting shadows needs to use its own ShadowGenerator.
  58542. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  58543. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  58544. * @param light The directional light object generating the shadows.
  58545. * @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.
  58546. */
  58547. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  58548. protected _initializeGenerator(): void;
  58549. protected _createTargetRenderTexture(): void;
  58550. protected _initializeShadowMap(): void;
  58551. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  58552. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  58553. /**
  58554. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  58555. * @param defines Defines of the material we want to update
  58556. * @param lightIndex Index of the light in the enabled light list of the material
  58557. */
  58558. prepareDefines(defines: any, lightIndex: number): void;
  58559. /**
  58560. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  58561. * defined in the generator but impacting the effect).
  58562. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  58563. * @param effect The effect we are binfing the information for
  58564. */
  58565. bindShadowLight(lightIndex: string, effect: Effect): void;
  58566. /**
  58567. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  58568. * (eq to view projection * shadow projection matrices)
  58569. * @returns The transform matrix used to create the shadow map
  58570. */
  58571. getTransformMatrix(): Matrix;
  58572. /**
  58573. * Disposes the ShadowGenerator.
  58574. * Returns nothing.
  58575. */
  58576. dispose(): void;
  58577. /**
  58578. * Serializes the shadow generator setup to a json object.
  58579. * @returns The serialized JSON object
  58580. */
  58581. serialize(): any;
  58582. /**
  58583. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  58584. * @param parsedShadowGenerator The JSON object to parse
  58585. * @param scene The scene to create the shadow map for
  58586. * @returns The parsed shadow generator
  58587. */
  58588. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  58589. }
  58590. }
  58591. declare module BABYLON {
  58592. /**
  58593. * Defines the shadow generator component responsible to manage any shadow generators
  58594. * in a given scene.
  58595. */
  58596. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  58597. /**
  58598. * The component name helpfull to identify the component in the list of scene components.
  58599. */
  58600. readonly name: string;
  58601. /**
  58602. * The scene the component belongs to.
  58603. */
  58604. scene: Scene;
  58605. /**
  58606. * Creates a new instance of the component for the given scene
  58607. * @param scene Defines the scene to register the component in
  58608. */
  58609. constructor(scene: Scene);
  58610. /**
  58611. * Registers the component in a given scene
  58612. */
  58613. register(): void;
  58614. /**
  58615. * Rebuilds the elements related to this component in case of
  58616. * context lost for instance.
  58617. */
  58618. rebuild(): void;
  58619. /**
  58620. * Serializes the component data to the specified json object
  58621. * @param serializationObject The object to serialize to
  58622. */
  58623. serialize(serializationObject: any): void;
  58624. /**
  58625. * Adds all the elements from the container to the scene
  58626. * @param container the container holding the elements
  58627. */
  58628. addFromContainer(container: AbstractScene): void;
  58629. /**
  58630. * Removes all the elements in the container from the scene
  58631. * @param container contains the elements to remove
  58632. * @param dispose if the removed element should be disposed (default: false)
  58633. */
  58634. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58635. /**
  58636. * Rebuilds the elements related to this component in case of
  58637. * context lost for instance.
  58638. */
  58639. dispose(): void;
  58640. private _gatherRenderTargets;
  58641. }
  58642. }
  58643. declare module BABYLON {
  58644. /**
  58645. * A point light is a light defined by an unique point in world space.
  58646. * The light is emitted in every direction from this point.
  58647. * A good example of a point light is a standard light bulb.
  58648. * Documentation: https://doc.babylonjs.com/babylon101/lights
  58649. */
  58650. export class PointLight extends ShadowLight {
  58651. private _shadowAngle;
  58652. /**
  58653. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58654. * This specifies what angle the shadow will use to be created.
  58655. *
  58656. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58657. */
  58658. get shadowAngle(): number;
  58659. /**
  58660. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58661. * This specifies what angle the shadow will use to be created.
  58662. *
  58663. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58664. */
  58665. set shadowAngle(value: number);
  58666. /**
  58667. * Gets the direction if it has been set.
  58668. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58669. */
  58670. get direction(): Vector3;
  58671. /**
  58672. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58673. */
  58674. set direction(value: Vector3);
  58675. /**
  58676. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  58677. * A PointLight emits the light in every direction.
  58678. * It can cast shadows.
  58679. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  58680. * ```javascript
  58681. * var pointLight = new PointLight("pl", camera.position, scene);
  58682. * ```
  58683. * Documentation : https://doc.babylonjs.com/babylon101/lights
  58684. * @param name The light friendly name
  58685. * @param position The position of the point light in the scene
  58686. * @param scene The scene the lights belongs to
  58687. */
  58688. constructor(name: string, position: Vector3, scene: Scene);
  58689. /**
  58690. * Returns the string "PointLight"
  58691. * @returns the class name
  58692. */
  58693. getClassName(): string;
  58694. /**
  58695. * Returns the integer 0.
  58696. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  58697. */
  58698. getTypeID(): number;
  58699. /**
  58700. * Specifies wether or not the shadowmap should be a cube texture.
  58701. * @returns true if the shadowmap needs to be a cube texture.
  58702. */
  58703. needCube(): boolean;
  58704. /**
  58705. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  58706. * @param faceIndex The index of the face we are computed the direction to generate shadow
  58707. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  58708. */
  58709. getShadowDirection(faceIndex?: number): Vector3;
  58710. /**
  58711. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  58712. * - fov = PI / 2
  58713. * - aspect ratio : 1.0
  58714. * - z-near and far equal to the active camera minZ and maxZ.
  58715. * Returns the PointLight.
  58716. */
  58717. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  58718. protected _buildUniformLayout(): void;
  58719. /**
  58720. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  58721. * @param effect The effect to update
  58722. * @param lightIndex The index of the light in the effect to update
  58723. * @returns The point light
  58724. */
  58725. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  58726. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  58727. /**
  58728. * Prepares the list of defines specific to the light type.
  58729. * @param defines the list of defines
  58730. * @param lightIndex defines the index of the light for the effect
  58731. */
  58732. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  58733. }
  58734. }
  58735. declare module BABYLON {
  58736. /**
  58737. * Header information of HDR texture files.
  58738. */
  58739. export interface HDRInfo {
  58740. /**
  58741. * The height of the texture in pixels.
  58742. */
  58743. height: number;
  58744. /**
  58745. * The width of the texture in pixels.
  58746. */
  58747. width: number;
  58748. /**
  58749. * The index of the beginning of the data in the binary file.
  58750. */
  58751. dataPosition: number;
  58752. }
  58753. /**
  58754. * This groups tools to convert HDR texture to native colors array.
  58755. */
  58756. export class HDRTools {
  58757. private static Ldexp;
  58758. private static Rgbe2float;
  58759. private static readStringLine;
  58760. /**
  58761. * Reads header information from an RGBE texture stored in a native array.
  58762. * More information on this format are available here:
  58763. * https://en.wikipedia.org/wiki/RGBE_image_format
  58764. *
  58765. * @param uint8array The binary file stored in native array.
  58766. * @return The header information.
  58767. */
  58768. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  58769. /**
  58770. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  58771. * This RGBE texture needs to store the information as a panorama.
  58772. *
  58773. * More information on this format are available here:
  58774. * https://en.wikipedia.org/wiki/RGBE_image_format
  58775. *
  58776. * @param buffer The binary file stored in an array buffer.
  58777. * @param size The expected size of the extracted cubemap.
  58778. * @return The Cube Map information.
  58779. */
  58780. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  58781. /**
  58782. * Returns the pixels data extracted from an RGBE texture.
  58783. * This pixels will be stored left to right up to down in the R G B order in one array.
  58784. *
  58785. * More information on this format are available here:
  58786. * https://en.wikipedia.org/wiki/RGBE_image_format
  58787. *
  58788. * @param uint8array The binary file stored in an array buffer.
  58789. * @param hdrInfo The header information of the file.
  58790. * @return The pixels data in RGB right to left up to down order.
  58791. */
  58792. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  58793. private static RGBE_ReadPixels_RLE;
  58794. }
  58795. }
  58796. declare module BABYLON {
  58797. /**
  58798. * Effect Render Options
  58799. */
  58800. export interface IEffectRendererOptions {
  58801. /**
  58802. * Defines the vertices positions.
  58803. */
  58804. positions?: number[];
  58805. /**
  58806. * Defines the indices.
  58807. */
  58808. indices?: number[];
  58809. }
  58810. /**
  58811. * Helper class to render one or more effects.
  58812. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  58813. */
  58814. export class EffectRenderer {
  58815. private engine;
  58816. private static _DefaultOptions;
  58817. private _vertexBuffers;
  58818. private _indexBuffer;
  58819. private _fullscreenViewport;
  58820. /**
  58821. * Creates an effect renderer
  58822. * @param engine the engine to use for rendering
  58823. * @param options defines the options of the effect renderer
  58824. */
  58825. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  58826. /**
  58827. * Sets the current viewport in normalized coordinates 0-1
  58828. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58829. */
  58830. setViewport(viewport?: Viewport): void;
  58831. /**
  58832. * Binds the embedded attributes buffer to the effect.
  58833. * @param effect Defines the effect to bind the attributes for
  58834. */
  58835. bindBuffers(effect: Effect): void;
  58836. /**
  58837. * Sets the current effect wrapper to use during draw.
  58838. * The effect needs to be ready before calling this api.
  58839. * This also sets the default full screen position attribute.
  58840. * @param effectWrapper Defines the effect to draw with
  58841. */
  58842. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58843. /**
  58844. * Restores engine states
  58845. */
  58846. restoreStates(): void;
  58847. /**
  58848. * Draws a full screen quad.
  58849. */
  58850. draw(): void;
  58851. private isRenderTargetTexture;
  58852. /**
  58853. * renders one or more effects to a specified texture
  58854. * @param effectWrapper the effect to renderer
  58855. * @param outputTexture texture to draw to, if null it will render to the screen.
  58856. */
  58857. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  58858. /**
  58859. * Disposes of the effect renderer
  58860. */
  58861. dispose(): void;
  58862. }
  58863. /**
  58864. * Options to create an EffectWrapper
  58865. */
  58866. interface EffectWrapperCreationOptions {
  58867. /**
  58868. * Engine to use to create the effect
  58869. */
  58870. engine: ThinEngine;
  58871. /**
  58872. * Fragment shader for the effect
  58873. */
  58874. fragmentShader: string;
  58875. /**
  58876. * Use the shader store instead of direct source code
  58877. */
  58878. useShaderStore?: boolean;
  58879. /**
  58880. * Vertex shader for the effect
  58881. */
  58882. vertexShader?: string;
  58883. /**
  58884. * Attributes to use in the shader
  58885. */
  58886. attributeNames?: Array<string>;
  58887. /**
  58888. * Uniforms to use in the shader
  58889. */
  58890. uniformNames?: Array<string>;
  58891. /**
  58892. * Texture sampler names to use in the shader
  58893. */
  58894. samplerNames?: Array<string>;
  58895. /**
  58896. * Defines to use in the shader
  58897. */
  58898. defines?: Array<string>;
  58899. /**
  58900. * Callback when effect is compiled
  58901. */
  58902. onCompiled?: Nullable<(effect: Effect) => void>;
  58903. /**
  58904. * The friendly name of the effect displayed in Spector.
  58905. */
  58906. name?: string;
  58907. }
  58908. /**
  58909. * Wraps an effect to be used for rendering
  58910. */
  58911. export class EffectWrapper {
  58912. /**
  58913. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58914. */
  58915. onApplyObservable: Observable<{}>;
  58916. /**
  58917. * The underlying effect
  58918. */
  58919. effect: Effect;
  58920. /**
  58921. * Creates an effect to be renderer
  58922. * @param creationOptions options to create the effect
  58923. */
  58924. constructor(creationOptions: EffectWrapperCreationOptions);
  58925. /**
  58926. * Disposes of the effect wrapper
  58927. */
  58928. dispose(): void;
  58929. }
  58930. }
  58931. declare module BABYLON {
  58932. /** @hidden */
  58933. export var hdrFilteringVertexShader: {
  58934. name: string;
  58935. shader: string;
  58936. };
  58937. }
  58938. declare module BABYLON {
  58939. /** @hidden */
  58940. export var hdrFilteringPixelShader: {
  58941. name: string;
  58942. shader: string;
  58943. };
  58944. }
  58945. declare module BABYLON {
  58946. /**
  58947. * Options for texture filtering
  58948. */
  58949. interface IHDRFilteringOptions {
  58950. /**
  58951. * Scales pixel intensity for the input HDR map.
  58952. */
  58953. hdrScale?: number;
  58954. /**
  58955. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  58956. */
  58957. quality?: number;
  58958. }
  58959. /**
  58960. * Filters HDR maps to get correct renderings of PBR reflections
  58961. */
  58962. export class HDRFiltering {
  58963. private _engine;
  58964. private _effectRenderer;
  58965. private _effectWrapper;
  58966. private _lodGenerationOffset;
  58967. private _lodGenerationScale;
  58968. /**
  58969. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  58970. * you care about baking speed.
  58971. */
  58972. quality: number;
  58973. /**
  58974. * Scales pixel intensity for the input HDR map.
  58975. */
  58976. hdrScale: number;
  58977. /**
  58978. * Instantiates HDR filter for reflection maps
  58979. *
  58980. * @param engine Thin engine
  58981. * @param options Options
  58982. */
  58983. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  58984. private _createRenderTarget;
  58985. private _prefilterInternal;
  58986. private _createEffect;
  58987. /**
  58988. * Get a value indicating if the filter is ready to be used
  58989. * @param texture Texture to filter
  58990. * @returns true if the filter is ready
  58991. */
  58992. isReady(texture: BaseTexture): boolean;
  58993. /**
  58994. * Prefilters a cube texture to have mipmap levels representing roughness values.
  58995. * Prefiltering will be invoked at the end of next rendering pass.
  58996. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  58997. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  58998. * @param texture Texture to filter
  58999. * @param onFinished Callback when filtering is done
  59000. * @return Promise called when prefiltering is done
  59001. */
  59002. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  59003. }
  59004. }
  59005. declare module BABYLON {
  59006. /**
  59007. * This represents a texture coming from an HDR input.
  59008. *
  59009. * The only supported format is currently panorama picture stored in RGBE format.
  59010. * Example of such files can be found on HDRLib: http://hdrlib.com/
  59011. */
  59012. export class HDRCubeTexture extends BaseTexture {
  59013. private static _facesMapping;
  59014. private _generateHarmonics;
  59015. private _noMipmap;
  59016. private _prefilterOnLoad;
  59017. private _textureMatrix;
  59018. private _size;
  59019. private _onLoad;
  59020. private _onError;
  59021. /**
  59022. * The texture URL.
  59023. */
  59024. url: string;
  59025. /**
  59026. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  59027. */
  59028. coordinatesMode: number;
  59029. protected _isBlocking: boolean;
  59030. /**
  59031. * Sets wether or not the texture is blocking during loading.
  59032. */
  59033. set isBlocking(value: boolean);
  59034. /**
  59035. * Gets wether or not the texture is blocking during loading.
  59036. */
  59037. get isBlocking(): boolean;
  59038. protected _rotationY: number;
  59039. /**
  59040. * Sets texture matrix rotation angle around Y axis in radians.
  59041. */
  59042. set rotationY(value: number);
  59043. /**
  59044. * Gets texture matrix rotation angle around Y axis radians.
  59045. */
  59046. get rotationY(): number;
  59047. /**
  59048. * Gets or sets the center of the bounding box associated with the cube texture
  59049. * It must define where the camera used to render the texture was set
  59050. */
  59051. boundingBoxPosition: Vector3;
  59052. private _boundingBoxSize;
  59053. /**
  59054. * Gets or sets the size of the bounding box associated with the cube texture
  59055. * When defined, the cubemap will switch to local mode
  59056. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  59057. * @example https://www.babylonjs-playground.com/#RNASML
  59058. */
  59059. set boundingBoxSize(value: Vector3);
  59060. get boundingBoxSize(): Vector3;
  59061. /**
  59062. * Instantiates an HDRTexture from the following parameters.
  59063. *
  59064. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  59065. * @param sceneOrEngine The scene or engine the texture will be used in
  59066. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  59067. * @param noMipmap Forces to not generate the mipmap if true
  59068. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  59069. * @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)
  59070. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  59071. */
  59072. 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>);
  59073. /**
  59074. * Get the current class name of the texture useful for serialization or dynamic coding.
  59075. * @returns "HDRCubeTexture"
  59076. */
  59077. getClassName(): string;
  59078. /**
  59079. * Occurs when the file is raw .hdr file.
  59080. */
  59081. private loadTexture;
  59082. clone(): HDRCubeTexture;
  59083. delayLoad(): void;
  59084. /**
  59085. * Get the texture reflection matrix used to rotate/transform the reflection.
  59086. * @returns the reflection matrix
  59087. */
  59088. getReflectionTextureMatrix(): Matrix;
  59089. /**
  59090. * Set the texture reflection matrix used to rotate/transform the reflection.
  59091. * @param value Define the reflection matrix to set
  59092. */
  59093. setReflectionTextureMatrix(value: Matrix): void;
  59094. /**
  59095. * Parses a JSON representation of an HDR Texture in order to create the texture
  59096. * @param parsedTexture Define the JSON representation
  59097. * @param scene Define the scene the texture should be created in
  59098. * @param rootUrl Define the root url in case we need to load relative dependencies
  59099. * @returns the newly created texture after parsing
  59100. */
  59101. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  59102. serialize(): any;
  59103. }
  59104. }
  59105. declare module BABYLON {
  59106. /**
  59107. * Class used to control physics engine
  59108. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  59109. */
  59110. export class PhysicsEngine implements IPhysicsEngine {
  59111. private _physicsPlugin;
  59112. /**
  59113. * Global value used to control the smallest number supported by the simulation
  59114. */
  59115. static Epsilon: number;
  59116. private _impostors;
  59117. private _joints;
  59118. private _subTimeStep;
  59119. /**
  59120. * Gets the gravity vector used by the simulation
  59121. */
  59122. gravity: Vector3;
  59123. /**
  59124. * Factory used to create the default physics plugin.
  59125. * @returns The default physics plugin
  59126. */
  59127. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  59128. /**
  59129. * Creates a new Physics Engine
  59130. * @param gravity defines the gravity vector used by the simulation
  59131. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  59132. */
  59133. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  59134. /**
  59135. * Sets the gravity vector used by the simulation
  59136. * @param gravity defines the gravity vector to use
  59137. */
  59138. setGravity(gravity: Vector3): void;
  59139. /**
  59140. * Set the time step of the physics engine.
  59141. * Default is 1/60.
  59142. * To slow it down, enter 1/600 for example.
  59143. * To speed it up, 1/30
  59144. * @param newTimeStep defines the new timestep to apply to this world.
  59145. */
  59146. setTimeStep(newTimeStep?: number): void;
  59147. /**
  59148. * Get the time step of the physics engine.
  59149. * @returns the current time step
  59150. */
  59151. getTimeStep(): number;
  59152. /**
  59153. * Set the sub time step of the physics engine.
  59154. * Default is 0 meaning there is no sub steps
  59155. * To increase physics resolution precision, set a small value (like 1 ms)
  59156. * @param subTimeStep defines the new sub timestep used for physics resolution.
  59157. */
  59158. setSubTimeStep(subTimeStep?: number): void;
  59159. /**
  59160. * Get the sub time step of the physics engine.
  59161. * @returns the current sub time step
  59162. */
  59163. getSubTimeStep(): number;
  59164. /**
  59165. * Release all resources
  59166. */
  59167. dispose(): void;
  59168. /**
  59169. * Gets the name of the current physics plugin
  59170. * @returns the name of the plugin
  59171. */
  59172. getPhysicsPluginName(): string;
  59173. /**
  59174. * Adding a new impostor for the impostor tracking.
  59175. * This will be done by the impostor itself.
  59176. * @param impostor the impostor to add
  59177. */
  59178. addImpostor(impostor: PhysicsImpostor): void;
  59179. /**
  59180. * Remove an impostor from the engine.
  59181. * This impostor and its mesh will not longer be updated by the physics engine.
  59182. * @param impostor the impostor to remove
  59183. */
  59184. removeImpostor(impostor: PhysicsImpostor): void;
  59185. /**
  59186. * Add a joint to the physics engine
  59187. * @param mainImpostor defines the main impostor to which the joint is added.
  59188. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  59189. * @param joint defines the joint that will connect both impostors.
  59190. */
  59191. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  59192. /**
  59193. * Removes a joint from the simulation
  59194. * @param mainImpostor defines the impostor used with the joint
  59195. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  59196. * @param joint defines the joint to remove
  59197. */
  59198. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  59199. /**
  59200. * Called by the scene. No need to call it.
  59201. * @param delta defines the timespam between frames
  59202. */
  59203. _step(delta: number): void;
  59204. /**
  59205. * Gets the current plugin used to run the simulation
  59206. * @returns current plugin
  59207. */
  59208. getPhysicsPlugin(): IPhysicsEnginePlugin;
  59209. /**
  59210. * Gets the list of physic impostors
  59211. * @returns an array of PhysicsImpostor
  59212. */
  59213. getImpostors(): Array<PhysicsImpostor>;
  59214. /**
  59215. * Gets the impostor for a physics enabled object
  59216. * @param object defines the object impersonated by the impostor
  59217. * @returns the PhysicsImpostor or null if not found
  59218. */
  59219. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  59220. /**
  59221. * Gets the impostor for a physics body object
  59222. * @param body defines physics body used by the impostor
  59223. * @returns the PhysicsImpostor or null if not found
  59224. */
  59225. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  59226. /**
  59227. * Does a raycast in the physics world
  59228. * @param from when should the ray start?
  59229. * @param to when should the ray end?
  59230. * @returns PhysicsRaycastResult
  59231. */
  59232. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59233. }
  59234. }
  59235. declare module BABYLON {
  59236. /** @hidden */
  59237. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  59238. private _useDeltaForWorldStep;
  59239. world: any;
  59240. name: string;
  59241. private _physicsMaterials;
  59242. private _fixedTimeStep;
  59243. private _cannonRaycastResult;
  59244. private _raycastResult;
  59245. private _physicsBodysToRemoveAfterStep;
  59246. private _firstFrame;
  59247. BJSCANNON: any;
  59248. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  59249. setGravity(gravity: Vector3): void;
  59250. setTimeStep(timeStep: number): void;
  59251. getTimeStep(): number;
  59252. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59253. private _removeMarkedPhysicsBodiesFromWorld;
  59254. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59255. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59256. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59257. private _processChildMeshes;
  59258. removePhysicsBody(impostor: PhysicsImpostor): void;
  59259. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59260. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59261. private _addMaterial;
  59262. private _checkWithEpsilon;
  59263. private _createShape;
  59264. private _createHeightmap;
  59265. private _minus90X;
  59266. private _plus90X;
  59267. private _tmpPosition;
  59268. private _tmpDeltaPosition;
  59269. private _tmpUnityRotation;
  59270. private _updatePhysicsBodyTransformation;
  59271. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59272. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59273. isSupported(): boolean;
  59274. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59275. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59276. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59277. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59278. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59279. getBodyMass(impostor: PhysicsImpostor): number;
  59280. getBodyFriction(impostor: PhysicsImpostor): number;
  59281. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59282. getBodyRestitution(impostor: PhysicsImpostor): number;
  59283. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59284. sleepBody(impostor: PhysicsImpostor): void;
  59285. wakeUpBody(impostor: PhysicsImpostor): void;
  59286. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  59287. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  59288. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  59289. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59290. getRadius(impostor: PhysicsImpostor): number;
  59291. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59292. dispose(): void;
  59293. private _extendNamespace;
  59294. /**
  59295. * Does a raycast in the physics world
  59296. * @param from when should the ray start?
  59297. * @param to when should the ray end?
  59298. * @returns PhysicsRaycastResult
  59299. */
  59300. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59301. }
  59302. }
  59303. declare module BABYLON {
  59304. /** @hidden */
  59305. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  59306. private _useDeltaForWorldStep;
  59307. world: any;
  59308. name: string;
  59309. BJSOIMO: any;
  59310. private _raycastResult;
  59311. private _fixedTimeStep;
  59312. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  59313. setGravity(gravity: Vector3): void;
  59314. setTimeStep(timeStep: number): void;
  59315. getTimeStep(): number;
  59316. private _tmpImpostorsArray;
  59317. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59318. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59319. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59320. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59321. private _tmpPositionVector;
  59322. removePhysicsBody(impostor: PhysicsImpostor): void;
  59323. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59324. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59325. isSupported(): boolean;
  59326. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59327. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59328. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59329. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59330. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59331. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59332. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59333. getBodyMass(impostor: PhysicsImpostor): number;
  59334. getBodyFriction(impostor: PhysicsImpostor): number;
  59335. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59336. getBodyRestitution(impostor: PhysicsImpostor): number;
  59337. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59338. sleepBody(impostor: PhysicsImpostor): void;
  59339. wakeUpBody(impostor: PhysicsImpostor): void;
  59340. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  59341. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  59342. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  59343. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59344. getRadius(impostor: PhysicsImpostor): number;
  59345. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59346. dispose(): void;
  59347. /**
  59348. * Does a raycast in the physics world
  59349. * @param from when should the ray start?
  59350. * @param to when should the ray end?
  59351. * @returns PhysicsRaycastResult
  59352. */
  59353. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59354. }
  59355. }
  59356. declare module BABYLON {
  59357. /**
  59358. * Class containing static functions to help procedurally build meshes
  59359. */
  59360. export class RibbonBuilder {
  59361. /**
  59362. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59363. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59364. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59365. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59366. * * 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
  59367. * * 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
  59368. * * 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
  59369. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59370. * * 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
  59371. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59372. * * 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
  59373. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59374. * * 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
  59375. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59376. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59377. * @param name defines the name of the mesh
  59378. * @param options defines the options used to create the mesh
  59379. * @param scene defines the hosting scene
  59380. * @returns the ribbon mesh
  59381. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59382. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59383. */
  59384. static CreateRibbon(name: string, options: {
  59385. pathArray: Vector3[][];
  59386. closeArray?: boolean;
  59387. closePath?: boolean;
  59388. offset?: number;
  59389. updatable?: boolean;
  59390. sideOrientation?: number;
  59391. frontUVs?: Vector4;
  59392. backUVs?: Vector4;
  59393. instance?: Mesh;
  59394. invertUV?: boolean;
  59395. uvs?: Vector2[];
  59396. colors?: Color4[];
  59397. }, scene?: Nullable<Scene>): Mesh;
  59398. }
  59399. }
  59400. declare module BABYLON {
  59401. /**
  59402. * Class containing static functions to help procedurally build meshes
  59403. */
  59404. export class ShapeBuilder {
  59405. /**
  59406. * 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.
  59407. * * 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.
  59408. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59409. * * 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.
  59410. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59411. * * 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
  59412. * * 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
  59413. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59414. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59415. * * 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
  59416. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59418. * @param name defines the name of the mesh
  59419. * @param options defines the options used to create the mesh
  59420. * @param scene defines the hosting scene
  59421. * @returns the extruded shape mesh
  59422. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59423. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59424. */
  59425. static ExtrudeShape(name: string, options: {
  59426. shape: Vector3[];
  59427. path: Vector3[];
  59428. scale?: number;
  59429. rotation?: number;
  59430. cap?: number;
  59431. updatable?: boolean;
  59432. sideOrientation?: number;
  59433. frontUVs?: Vector4;
  59434. backUVs?: Vector4;
  59435. instance?: Mesh;
  59436. invertUV?: boolean;
  59437. }, scene?: Nullable<Scene>): Mesh;
  59438. /**
  59439. * Creates an custom extruded shape mesh.
  59440. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59441. * * 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.
  59442. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59443. * * 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
  59444. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59445. * * 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
  59446. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59447. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59448. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59449. * * 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
  59450. * * 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
  59451. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59452. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59453. * * 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
  59454. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59455. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59456. * @param name defines the name of the mesh
  59457. * @param options defines the options used to create the mesh
  59458. * @param scene defines the hosting scene
  59459. * @returns the custom extruded shape mesh
  59460. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59461. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59462. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59463. */
  59464. static ExtrudeShapeCustom(name: string, options: {
  59465. shape: Vector3[];
  59466. path: Vector3[];
  59467. scaleFunction?: any;
  59468. rotationFunction?: any;
  59469. ribbonCloseArray?: boolean;
  59470. ribbonClosePath?: boolean;
  59471. cap?: number;
  59472. updatable?: boolean;
  59473. sideOrientation?: number;
  59474. frontUVs?: Vector4;
  59475. backUVs?: Vector4;
  59476. instance?: Mesh;
  59477. invertUV?: boolean;
  59478. }, scene?: Nullable<Scene>): Mesh;
  59479. private static _ExtrudeShapeGeneric;
  59480. }
  59481. }
  59482. declare module BABYLON {
  59483. /**
  59484. * AmmoJS Physics plugin
  59485. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  59486. * @see https://github.com/kripken/ammo.js/
  59487. */
  59488. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  59489. private _useDeltaForWorldStep;
  59490. /**
  59491. * Reference to the Ammo library
  59492. */
  59493. bjsAMMO: any;
  59494. /**
  59495. * Created ammoJS world which physics bodies are added to
  59496. */
  59497. world: any;
  59498. /**
  59499. * Name of the plugin
  59500. */
  59501. name: string;
  59502. private _timeStep;
  59503. private _fixedTimeStep;
  59504. private _maxSteps;
  59505. private _tmpQuaternion;
  59506. private _tmpAmmoTransform;
  59507. private _tmpAmmoQuaternion;
  59508. private _tmpAmmoConcreteContactResultCallback;
  59509. private _collisionConfiguration;
  59510. private _dispatcher;
  59511. private _overlappingPairCache;
  59512. private _solver;
  59513. private _softBodySolver;
  59514. private _tmpAmmoVectorA;
  59515. private _tmpAmmoVectorB;
  59516. private _tmpAmmoVectorC;
  59517. private _tmpAmmoVectorD;
  59518. private _tmpContactCallbackResult;
  59519. private _tmpAmmoVectorRCA;
  59520. private _tmpAmmoVectorRCB;
  59521. private _raycastResult;
  59522. private static readonly DISABLE_COLLISION_FLAG;
  59523. private static readonly KINEMATIC_FLAG;
  59524. private static readonly DISABLE_DEACTIVATION_FLAG;
  59525. /**
  59526. * Initializes the ammoJS plugin
  59527. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  59528. * @param ammoInjection can be used to inject your own ammo reference
  59529. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  59530. */
  59531. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  59532. /**
  59533. * Sets the gravity of the physics world (m/(s^2))
  59534. * @param gravity Gravity to set
  59535. */
  59536. setGravity(gravity: Vector3): void;
  59537. /**
  59538. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  59539. * @param timeStep timestep to use in seconds
  59540. */
  59541. setTimeStep(timeStep: number): void;
  59542. /**
  59543. * 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)
  59544. * @param fixedTimeStep fixedTimeStep to use in seconds
  59545. */
  59546. setFixedTimeStep(fixedTimeStep: number): void;
  59547. /**
  59548. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  59549. * @param maxSteps the maximum number of steps by the physics engine per frame
  59550. */
  59551. setMaxSteps(maxSteps: number): void;
  59552. /**
  59553. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  59554. * @returns the current timestep in seconds
  59555. */
  59556. getTimeStep(): number;
  59557. /**
  59558. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  59559. */
  59560. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  59561. private _isImpostorInContact;
  59562. private _isImpostorPairInContact;
  59563. private _stepSimulation;
  59564. /**
  59565. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  59566. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  59567. * After the step the babylon meshes are set to the position of the physics imposters
  59568. * @param delta amount of time to step forward
  59569. * @param impostors array of imposters to update before/after the step
  59570. */
  59571. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59572. /**
  59573. * Update babylon mesh to match physics world object
  59574. * @param impostor imposter to match
  59575. */
  59576. private _afterSoftStep;
  59577. /**
  59578. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59579. * @param impostor imposter to match
  59580. */
  59581. private _ropeStep;
  59582. /**
  59583. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59584. * @param impostor imposter to match
  59585. */
  59586. private _softbodyOrClothStep;
  59587. private _tmpMatrix;
  59588. /**
  59589. * Applies an impulse on the imposter
  59590. * @param impostor imposter to apply impulse to
  59591. * @param force amount of force to be applied to the imposter
  59592. * @param contactPoint the location to apply the impulse on the imposter
  59593. */
  59594. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59595. /**
  59596. * Applies a force on the imposter
  59597. * @param impostor imposter to apply force
  59598. * @param force amount of force to be applied to the imposter
  59599. * @param contactPoint the location to apply the force on the imposter
  59600. */
  59601. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59602. /**
  59603. * Creates a physics body using the plugin
  59604. * @param impostor the imposter to create the physics body on
  59605. */
  59606. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59607. /**
  59608. * Removes the physics body from the imposter and disposes of the body's memory
  59609. * @param impostor imposter to remove the physics body from
  59610. */
  59611. removePhysicsBody(impostor: PhysicsImpostor): void;
  59612. /**
  59613. * Generates a joint
  59614. * @param impostorJoint the imposter joint to create the joint with
  59615. */
  59616. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59617. /**
  59618. * Removes a joint
  59619. * @param impostorJoint the imposter joint to remove the joint from
  59620. */
  59621. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59622. private _addMeshVerts;
  59623. /**
  59624. * Initialise the soft body vertices to match its object's (mesh) vertices
  59625. * Softbody vertices (nodes) are in world space and to match this
  59626. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  59627. * @param impostor to create the softbody for
  59628. */
  59629. private _softVertexData;
  59630. /**
  59631. * Create an impostor's soft body
  59632. * @param impostor to create the softbody for
  59633. */
  59634. private _createSoftbody;
  59635. /**
  59636. * Create cloth for an impostor
  59637. * @param impostor to create the softbody for
  59638. */
  59639. private _createCloth;
  59640. /**
  59641. * Create rope for an impostor
  59642. * @param impostor to create the softbody for
  59643. */
  59644. private _createRope;
  59645. /**
  59646. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  59647. * @param impostor to create the custom physics shape for
  59648. */
  59649. private _createCustom;
  59650. private _addHullVerts;
  59651. private _createShape;
  59652. /**
  59653. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  59654. * @param impostor imposter containing the physics body and babylon object
  59655. */
  59656. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59657. /**
  59658. * Sets the babylon object's position/rotation from the physics body's position/rotation
  59659. * @param impostor imposter containing the physics body and babylon object
  59660. * @param newPosition new position
  59661. * @param newRotation new rotation
  59662. */
  59663. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59664. /**
  59665. * If this plugin is supported
  59666. * @returns true if its supported
  59667. */
  59668. isSupported(): boolean;
  59669. /**
  59670. * Sets the linear velocity of the physics body
  59671. * @param impostor imposter to set the velocity on
  59672. * @param velocity velocity to set
  59673. */
  59674. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59675. /**
  59676. * Sets the angular velocity of the physics body
  59677. * @param impostor imposter to set the velocity on
  59678. * @param velocity velocity to set
  59679. */
  59680. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59681. /**
  59682. * gets the linear velocity
  59683. * @param impostor imposter to get linear velocity from
  59684. * @returns linear velocity
  59685. */
  59686. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59687. /**
  59688. * gets the angular velocity
  59689. * @param impostor imposter to get angular velocity from
  59690. * @returns angular velocity
  59691. */
  59692. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59693. /**
  59694. * Sets the mass of physics body
  59695. * @param impostor imposter to set the mass on
  59696. * @param mass mass to set
  59697. */
  59698. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59699. /**
  59700. * Gets the mass of the physics body
  59701. * @param impostor imposter to get the mass from
  59702. * @returns mass
  59703. */
  59704. getBodyMass(impostor: PhysicsImpostor): number;
  59705. /**
  59706. * Gets friction of the impostor
  59707. * @param impostor impostor to get friction from
  59708. * @returns friction value
  59709. */
  59710. getBodyFriction(impostor: PhysicsImpostor): number;
  59711. /**
  59712. * Sets friction of the impostor
  59713. * @param impostor impostor to set friction on
  59714. * @param friction friction value
  59715. */
  59716. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59717. /**
  59718. * Gets restitution of the impostor
  59719. * @param impostor impostor to get restitution from
  59720. * @returns restitution value
  59721. */
  59722. getBodyRestitution(impostor: PhysicsImpostor): number;
  59723. /**
  59724. * Sets resitution of the impostor
  59725. * @param impostor impostor to set resitution on
  59726. * @param restitution resitution value
  59727. */
  59728. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59729. /**
  59730. * Gets pressure inside the impostor
  59731. * @param impostor impostor to get pressure from
  59732. * @returns pressure value
  59733. */
  59734. getBodyPressure(impostor: PhysicsImpostor): number;
  59735. /**
  59736. * Sets pressure inside a soft body impostor
  59737. * Cloth and rope must remain 0 pressure
  59738. * @param impostor impostor to set pressure on
  59739. * @param pressure pressure value
  59740. */
  59741. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  59742. /**
  59743. * Gets stiffness of the impostor
  59744. * @param impostor impostor to get stiffness from
  59745. * @returns pressure value
  59746. */
  59747. getBodyStiffness(impostor: PhysicsImpostor): number;
  59748. /**
  59749. * Sets stiffness of the impostor
  59750. * @param impostor impostor to set stiffness on
  59751. * @param stiffness stiffness value from 0 to 1
  59752. */
  59753. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  59754. /**
  59755. * Gets velocityIterations of the impostor
  59756. * @param impostor impostor to get velocity iterations from
  59757. * @returns velocityIterations value
  59758. */
  59759. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  59760. /**
  59761. * Sets velocityIterations of the impostor
  59762. * @param impostor impostor to set velocity iterations on
  59763. * @param velocityIterations velocityIterations value
  59764. */
  59765. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  59766. /**
  59767. * Gets positionIterations of the impostor
  59768. * @param impostor impostor to get position iterations from
  59769. * @returns positionIterations value
  59770. */
  59771. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  59772. /**
  59773. * Sets positionIterations of the impostor
  59774. * @param impostor impostor to set position on
  59775. * @param positionIterations positionIterations value
  59776. */
  59777. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  59778. /**
  59779. * Append an anchor to a cloth object
  59780. * @param impostor is the cloth impostor to add anchor to
  59781. * @param otherImpostor is the rigid impostor to anchor to
  59782. * @param width ratio across width from 0 to 1
  59783. * @param height ratio up height from 0 to 1
  59784. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  59785. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59786. */
  59787. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59788. /**
  59789. * Append an hook to a rope object
  59790. * @param impostor is the rope impostor to add hook to
  59791. * @param otherImpostor is the rigid impostor to hook to
  59792. * @param length ratio along the rope from 0 to 1
  59793. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  59794. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59795. */
  59796. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59797. /**
  59798. * Sleeps the physics body and stops it from being active
  59799. * @param impostor impostor to sleep
  59800. */
  59801. sleepBody(impostor: PhysicsImpostor): void;
  59802. /**
  59803. * Activates the physics body
  59804. * @param impostor impostor to activate
  59805. */
  59806. wakeUpBody(impostor: PhysicsImpostor): void;
  59807. /**
  59808. * Updates the distance parameters of the joint
  59809. * @param joint joint to update
  59810. * @param maxDistance maximum distance of the joint
  59811. * @param minDistance minimum distance of the joint
  59812. */
  59813. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  59814. /**
  59815. * Sets a motor on the joint
  59816. * @param joint joint to set motor on
  59817. * @param speed speed of the motor
  59818. * @param maxForce maximum force of the motor
  59819. * @param motorIndex index of the motor
  59820. */
  59821. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  59822. /**
  59823. * Sets the motors limit
  59824. * @param joint joint to set limit on
  59825. * @param upperLimit upper limit
  59826. * @param lowerLimit lower limit
  59827. */
  59828. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  59829. /**
  59830. * Syncs the position and rotation of a mesh with the impostor
  59831. * @param mesh mesh to sync
  59832. * @param impostor impostor to update the mesh with
  59833. */
  59834. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59835. /**
  59836. * Gets the radius of the impostor
  59837. * @param impostor impostor to get radius from
  59838. * @returns the radius
  59839. */
  59840. getRadius(impostor: PhysicsImpostor): number;
  59841. /**
  59842. * Gets the box size of the impostor
  59843. * @param impostor impostor to get box size from
  59844. * @param result the resulting box size
  59845. */
  59846. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59847. /**
  59848. * Disposes of the impostor
  59849. */
  59850. dispose(): void;
  59851. /**
  59852. * Does a raycast in the physics world
  59853. * @param from when should the ray start?
  59854. * @param to when should the ray end?
  59855. * @returns PhysicsRaycastResult
  59856. */
  59857. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59858. }
  59859. }
  59860. declare module BABYLON {
  59861. interface AbstractScene {
  59862. /**
  59863. * The list of reflection probes added to the scene
  59864. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  59865. */
  59866. reflectionProbes: Array<ReflectionProbe>;
  59867. /**
  59868. * Removes the given reflection probe from this scene.
  59869. * @param toRemove The reflection probe to remove
  59870. * @returns The index of the removed reflection probe
  59871. */
  59872. removeReflectionProbe(toRemove: ReflectionProbe): number;
  59873. /**
  59874. * Adds the given reflection probe to this scene.
  59875. * @param newReflectionProbe The reflection probe to add
  59876. */
  59877. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  59878. }
  59879. /**
  59880. * Class used to generate realtime reflection / refraction cube textures
  59881. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  59882. */
  59883. export class ReflectionProbe {
  59884. /** defines the name of the probe */
  59885. name: string;
  59886. private _scene;
  59887. private _renderTargetTexture;
  59888. private _projectionMatrix;
  59889. private _viewMatrix;
  59890. private _target;
  59891. private _add;
  59892. private _attachedMesh;
  59893. private _invertYAxis;
  59894. /** Gets or sets probe position (center of the cube map) */
  59895. position: Vector3;
  59896. /**
  59897. * Creates a new reflection probe
  59898. * @param name defines the name of the probe
  59899. * @param size defines the texture resolution (for each face)
  59900. * @param scene defines the hosting scene
  59901. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  59902. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  59903. */
  59904. constructor(
  59905. /** defines the name of the probe */
  59906. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  59907. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  59908. get samples(): number;
  59909. set samples(value: number);
  59910. /** Gets or sets the refresh rate to use (on every frame by default) */
  59911. get refreshRate(): number;
  59912. set refreshRate(value: number);
  59913. /**
  59914. * Gets the hosting scene
  59915. * @returns a Scene
  59916. */
  59917. getScene(): Scene;
  59918. /** Gets the internal CubeTexture used to render to */
  59919. get cubeTexture(): RenderTargetTexture;
  59920. /** Gets the list of meshes to render */
  59921. get renderList(): Nullable<AbstractMesh[]>;
  59922. /**
  59923. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  59924. * @param mesh defines the mesh to attach to
  59925. */
  59926. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  59927. /**
  59928. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  59929. * @param renderingGroupId The rendering group id corresponding to its index
  59930. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  59931. */
  59932. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  59933. /**
  59934. * Clean all associated resources
  59935. */
  59936. dispose(): void;
  59937. /**
  59938. * Converts the reflection probe information to a readable string for debug purpose.
  59939. * @param fullDetails Supports for multiple levels of logging within scene loading
  59940. * @returns the human readable reflection probe info
  59941. */
  59942. toString(fullDetails?: boolean): string;
  59943. /**
  59944. * Get the class name of the relfection probe.
  59945. * @returns "ReflectionProbe"
  59946. */
  59947. getClassName(): string;
  59948. /**
  59949. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  59950. * @returns The JSON representation of the texture
  59951. */
  59952. serialize(): any;
  59953. /**
  59954. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  59955. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  59956. * @param scene Define the scene the parsed reflection probe should be instantiated in
  59957. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  59958. * @returns The parsed reflection probe if successful
  59959. */
  59960. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  59961. }
  59962. }
  59963. declare module BABYLON {
  59964. /** @hidden */
  59965. export var _BabylonLoaderRegistered: boolean;
  59966. /**
  59967. * Helps setting up some configuration for the babylon file loader.
  59968. */
  59969. export class BabylonFileLoaderConfiguration {
  59970. /**
  59971. * The loader does not allow injecting custom physix engine into the plugins.
  59972. * Unfortunately in ES6, we need to manually inject them into the plugin.
  59973. * So you could set this variable to your engine import to make it work.
  59974. */
  59975. static LoaderInjectedPhysicsEngine: any;
  59976. }
  59977. }
  59978. declare module BABYLON {
  59979. /**
  59980. * The Physically based simple base material of BJS.
  59981. *
  59982. * This enables better naming and convention enforcements on top of the pbrMaterial.
  59983. * It is used as the base class for both the specGloss and metalRough conventions.
  59984. */
  59985. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  59986. /**
  59987. * Number of Simultaneous lights allowed on the material.
  59988. */
  59989. maxSimultaneousLights: number;
  59990. /**
  59991. * If sets to true, disables all the lights affecting the material.
  59992. */
  59993. disableLighting: boolean;
  59994. /**
  59995. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  59996. */
  59997. environmentTexture: BaseTexture;
  59998. /**
  59999. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  60000. */
  60001. invertNormalMapX: boolean;
  60002. /**
  60003. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  60004. */
  60005. invertNormalMapY: boolean;
  60006. /**
  60007. * Normal map used in the model.
  60008. */
  60009. normalTexture: BaseTexture;
  60010. /**
  60011. * Emissivie color used to self-illuminate the model.
  60012. */
  60013. emissiveColor: Color3;
  60014. /**
  60015. * Emissivie texture used to self-illuminate the model.
  60016. */
  60017. emissiveTexture: BaseTexture;
  60018. /**
  60019. * Occlusion Channel Strenght.
  60020. */
  60021. occlusionStrength: number;
  60022. /**
  60023. * Occlusion Texture of the material (adding extra occlusion effects).
  60024. */
  60025. occlusionTexture: BaseTexture;
  60026. /**
  60027. * Defines the alpha limits in alpha test mode.
  60028. */
  60029. alphaCutOff: number;
  60030. /**
  60031. * Gets the current double sided mode.
  60032. */
  60033. get doubleSided(): boolean;
  60034. /**
  60035. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  60036. */
  60037. set doubleSided(value: boolean);
  60038. /**
  60039. * Stores the pre-calculated light information of a mesh in a texture.
  60040. */
  60041. lightmapTexture: BaseTexture;
  60042. /**
  60043. * If true, the light map contains occlusion information instead of lighting info.
  60044. */
  60045. useLightmapAsShadowmap: boolean;
  60046. /**
  60047. * Instantiates a new PBRMaterial instance.
  60048. *
  60049. * @param name The material name
  60050. * @param scene The scene the material will be use in.
  60051. */
  60052. constructor(name: string, scene: Scene);
  60053. getClassName(): string;
  60054. }
  60055. }
  60056. declare module BABYLON {
  60057. /**
  60058. * The PBR material of BJS following the metal roughness convention.
  60059. *
  60060. * This fits to the PBR convention in the GLTF definition:
  60061. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  60062. */
  60063. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  60064. /**
  60065. * The base color has two different interpretations depending on the value of metalness.
  60066. * When the material is a metal, the base color is the specific measured reflectance value
  60067. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  60068. * of the material.
  60069. */
  60070. baseColor: Color3;
  60071. /**
  60072. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  60073. * well as opacity information in the alpha channel.
  60074. */
  60075. baseTexture: BaseTexture;
  60076. /**
  60077. * Specifies the metallic scalar value of the material.
  60078. * Can also be used to scale the metalness values of the metallic texture.
  60079. */
  60080. metallic: number;
  60081. /**
  60082. * Specifies the roughness scalar value of the material.
  60083. * Can also be used to scale the roughness values of the metallic texture.
  60084. */
  60085. roughness: number;
  60086. /**
  60087. * Texture containing both the metallic value in the B channel and the
  60088. * roughness value in the G channel to keep better precision.
  60089. */
  60090. metallicRoughnessTexture: BaseTexture;
  60091. /**
  60092. * Instantiates a new PBRMetalRoughnessMaterial instance.
  60093. *
  60094. * @param name The material name
  60095. * @param scene The scene the material will be use in.
  60096. */
  60097. constructor(name: string, scene: Scene);
  60098. /**
  60099. * Return the currrent class name of the material.
  60100. */
  60101. getClassName(): string;
  60102. /**
  60103. * Makes a duplicate of the current material.
  60104. * @param name - name to use for the new material.
  60105. */
  60106. clone(name: string): PBRMetallicRoughnessMaterial;
  60107. /**
  60108. * Serialize the material to a parsable JSON object.
  60109. */
  60110. serialize(): any;
  60111. /**
  60112. * Parses a JSON object correponding to the serialize function.
  60113. */
  60114. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  60115. }
  60116. }
  60117. declare module BABYLON {
  60118. /**
  60119. * The PBR material of BJS following the specular glossiness convention.
  60120. *
  60121. * This fits to the PBR convention in the GLTF definition:
  60122. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  60123. */
  60124. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  60125. /**
  60126. * Specifies the diffuse color of the material.
  60127. */
  60128. diffuseColor: Color3;
  60129. /**
  60130. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  60131. * channel.
  60132. */
  60133. diffuseTexture: BaseTexture;
  60134. /**
  60135. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  60136. */
  60137. specularColor: Color3;
  60138. /**
  60139. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  60140. */
  60141. glossiness: number;
  60142. /**
  60143. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  60144. */
  60145. specularGlossinessTexture: BaseTexture;
  60146. /**
  60147. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  60148. *
  60149. * @param name The material name
  60150. * @param scene The scene the material will be use in.
  60151. */
  60152. constructor(name: string, scene: Scene);
  60153. /**
  60154. * Return the currrent class name of the material.
  60155. */
  60156. getClassName(): string;
  60157. /**
  60158. * Makes a duplicate of the current material.
  60159. * @param name - name to use for the new material.
  60160. */
  60161. clone(name: string): PBRSpecularGlossinessMaterial;
  60162. /**
  60163. * Serialize the material to a parsable JSON object.
  60164. */
  60165. serialize(): any;
  60166. /**
  60167. * Parses a JSON object correponding to the serialize function.
  60168. */
  60169. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  60170. }
  60171. }
  60172. declare module BABYLON {
  60173. /**
  60174. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  60175. * It can help converting any input color in a desired output one. This can then be used to create effects
  60176. * from sepia, black and white to sixties or futuristic rendering...
  60177. *
  60178. * The only supported format is currently 3dl.
  60179. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  60180. */
  60181. export class ColorGradingTexture extends BaseTexture {
  60182. /**
  60183. * The texture URL.
  60184. */
  60185. url: string;
  60186. /**
  60187. * Empty line regex stored for GC.
  60188. */
  60189. private static _noneEmptyLineRegex;
  60190. private _textureMatrix;
  60191. private _onLoad;
  60192. /**
  60193. * Instantiates a ColorGradingTexture from the following parameters.
  60194. *
  60195. * @param url The location of the color gradind data (currently only supporting 3dl)
  60196. * @param sceneOrEngine The scene or engine the texture will be used in
  60197. * @param onLoad defines a callback triggered when the texture has been loaded
  60198. */
  60199. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  60200. /**
  60201. * Fires the onload event from the constructor if requested.
  60202. */
  60203. private _triggerOnLoad;
  60204. /**
  60205. * Returns the texture matrix used in most of the material.
  60206. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  60207. */
  60208. getTextureMatrix(): Matrix;
  60209. /**
  60210. * Occurs when the file being loaded is a .3dl LUT file.
  60211. */
  60212. private load3dlTexture;
  60213. /**
  60214. * Starts the loading process of the texture.
  60215. */
  60216. private loadTexture;
  60217. /**
  60218. * Clones the color gradind texture.
  60219. */
  60220. clone(): ColorGradingTexture;
  60221. /**
  60222. * Called during delayed load for textures.
  60223. */
  60224. delayLoad(): void;
  60225. /**
  60226. * Parses a color grading texture serialized by Babylon.
  60227. * @param parsedTexture The texture information being parsedTexture
  60228. * @param scene The scene to load the texture in
  60229. * @param rootUrl The root url of the data assets to load
  60230. * @return A color gradind texture
  60231. */
  60232. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  60233. /**
  60234. * Serializes the LUT texture to json format.
  60235. */
  60236. serialize(): any;
  60237. }
  60238. }
  60239. declare module BABYLON {
  60240. /**
  60241. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  60242. */
  60243. export class EquiRectangularCubeTexture extends BaseTexture {
  60244. /** The six faces of the cube. */
  60245. private static _FacesMapping;
  60246. private _noMipmap;
  60247. private _onLoad;
  60248. private _onError;
  60249. /** The size of the cubemap. */
  60250. private _size;
  60251. /** The buffer of the image. */
  60252. private _buffer;
  60253. /** The width of the input image. */
  60254. private _width;
  60255. /** The height of the input image. */
  60256. private _height;
  60257. /** The URL to the image. */
  60258. url: string;
  60259. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  60260. coordinatesMode: number;
  60261. /**
  60262. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  60263. * @param url The location of the image
  60264. * @param scene The scene the texture will be used in
  60265. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  60266. * @param noMipmap Forces to not generate the mipmap if true
  60267. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  60268. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  60269. * @param onLoad — defines a callback called when texture is loaded
  60270. * @param onError — defines a callback called if there is an error
  60271. */
  60272. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  60273. /**
  60274. * Load the image data, by putting the image on a canvas and extracting its buffer.
  60275. */
  60276. private loadImage;
  60277. /**
  60278. * Convert the image buffer into a cubemap and create a CubeTexture.
  60279. */
  60280. private loadTexture;
  60281. /**
  60282. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  60283. * @param buffer The ArrayBuffer that should be converted.
  60284. * @returns The buffer as Float32Array.
  60285. */
  60286. private getFloat32ArrayFromArrayBuffer;
  60287. /**
  60288. * Get the current class name of the texture useful for serialization or dynamic coding.
  60289. * @returns "EquiRectangularCubeTexture"
  60290. */
  60291. getClassName(): string;
  60292. /**
  60293. * Create a clone of the current EquiRectangularCubeTexture and return it.
  60294. * @returns A clone of the current EquiRectangularCubeTexture.
  60295. */
  60296. clone(): EquiRectangularCubeTexture;
  60297. }
  60298. }
  60299. declare module BABYLON {
  60300. /**
  60301. * Defines the options related to the creation of an HtmlElementTexture
  60302. */
  60303. export interface IHtmlElementTextureOptions {
  60304. /**
  60305. * Defines wether mip maps should be created or not.
  60306. */
  60307. generateMipMaps?: boolean;
  60308. /**
  60309. * Defines the sampling mode of the texture.
  60310. */
  60311. samplingMode?: number;
  60312. /**
  60313. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  60314. */
  60315. engine: Nullable<ThinEngine>;
  60316. /**
  60317. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  60318. */
  60319. scene: Nullable<Scene>;
  60320. }
  60321. /**
  60322. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  60323. * To be as efficient as possible depending on your constraints nothing aside the first upload
  60324. * is automatically managed.
  60325. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  60326. * in your application.
  60327. *
  60328. * As the update is not automatic, you need to call them manually.
  60329. */
  60330. export class HtmlElementTexture extends BaseTexture {
  60331. /**
  60332. * The texture URL.
  60333. */
  60334. element: HTMLVideoElement | HTMLCanvasElement;
  60335. private static readonly DefaultOptions;
  60336. private _textureMatrix;
  60337. private _isVideo;
  60338. private _generateMipMaps;
  60339. private _samplingMode;
  60340. /**
  60341. * Instantiates a HtmlElementTexture from the following parameters.
  60342. *
  60343. * @param name Defines the name of the texture
  60344. * @param element Defines the video or canvas the texture is filled with
  60345. * @param options Defines the other none mandatory texture creation options
  60346. */
  60347. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  60348. private _createInternalTexture;
  60349. /**
  60350. * Returns the texture matrix used in most of the material.
  60351. */
  60352. getTextureMatrix(): Matrix;
  60353. /**
  60354. * Updates the content of the texture.
  60355. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  60356. */
  60357. update(invertY?: Nullable<boolean>): void;
  60358. }
  60359. }
  60360. declare module BABYLON {
  60361. /**
  60362. * Based on jsTGALoader - Javascript loader for TGA file
  60363. * By Vincent Thibault
  60364. * @see http://blog.robrowser.com/javascript-tga-loader.html
  60365. */
  60366. export class TGATools {
  60367. private static _TYPE_INDEXED;
  60368. private static _TYPE_RGB;
  60369. private static _TYPE_GREY;
  60370. private static _TYPE_RLE_INDEXED;
  60371. private static _TYPE_RLE_RGB;
  60372. private static _TYPE_RLE_GREY;
  60373. private static _ORIGIN_MASK;
  60374. private static _ORIGIN_SHIFT;
  60375. private static _ORIGIN_BL;
  60376. private static _ORIGIN_BR;
  60377. private static _ORIGIN_UL;
  60378. private static _ORIGIN_UR;
  60379. /**
  60380. * Gets the header of a TGA file
  60381. * @param data defines the TGA data
  60382. * @returns the header
  60383. */
  60384. static GetTGAHeader(data: Uint8Array): any;
  60385. /**
  60386. * Uploads TGA content to a Babylon Texture
  60387. * @hidden
  60388. */
  60389. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  60390. /** @hidden */
  60391. 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;
  60392. /** @hidden */
  60393. 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;
  60394. /** @hidden */
  60395. 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;
  60396. /** @hidden */
  60397. 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;
  60398. /** @hidden */
  60399. 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;
  60400. /** @hidden */
  60401. 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;
  60402. }
  60403. }
  60404. declare module BABYLON {
  60405. /**
  60406. * Implementation of the TGA Texture Loader.
  60407. * @hidden
  60408. */
  60409. export class _TGATextureLoader implements IInternalTextureLoader {
  60410. /**
  60411. * Defines wether the loader supports cascade loading the different faces.
  60412. */
  60413. readonly supportCascades: boolean;
  60414. /**
  60415. * This returns if the loader support the current file information.
  60416. * @param extension defines the file extension of the file being loaded
  60417. * @returns true if the loader can load the specified file
  60418. */
  60419. canLoad(extension: string): boolean;
  60420. /**
  60421. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60422. * @param data contains the texture data
  60423. * @param texture defines the BabylonJS internal texture
  60424. * @param createPolynomials will be true if polynomials have been requested
  60425. * @param onLoad defines the callback to trigger once the texture is ready
  60426. * @param onError defines the callback to trigger in case of error
  60427. */
  60428. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60429. /**
  60430. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60431. * @param data contains the texture data
  60432. * @param texture defines the BabylonJS internal texture
  60433. * @param callback defines the method to call once ready to upload
  60434. */
  60435. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60436. }
  60437. }
  60438. declare module BABYLON {
  60439. /**
  60440. * Info about the .basis files
  60441. */
  60442. class BasisFileInfo {
  60443. /**
  60444. * If the file has alpha
  60445. */
  60446. hasAlpha: boolean;
  60447. /**
  60448. * Info about each image of the basis file
  60449. */
  60450. images: Array<{
  60451. levels: Array<{
  60452. width: number;
  60453. height: number;
  60454. transcodedPixels: ArrayBufferView;
  60455. }>;
  60456. }>;
  60457. }
  60458. /**
  60459. * Result of transcoding a basis file
  60460. */
  60461. class TranscodeResult {
  60462. /**
  60463. * Info about the .basis file
  60464. */
  60465. fileInfo: BasisFileInfo;
  60466. /**
  60467. * Format to use when loading the file
  60468. */
  60469. format: number;
  60470. }
  60471. /**
  60472. * Configuration options for the Basis transcoder
  60473. */
  60474. export class BasisTranscodeConfiguration {
  60475. /**
  60476. * Supported compression formats used to determine the supported output format of the transcoder
  60477. */
  60478. supportedCompressionFormats?: {
  60479. /**
  60480. * etc1 compression format
  60481. */
  60482. etc1?: boolean;
  60483. /**
  60484. * s3tc compression format
  60485. */
  60486. s3tc?: boolean;
  60487. /**
  60488. * pvrtc compression format
  60489. */
  60490. pvrtc?: boolean;
  60491. /**
  60492. * etc2 compression format
  60493. */
  60494. etc2?: boolean;
  60495. };
  60496. /**
  60497. * If mipmap levels should be loaded for transcoded images (Default: true)
  60498. */
  60499. loadMipmapLevels?: boolean;
  60500. /**
  60501. * Index of a single image to load (Default: all images)
  60502. */
  60503. loadSingleImage?: number;
  60504. }
  60505. /**
  60506. * Used to load .Basis files
  60507. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  60508. */
  60509. export class BasisTools {
  60510. private static _IgnoreSupportedFormats;
  60511. /**
  60512. * URL to use when loading the basis transcoder
  60513. */
  60514. static JSModuleURL: string;
  60515. /**
  60516. * URL to use when loading the wasm module for the transcoder
  60517. */
  60518. static WasmModuleURL: string;
  60519. /**
  60520. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  60521. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  60522. * @returns internal format corresponding to the Basis format
  60523. */
  60524. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  60525. private static _WorkerPromise;
  60526. private static _Worker;
  60527. private static _actionId;
  60528. private static _CreateWorkerAsync;
  60529. /**
  60530. * Transcodes a loaded image file to compressed pixel data
  60531. * @param data image data to transcode
  60532. * @param config configuration options for the transcoding
  60533. * @returns a promise resulting in the transcoded image
  60534. */
  60535. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  60536. /**
  60537. * Loads a texture from the transcode result
  60538. * @param texture texture load to
  60539. * @param transcodeResult the result of transcoding the basis file to load from
  60540. */
  60541. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  60542. }
  60543. }
  60544. declare module BABYLON {
  60545. /**
  60546. * Loader for .basis file format
  60547. */
  60548. export class _BasisTextureLoader implements IInternalTextureLoader {
  60549. /**
  60550. * Defines whether the loader supports cascade loading the different faces.
  60551. */
  60552. readonly supportCascades: boolean;
  60553. /**
  60554. * This returns if the loader support the current file information.
  60555. * @param extension defines the file extension of the file being loaded
  60556. * @returns true if the loader can load the specified file
  60557. */
  60558. canLoad(extension: string): boolean;
  60559. /**
  60560. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60561. * @param data contains the texture data
  60562. * @param texture defines the BabylonJS internal texture
  60563. * @param createPolynomials will be true if polynomials have been requested
  60564. * @param onLoad defines the callback to trigger once the texture is ready
  60565. * @param onError defines the callback to trigger in case of error
  60566. */
  60567. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60568. /**
  60569. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60570. * @param data contains the texture data
  60571. * @param texture defines the BabylonJS internal texture
  60572. * @param callback defines the method to call once ready to upload
  60573. */
  60574. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60575. }
  60576. }
  60577. declare module BABYLON {
  60578. /**
  60579. * Defines the basic options interface of a TexturePacker Frame
  60580. */
  60581. export interface ITexturePackerFrame {
  60582. /**
  60583. * The frame ID
  60584. */
  60585. id: number;
  60586. /**
  60587. * The frames Scale
  60588. */
  60589. scale: Vector2;
  60590. /**
  60591. * The Frames offset
  60592. */
  60593. offset: Vector2;
  60594. }
  60595. /**
  60596. * This is a support class for frame Data on texture packer sets.
  60597. */
  60598. export class TexturePackerFrame implements ITexturePackerFrame {
  60599. /**
  60600. * The frame ID
  60601. */
  60602. id: number;
  60603. /**
  60604. * The frames Scale
  60605. */
  60606. scale: Vector2;
  60607. /**
  60608. * The Frames offset
  60609. */
  60610. offset: Vector2;
  60611. /**
  60612. * Initializes a texture package frame.
  60613. * @param id The numerical frame identifier
  60614. * @param scale Scalar Vector2 for UV frame
  60615. * @param offset Vector2 for the frame position in UV units.
  60616. * @returns TexturePackerFrame
  60617. */
  60618. constructor(id: number, scale: Vector2, offset: Vector2);
  60619. }
  60620. }
  60621. declare module BABYLON {
  60622. /**
  60623. * Defines the basic options interface of a TexturePacker
  60624. */
  60625. export interface ITexturePackerOptions {
  60626. /**
  60627. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  60628. */
  60629. map?: string[];
  60630. /**
  60631. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60632. */
  60633. uvsIn?: string;
  60634. /**
  60635. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60636. */
  60637. uvsOut?: string;
  60638. /**
  60639. * number representing the layout style. Defaults to LAYOUT_STRIP
  60640. */
  60641. layout?: number;
  60642. /**
  60643. * number of columns if using custom column count layout(2). This defaults to 4.
  60644. */
  60645. colnum?: number;
  60646. /**
  60647. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  60648. */
  60649. updateInputMeshes?: boolean;
  60650. /**
  60651. * boolean flag to dispose all the source textures. Defaults to true.
  60652. */
  60653. disposeSources?: boolean;
  60654. /**
  60655. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  60656. */
  60657. fillBlanks?: boolean;
  60658. /**
  60659. * string value representing the context fill style color. Defaults to 'black'.
  60660. */
  60661. customFillColor?: string;
  60662. /**
  60663. * Width and Height Value of each Frame in the TexturePacker Sets
  60664. */
  60665. frameSize?: number;
  60666. /**
  60667. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  60668. */
  60669. paddingRatio?: number;
  60670. /**
  60671. * Number that declares the fill method for the padding gutter.
  60672. */
  60673. paddingMode?: number;
  60674. /**
  60675. * If in SUBUV_COLOR padding mode what color to use.
  60676. */
  60677. paddingColor?: Color3 | Color4;
  60678. }
  60679. /**
  60680. * Defines the basic interface of a TexturePacker JSON File
  60681. */
  60682. export interface ITexturePackerJSON {
  60683. /**
  60684. * The frame ID
  60685. */
  60686. name: string;
  60687. /**
  60688. * The base64 channel data
  60689. */
  60690. sets: any;
  60691. /**
  60692. * The options of the Packer
  60693. */
  60694. options: ITexturePackerOptions;
  60695. /**
  60696. * The frame data of the Packer
  60697. */
  60698. frames: Array<number>;
  60699. }
  60700. /**
  60701. * This is a support class that generates a series of packed texture sets.
  60702. * @see https://doc.babylonjs.com/babylon101/materials
  60703. */
  60704. export class TexturePacker {
  60705. /** Packer Layout Constant 0 */
  60706. static readonly LAYOUT_STRIP: number;
  60707. /** Packer Layout Constant 1 */
  60708. static readonly LAYOUT_POWER2: number;
  60709. /** Packer Layout Constant 2 */
  60710. static readonly LAYOUT_COLNUM: number;
  60711. /** Packer Layout Constant 0 */
  60712. static readonly SUBUV_WRAP: number;
  60713. /** Packer Layout Constant 1 */
  60714. static readonly SUBUV_EXTEND: number;
  60715. /** Packer Layout Constant 2 */
  60716. static readonly SUBUV_COLOR: number;
  60717. /** The Name of the Texture Package */
  60718. name: string;
  60719. /** The scene scope of the TexturePacker */
  60720. scene: Scene;
  60721. /** The Meshes to target */
  60722. meshes: AbstractMesh[];
  60723. /** Arguments passed with the Constructor */
  60724. options: ITexturePackerOptions;
  60725. /** The promise that is started upon initialization */
  60726. promise: Nullable<Promise<TexturePacker | string>>;
  60727. /** The Container object for the channel sets that are generated */
  60728. sets: object;
  60729. /** The Container array for the frames that are generated */
  60730. frames: TexturePackerFrame[];
  60731. /** The expected number of textures the system is parsing. */
  60732. private _expecting;
  60733. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  60734. private _paddingValue;
  60735. /**
  60736. * Initializes a texture package series from an array of meshes or a single mesh.
  60737. * @param name The name of the package
  60738. * @param meshes The target meshes to compose the package from
  60739. * @param options The arguments that texture packer should follow while building.
  60740. * @param scene The scene which the textures are scoped to.
  60741. * @returns TexturePacker
  60742. */
  60743. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  60744. /**
  60745. * Starts the package process
  60746. * @param resolve The promises resolution function
  60747. * @returns TexturePacker
  60748. */
  60749. private _createFrames;
  60750. /**
  60751. * Calculates the Size of the Channel Sets
  60752. * @returns Vector2
  60753. */
  60754. private _calculateSize;
  60755. /**
  60756. * Calculates the UV data for the frames.
  60757. * @param baseSize the base frameSize
  60758. * @param padding the base frame padding
  60759. * @param dtSize size of the Dynamic Texture for that channel
  60760. * @param dtUnits is 1/dtSize
  60761. * @param update flag to update the input meshes
  60762. */
  60763. private _calculateMeshUVFrames;
  60764. /**
  60765. * Calculates the frames Offset.
  60766. * @param index of the frame
  60767. * @returns Vector2
  60768. */
  60769. private _getFrameOffset;
  60770. /**
  60771. * Updates a Mesh to the frame data
  60772. * @param mesh that is the target
  60773. * @param frameID or the frame index
  60774. */
  60775. private _updateMeshUV;
  60776. /**
  60777. * Updates a Meshes materials to use the texture packer channels
  60778. * @param m is the mesh to target
  60779. * @param force all channels on the packer to be set.
  60780. */
  60781. private _updateTextureReferences;
  60782. /**
  60783. * Public method to set a Mesh to a frame
  60784. * @param m that is the target
  60785. * @param frameID or the frame index
  60786. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  60787. */
  60788. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  60789. /**
  60790. * Starts the async promise to compile the texture packer.
  60791. * @returns Promise<void>
  60792. */
  60793. processAsync(): Promise<void>;
  60794. /**
  60795. * Disposes all textures associated with this packer
  60796. */
  60797. dispose(): void;
  60798. /**
  60799. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  60800. * @param imageType is the image type to use.
  60801. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  60802. */
  60803. download(imageType?: string, quality?: number): void;
  60804. /**
  60805. * Public method to load a texturePacker JSON file.
  60806. * @param data of the JSON file in string format.
  60807. */
  60808. updateFromJSON(data: string): void;
  60809. }
  60810. }
  60811. declare module BABYLON {
  60812. /**
  60813. * 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.
  60814. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  60815. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  60816. */
  60817. export class CustomProceduralTexture extends ProceduralTexture {
  60818. private _animate;
  60819. private _time;
  60820. private _config;
  60821. private _texturePath;
  60822. /**
  60823. * Instantiates a new Custom Procedural Texture.
  60824. * 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.
  60825. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  60826. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  60827. * @param name Define the name of the texture
  60828. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  60829. * @param size Define the size of the texture to create
  60830. * @param scene Define the scene the texture belongs to
  60831. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  60832. * @param generateMipMaps Define if the texture should creates mip maps or not
  60833. */
  60834. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  60835. private _loadJson;
  60836. /**
  60837. * Is the texture ready to be used ? (rendered at least once)
  60838. * @returns true if ready, otherwise, false.
  60839. */
  60840. isReady(): boolean;
  60841. /**
  60842. * Render the texture to its associated render target.
  60843. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  60844. */
  60845. render(useCameraPostProcess?: boolean): void;
  60846. /**
  60847. * Update the list of dependant textures samplers in the shader.
  60848. */
  60849. updateTextures(): void;
  60850. /**
  60851. * Update the uniform values of the procedural texture in the shader.
  60852. */
  60853. updateShaderUniforms(): void;
  60854. /**
  60855. * Define if the texture animates or not.
  60856. */
  60857. get animate(): boolean;
  60858. set animate(value: boolean);
  60859. }
  60860. }
  60861. declare module BABYLON {
  60862. /** @hidden */
  60863. export var noisePixelShader: {
  60864. name: string;
  60865. shader: string;
  60866. };
  60867. }
  60868. declare module BABYLON {
  60869. /**
  60870. * Class used to generate noise procedural textures
  60871. */
  60872. export class NoiseProceduralTexture extends ProceduralTexture {
  60873. private _time;
  60874. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  60875. brightness: number;
  60876. /** Defines the number of octaves to process */
  60877. octaves: number;
  60878. /** Defines the level of persistence (0.8 by default) */
  60879. persistence: number;
  60880. /** Gets or sets animation speed factor (default is 1) */
  60881. animationSpeedFactor: number;
  60882. /**
  60883. * Creates a new NoiseProceduralTexture
  60884. * @param name defines the name fo the texture
  60885. * @param size defines the size of the texture (default is 256)
  60886. * @param scene defines the hosting scene
  60887. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  60888. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  60889. */
  60890. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  60891. private _updateShaderUniforms;
  60892. protected _getDefines(): string;
  60893. /** Generate the current state of the procedural texture */
  60894. render(useCameraPostProcess?: boolean): void;
  60895. /**
  60896. * Serializes this noise procedural texture
  60897. * @returns a serialized noise procedural texture object
  60898. */
  60899. serialize(): any;
  60900. /**
  60901. * Clone the texture.
  60902. * @returns the cloned texture
  60903. */
  60904. clone(): NoiseProceduralTexture;
  60905. /**
  60906. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  60907. * @param parsedTexture defines parsed texture data
  60908. * @param scene defines the current scene
  60909. * @param rootUrl defines the root URL containing noise procedural texture information
  60910. * @returns a parsed NoiseProceduralTexture
  60911. */
  60912. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  60913. }
  60914. }
  60915. declare module BABYLON {
  60916. /**
  60917. * Raw cube texture where the raw buffers are passed in
  60918. */
  60919. export class RawCubeTexture extends CubeTexture {
  60920. /**
  60921. * Creates a cube texture where the raw buffers are passed in.
  60922. * @param scene defines the scene the texture is attached to
  60923. * @param data defines the array of data to use to create each face
  60924. * @param size defines the size of the textures
  60925. * @param format defines the format of the data
  60926. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  60927. * @param generateMipMaps defines if the engine should generate the mip levels
  60928. * @param invertY defines if data must be stored with Y axis inverted
  60929. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  60930. * @param compression defines the compression used (null by default)
  60931. */
  60932. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  60933. /**
  60934. * Updates the raw cube texture.
  60935. * @param data defines the data to store
  60936. * @param format defines the data format
  60937. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60938. * @param invertY defines if data must be stored with Y axis inverted
  60939. * @param compression defines the compression used (null by default)
  60940. * @param level defines which level of the texture to update
  60941. */
  60942. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  60943. /**
  60944. * Updates a raw cube texture with RGBD encoded data.
  60945. * @param data defines the array of data [mipmap][face] to use to create each face
  60946. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  60947. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  60948. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  60949. * @returns a promsie that resolves when the operation is complete
  60950. */
  60951. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  60952. /**
  60953. * Clones the raw cube texture.
  60954. * @return a new cube texture
  60955. */
  60956. clone(): CubeTexture;
  60957. /** @hidden */
  60958. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  60959. }
  60960. }
  60961. declare module BABYLON {
  60962. /**
  60963. * Class used to store 2D array textures containing user data
  60964. */
  60965. export class RawTexture2DArray extends Texture {
  60966. /** Gets or sets the texture format to use */
  60967. format: number;
  60968. /**
  60969. * Create a new RawTexture2DArray
  60970. * @param data defines the data of the texture
  60971. * @param width defines the width of the texture
  60972. * @param height defines the height of the texture
  60973. * @param depth defines the number of layers of the texture
  60974. * @param format defines the texture format to use
  60975. * @param scene defines the hosting scene
  60976. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  60977. * @param invertY defines if texture must be stored with Y axis inverted
  60978. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60979. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  60980. */
  60981. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  60982. /** Gets or sets the texture format to use */
  60983. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  60984. /**
  60985. * Update the texture with new data
  60986. * @param data defines the data to store in the texture
  60987. */
  60988. update(data: ArrayBufferView): void;
  60989. }
  60990. }
  60991. declare module BABYLON {
  60992. /**
  60993. * Class used to store 3D textures containing user data
  60994. */
  60995. export class RawTexture3D extends Texture {
  60996. /** Gets or sets the texture format to use */
  60997. format: number;
  60998. /**
  60999. * Create a new RawTexture3D
  61000. * @param data defines the data of the texture
  61001. * @param width defines the width of the texture
  61002. * @param height defines the height of the texture
  61003. * @param depth defines the depth of the texture
  61004. * @param format defines the texture format to use
  61005. * @param scene defines the hosting scene
  61006. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  61007. * @param invertY defines if texture must be stored with Y axis inverted
  61008. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61009. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  61010. */
  61011. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  61012. /** Gets or sets the texture format to use */
  61013. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  61014. /**
  61015. * Update the texture with new data
  61016. * @param data defines the data to store in the texture
  61017. */
  61018. update(data: ArrayBufferView): void;
  61019. }
  61020. }
  61021. declare module BABYLON {
  61022. /**
  61023. * Creates a refraction texture used by refraction channel of the standard material.
  61024. * It is like a mirror but to see through a material.
  61025. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61026. */
  61027. export class RefractionTexture extends RenderTargetTexture {
  61028. /**
  61029. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  61030. * 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.
  61031. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61032. */
  61033. refractionPlane: Plane;
  61034. /**
  61035. * Define how deep under the surface we should see.
  61036. */
  61037. depth: number;
  61038. /**
  61039. * Creates a refraction texture used by refraction channel of the standard material.
  61040. * It is like a mirror but to see through a material.
  61041. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61042. * @param name Define the texture name
  61043. * @param size Define the size of the underlying texture
  61044. * @param scene Define the scene the refraction belongs to
  61045. * @param generateMipMaps Define if we need to generate mips level for the refraction
  61046. */
  61047. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  61048. /**
  61049. * Clone the refraction texture.
  61050. * @returns the cloned texture
  61051. */
  61052. clone(): RefractionTexture;
  61053. /**
  61054. * Serialize the texture to a JSON representation you could use in Parse later on
  61055. * @returns the serialized JSON representation
  61056. */
  61057. serialize(): any;
  61058. }
  61059. }
  61060. declare module BABYLON {
  61061. /**
  61062. * Block used to add support for vertex skinning (bones)
  61063. */
  61064. export class BonesBlock extends NodeMaterialBlock {
  61065. /**
  61066. * Creates a new BonesBlock
  61067. * @param name defines the block name
  61068. */
  61069. constructor(name: string);
  61070. /**
  61071. * Initialize the block and prepare the context for build
  61072. * @param state defines the state that will be used for the build
  61073. */
  61074. initialize(state: NodeMaterialBuildState): void;
  61075. /**
  61076. * Gets the current class name
  61077. * @returns the class name
  61078. */
  61079. getClassName(): string;
  61080. /**
  61081. * Gets the matrix indices input component
  61082. */
  61083. get matricesIndices(): NodeMaterialConnectionPoint;
  61084. /**
  61085. * Gets the matrix weights input component
  61086. */
  61087. get matricesWeights(): NodeMaterialConnectionPoint;
  61088. /**
  61089. * Gets the extra matrix indices input component
  61090. */
  61091. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  61092. /**
  61093. * Gets the extra matrix weights input component
  61094. */
  61095. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  61096. /**
  61097. * Gets the world input component
  61098. */
  61099. get world(): NodeMaterialConnectionPoint;
  61100. /**
  61101. * Gets the output component
  61102. */
  61103. get output(): NodeMaterialConnectionPoint;
  61104. autoConfigure(material: NodeMaterial): void;
  61105. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61106. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61107. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61108. protected _buildBlock(state: NodeMaterialBuildState): this;
  61109. }
  61110. }
  61111. declare module BABYLON {
  61112. /**
  61113. * Block used to add support for instances
  61114. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  61115. */
  61116. export class InstancesBlock extends NodeMaterialBlock {
  61117. /**
  61118. * Creates a new InstancesBlock
  61119. * @param name defines the block name
  61120. */
  61121. constructor(name: string);
  61122. /**
  61123. * Gets the current class name
  61124. * @returns the class name
  61125. */
  61126. getClassName(): string;
  61127. /**
  61128. * Gets the first world row input component
  61129. */
  61130. get world0(): NodeMaterialConnectionPoint;
  61131. /**
  61132. * Gets the second world row input component
  61133. */
  61134. get world1(): NodeMaterialConnectionPoint;
  61135. /**
  61136. * Gets the third world row input component
  61137. */
  61138. get world2(): NodeMaterialConnectionPoint;
  61139. /**
  61140. * Gets the forth world row input component
  61141. */
  61142. get world3(): NodeMaterialConnectionPoint;
  61143. /**
  61144. * Gets the world input component
  61145. */
  61146. get world(): NodeMaterialConnectionPoint;
  61147. /**
  61148. * Gets the output component
  61149. */
  61150. get output(): NodeMaterialConnectionPoint;
  61151. /**
  61152. * Gets the isntanceID component
  61153. */
  61154. get instanceID(): NodeMaterialConnectionPoint;
  61155. autoConfigure(material: NodeMaterial): void;
  61156. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  61157. protected _buildBlock(state: NodeMaterialBuildState): this;
  61158. }
  61159. }
  61160. declare module BABYLON {
  61161. /**
  61162. * Block used to add morph targets support to vertex shader
  61163. */
  61164. export class MorphTargetsBlock extends NodeMaterialBlock {
  61165. private _repeatableContentAnchor;
  61166. /**
  61167. * Create a new MorphTargetsBlock
  61168. * @param name defines the block name
  61169. */
  61170. constructor(name: string);
  61171. /**
  61172. * Gets the current class name
  61173. * @returns the class name
  61174. */
  61175. getClassName(): string;
  61176. /**
  61177. * Gets the position input component
  61178. */
  61179. get position(): NodeMaterialConnectionPoint;
  61180. /**
  61181. * Gets the normal input component
  61182. */
  61183. get normal(): NodeMaterialConnectionPoint;
  61184. /**
  61185. * Gets the tangent input component
  61186. */
  61187. get tangent(): NodeMaterialConnectionPoint;
  61188. /**
  61189. * Gets the tangent input component
  61190. */
  61191. get uv(): NodeMaterialConnectionPoint;
  61192. /**
  61193. * Gets the position output component
  61194. */
  61195. get positionOutput(): NodeMaterialConnectionPoint;
  61196. /**
  61197. * Gets the normal output component
  61198. */
  61199. get normalOutput(): NodeMaterialConnectionPoint;
  61200. /**
  61201. * Gets the tangent output component
  61202. */
  61203. get tangentOutput(): NodeMaterialConnectionPoint;
  61204. /**
  61205. * Gets the tangent output component
  61206. */
  61207. get uvOutput(): NodeMaterialConnectionPoint;
  61208. initialize(state: NodeMaterialBuildState): void;
  61209. autoConfigure(material: NodeMaterial): void;
  61210. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61211. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61212. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61213. protected _buildBlock(state: NodeMaterialBuildState): this;
  61214. }
  61215. }
  61216. declare module BABYLON {
  61217. /**
  61218. * Block used to get data information from a light
  61219. */
  61220. export class LightInformationBlock extends NodeMaterialBlock {
  61221. private _lightDataUniformName;
  61222. private _lightColorUniformName;
  61223. private _lightTypeDefineName;
  61224. /**
  61225. * Gets or sets the light associated with this block
  61226. */
  61227. light: Nullable<Light>;
  61228. /**
  61229. * Creates a new LightInformationBlock
  61230. * @param name defines the block name
  61231. */
  61232. constructor(name: string);
  61233. /**
  61234. * Gets the current class name
  61235. * @returns the class name
  61236. */
  61237. getClassName(): string;
  61238. /**
  61239. * Gets the world position input component
  61240. */
  61241. get worldPosition(): NodeMaterialConnectionPoint;
  61242. /**
  61243. * Gets the direction output component
  61244. */
  61245. get direction(): NodeMaterialConnectionPoint;
  61246. /**
  61247. * Gets the direction output component
  61248. */
  61249. get color(): NodeMaterialConnectionPoint;
  61250. /**
  61251. * Gets the direction output component
  61252. */
  61253. get intensity(): NodeMaterialConnectionPoint;
  61254. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61255. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61256. protected _buildBlock(state: NodeMaterialBuildState): this;
  61257. serialize(): any;
  61258. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61259. }
  61260. }
  61261. declare module BABYLON {
  61262. /**
  61263. * Block used to add image processing support to fragment shader
  61264. */
  61265. export class ImageProcessingBlock extends NodeMaterialBlock {
  61266. /**
  61267. * Create a new ImageProcessingBlock
  61268. * @param name defines the block name
  61269. */
  61270. constructor(name: string);
  61271. /**
  61272. * Gets the current class name
  61273. * @returns the class name
  61274. */
  61275. getClassName(): string;
  61276. /**
  61277. * Gets the color input component
  61278. */
  61279. get color(): NodeMaterialConnectionPoint;
  61280. /**
  61281. * Gets the output component
  61282. */
  61283. get output(): NodeMaterialConnectionPoint;
  61284. /**
  61285. * Initialize the block and prepare the context for build
  61286. * @param state defines the state that will be used for the build
  61287. */
  61288. initialize(state: NodeMaterialBuildState): void;
  61289. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61290. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61291. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61292. protected _buildBlock(state: NodeMaterialBuildState): this;
  61293. }
  61294. }
  61295. declare module BABYLON {
  61296. /**
  61297. * Block used to pertub normals based on a normal map
  61298. */
  61299. export class PerturbNormalBlock extends NodeMaterialBlock {
  61300. private _tangentSpaceParameterName;
  61301. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61302. invertX: boolean;
  61303. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61304. invertY: boolean;
  61305. /**
  61306. * Create a new PerturbNormalBlock
  61307. * @param name defines the block name
  61308. */
  61309. constructor(name: string);
  61310. /**
  61311. * Gets the current class name
  61312. * @returns the class name
  61313. */
  61314. getClassName(): string;
  61315. /**
  61316. * Gets the world position input component
  61317. */
  61318. get worldPosition(): NodeMaterialConnectionPoint;
  61319. /**
  61320. * Gets the world normal input component
  61321. */
  61322. get worldNormal(): NodeMaterialConnectionPoint;
  61323. /**
  61324. * Gets the world tangent input component
  61325. */
  61326. get worldTangent(): NodeMaterialConnectionPoint;
  61327. /**
  61328. * Gets the uv input component
  61329. */
  61330. get uv(): NodeMaterialConnectionPoint;
  61331. /**
  61332. * Gets the normal map color input component
  61333. */
  61334. get normalMapColor(): NodeMaterialConnectionPoint;
  61335. /**
  61336. * Gets the strength input component
  61337. */
  61338. get strength(): NodeMaterialConnectionPoint;
  61339. /**
  61340. * Gets the output component
  61341. */
  61342. get output(): NodeMaterialConnectionPoint;
  61343. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61344. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61345. autoConfigure(material: NodeMaterial): void;
  61346. protected _buildBlock(state: NodeMaterialBuildState): this;
  61347. protected _dumpPropertiesCode(): string;
  61348. serialize(): any;
  61349. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61350. }
  61351. }
  61352. declare module BABYLON {
  61353. /**
  61354. * Block used to discard a pixel if a value is smaller than a cutoff
  61355. */
  61356. export class DiscardBlock extends NodeMaterialBlock {
  61357. /**
  61358. * Create a new DiscardBlock
  61359. * @param name defines the block name
  61360. */
  61361. constructor(name: string);
  61362. /**
  61363. * Gets the current class name
  61364. * @returns the class name
  61365. */
  61366. getClassName(): string;
  61367. /**
  61368. * Gets the color input component
  61369. */
  61370. get value(): NodeMaterialConnectionPoint;
  61371. /**
  61372. * Gets the cutoff input component
  61373. */
  61374. get cutoff(): NodeMaterialConnectionPoint;
  61375. protected _buildBlock(state: NodeMaterialBuildState): this;
  61376. }
  61377. }
  61378. declare module BABYLON {
  61379. /**
  61380. * Block used to test if the fragment shader is front facing
  61381. */
  61382. export class FrontFacingBlock extends NodeMaterialBlock {
  61383. /**
  61384. * Creates a new FrontFacingBlock
  61385. * @param name defines the block name
  61386. */
  61387. constructor(name: string);
  61388. /**
  61389. * Gets the current class name
  61390. * @returns the class name
  61391. */
  61392. getClassName(): string;
  61393. /**
  61394. * Gets the output component
  61395. */
  61396. get output(): NodeMaterialConnectionPoint;
  61397. protected _buildBlock(state: NodeMaterialBuildState): this;
  61398. }
  61399. }
  61400. declare module BABYLON {
  61401. /**
  61402. * Block used to get the derivative value on x and y of a given input
  61403. */
  61404. export class DerivativeBlock extends NodeMaterialBlock {
  61405. /**
  61406. * Create a new DerivativeBlock
  61407. * @param name defines the block name
  61408. */
  61409. constructor(name: string);
  61410. /**
  61411. * Gets the current class name
  61412. * @returns the class name
  61413. */
  61414. getClassName(): string;
  61415. /**
  61416. * Gets the input component
  61417. */
  61418. get input(): NodeMaterialConnectionPoint;
  61419. /**
  61420. * Gets the derivative output on x
  61421. */
  61422. get dx(): NodeMaterialConnectionPoint;
  61423. /**
  61424. * Gets the derivative output on y
  61425. */
  61426. get dy(): NodeMaterialConnectionPoint;
  61427. protected _buildBlock(state: NodeMaterialBuildState): this;
  61428. }
  61429. }
  61430. declare module BABYLON {
  61431. /**
  61432. * Block used to make gl_FragCoord available
  61433. */
  61434. export class FragCoordBlock extends NodeMaterialBlock {
  61435. /**
  61436. * Creates a new FragCoordBlock
  61437. * @param name defines the block name
  61438. */
  61439. constructor(name: string);
  61440. /**
  61441. * Gets the current class name
  61442. * @returns the class name
  61443. */
  61444. getClassName(): string;
  61445. /**
  61446. * Gets the xy component
  61447. */
  61448. get xy(): NodeMaterialConnectionPoint;
  61449. /**
  61450. * Gets the xyz component
  61451. */
  61452. get xyz(): NodeMaterialConnectionPoint;
  61453. /**
  61454. * Gets the xyzw component
  61455. */
  61456. get xyzw(): NodeMaterialConnectionPoint;
  61457. /**
  61458. * Gets the x component
  61459. */
  61460. get x(): NodeMaterialConnectionPoint;
  61461. /**
  61462. * Gets the y component
  61463. */
  61464. get y(): NodeMaterialConnectionPoint;
  61465. /**
  61466. * Gets the z component
  61467. */
  61468. get z(): NodeMaterialConnectionPoint;
  61469. /**
  61470. * Gets the w component
  61471. */
  61472. get output(): NodeMaterialConnectionPoint;
  61473. protected writeOutputs(state: NodeMaterialBuildState): string;
  61474. protected _buildBlock(state: NodeMaterialBuildState): this;
  61475. }
  61476. }
  61477. declare module BABYLON {
  61478. /**
  61479. * Block used to get the screen sizes
  61480. */
  61481. export class ScreenSizeBlock extends NodeMaterialBlock {
  61482. private _varName;
  61483. private _scene;
  61484. /**
  61485. * Creates a new ScreenSizeBlock
  61486. * @param name defines the block name
  61487. */
  61488. constructor(name: string);
  61489. /**
  61490. * Gets the current class name
  61491. * @returns the class name
  61492. */
  61493. getClassName(): string;
  61494. /**
  61495. * Gets the xy component
  61496. */
  61497. get xy(): NodeMaterialConnectionPoint;
  61498. /**
  61499. * Gets the x component
  61500. */
  61501. get x(): NodeMaterialConnectionPoint;
  61502. /**
  61503. * Gets the y component
  61504. */
  61505. get y(): NodeMaterialConnectionPoint;
  61506. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61507. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  61508. protected _buildBlock(state: NodeMaterialBuildState): this;
  61509. }
  61510. }
  61511. declare module BABYLON {
  61512. /**
  61513. * Block used to add support for scene fog
  61514. */
  61515. export class FogBlock extends NodeMaterialBlock {
  61516. private _fogDistanceName;
  61517. private _fogParameters;
  61518. /**
  61519. * Create a new FogBlock
  61520. * @param name defines the block name
  61521. */
  61522. constructor(name: string);
  61523. /**
  61524. * Gets the current class name
  61525. * @returns the class name
  61526. */
  61527. getClassName(): string;
  61528. /**
  61529. * Gets the world position input component
  61530. */
  61531. get worldPosition(): NodeMaterialConnectionPoint;
  61532. /**
  61533. * Gets the view input component
  61534. */
  61535. get view(): NodeMaterialConnectionPoint;
  61536. /**
  61537. * Gets the color input component
  61538. */
  61539. get input(): NodeMaterialConnectionPoint;
  61540. /**
  61541. * Gets the fog color input component
  61542. */
  61543. get fogColor(): NodeMaterialConnectionPoint;
  61544. /**
  61545. * Gets the output component
  61546. */
  61547. get output(): NodeMaterialConnectionPoint;
  61548. autoConfigure(material: NodeMaterial): void;
  61549. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61550. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61551. protected _buildBlock(state: NodeMaterialBuildState): this;
  61552. }
  61553. }
  61554. declare module BABYLON {
  61555. /**
  61556. * Block used to add light in the fragment shader
  61557. */
  61558. export class LightBlock extends NodeMaterialBlock {
  61559. private _lightId;
  61560. /**
  61561. * Gets or sets the light associated with this block
  61562. */
  61563. light: Nullable<Light>;
  61564. /**
  61565. * Create a new LightBlock
  61566. * @param name defines the block name
  61567. */
  61568. constructor(name: string);
  61569. /**
  61570. * Gets the current class name
  61571. * @returns the class name
  61572. */
  61573. getClassName(): string;
  61574. /**
  61575. * Gets the world position input component
  61576. */
  61577. get worldPosition(): NodeMaterialConnectionPoint;
  61578. /**
  61579. * Gets the world normal input component
  61580. */
  61581. get worldNormal(): NodeMaterialConnectionPoint;
  61582. /**
  61583. * Gets the camera (or eye) position component
  61584. */
  61585. get cameraPosition(): NodeMaterialConnectionPoint;
  61586. /**
  61587. * Gets the glossiness component
  61588. */
  61589. get glossiness(): NodeMaterialConnectionPoint;
  61590. /**
  61591. * Gets the glossinness power component
  61592. */
  61593. get glossPower(): NodeMaterialConnectionPoint;
  61594. /**
  61595. * Gets the diffuse color component
  61596. */
  61597. get diffuseColor(): NodeMaterialConnectionPoint;
  61598. /**
  61599. * Gets the specular color component
  61600. */
  61601. get specularColor(): NodeMaterialConnectionPoint;
  61602. /**
  61603. * Gets the diffuse output component
  61604. */
  61605. get diffuseOutput(): NodeMaterialConnectionPoint;
  61606. /**
  61607. * Gets the specular output component
  61608. */
  61609. get specularOutput(): NodeMaterialConnectionPoint;
  61610. /**
  61611. * Gets the shadow output component
  61612. */
  61613. get shadow(): NodeMaterialConnectionPoint;
  61614. autoConfigure(material: NodeMaterial): void;
  61615. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61616. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61617. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61618. private _injectVertexCode;
  61619. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61620. serialize(): any;
  61621. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61622. }
  61623. }
  61624. declare module BABYLON {
  61625. /**
  61626. * Block used to read a reflection texture from a sampler
  61627. */
  61628. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  61629. /**
  61630. * Create a new ReflectionTextureBlock
  61631. * @param name defines the block name
  61632. */
  61633. constructor(name: string);
  61634. /**
  61635. * Gets the current class name
  61636. * @returns the class name
  61637. */
  61638. getClassName(): string;
  61639. /**
  61640. * Gets the world position input component
  61641. */
  61642. get position(): NodeMaterialConnectionPoint;
  61643. /**
  61644. * Gets the world position input component
  61645. */
  61646. get worldPosition(): NodeMaterialConnectionPoint;
  61647. /**
  61648. * Gets the world normal input component
  61649. */
  61650. get worldNormal(): NodeMaterialConnectionPoint;
  61651. /**
  61652. * Gets the world input component
  61653. */
  61654. get world(): NodeMaterialConnectionPoint;
  61655. /**
  61656. * Gets the camera (or eye) position component
  61657. */
  61658. get cameraPosition(): NodeMaterialConnectionPoint;
  61659. /**
  61660. * Gets the view input component
  61661. */
  61662. get view(): NodeMaterialConnectionPoint;
  61663. /**
  61664. * Gets the rgb output component
  61665. */
  61666. get rgb(): NodeMaterialConnectionPoint;
  61667. /**
  61668. * Gets the r output component
  61669. */
  61670. get r(): NodeMaterialConnectionPoint;
  61671. /**
  61672. * Gets the g output component
  61673. */
  61674. get g(): NodeMaterialConnectionPoint;
  61675. /**
  61676. * Gets the b output component
  61677. */
  61678. get b(): NodeMaterialConnectionPoint;
  61679. autoConfigure(material: NodeMaterial): void;
  61680. protected _buildBlock(state: NodeMaterialBuildState): this;
  61681. }
  61682. }
  61683. declare module BABYLON {
  61684. /**
  61685. * Block used to add 2 vectors
  61686. */
  61687. export class AddBlock extends NodeMaterialBlock {
  61688. /**
  61689. * Creates a new AddBlock
  61690. * @param name defines the block name
  61691. */
  61692. constructor(name: string);
  61693. /**
  61694. * Gets the current class name
  61695. * @returns the class name
  61696. */
  61697. getClassName(): string;
  61698. /**
  61699. * Gets the left operand input component
  61700. */
  61701. get left(): NodeMaterialConnectionPoint;
  61702. /**
  61703. * Gets the right operand input component
  61704. */
  61705. get right(): NodeMaterialConnectionPoint;
  61706. /**
  61707. * Gets the output component
  61708. */
  61709. get output(): NodeMaterialConnectionPoint;
  61710. protected _buildBlock(state: NodeMaterialBuildState): this;
  61711. }
  61712. }
  61713. declare module BABYLON {
  61714. /**
  61715. * Block used to scale a vector by a float
  61716. */
  61717. export class ScaleBlock extends NodeMaterialBlock {
  61718. /**
  61719. * Creates a new ScaleBlock
  61720. * @param name defines the block name
  61721. */
  61722. constructor(name: string);
  61723. /**
  61724. * Gets the current class name
  61725. * @returns the class name
  61726. */
  61727. getClassName(): string;
  61728. /**
  61729. * Gets the input component
  61730. */
  61731. get input(): NodeMaterialConnectionPoint;
  61732. /**
  61733. * Gets the factor input component
  61734. */
  61735. get factor(): NodeMaterialConnectionPoint;
  61736. /**
  61737. * Gets the output component
  61738. */
  61739. get output(): NodeMaterialConnectionPoint;
  61740. protected _buildBlock(state: NodeMaterialBuildState): this;
  61741. }
  61742. }
  61743. declare module BABYLON {
  61744. /**
  61745. * Block used to clamp a float
  61746. */
  61747. export class ClampBlock extends NodeMaterialBlock {
  61748. /** Gets or sets the minimum range */
  61749. minimum: number;
  61750. /** Gets or sets the maximum range */
  61751. maximum: number;
  61752. /**
  61753. * Creates a new ClampBlock
  61754. * @param name defines the block name
  61755. */
  61756. constructor(name: string);
  61757. /**
  61758. * Gets the current class name
  61759. * @returns the class name
  61760. */
  61761. getClassName(): string;
  61762. /**
  61763. * Gets the value input component
  61764. */
  61765. get value(): NodeMaterialConnectionPoint;
  61766. /**
  61767. * Gets the output component
  61768. */
  61769. get output(): NodeMaterialConnectionPoint;
  61770. protected _buildBlock(state: NodeMaterialBuildState): this;
  61771. protected _dumpPropertiesCode(): string;
  61772. serialize(): any;
  61773. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61774. }
  61775. }
  61776. declare module BABYLON {
  61777. /**
  61778. * Block used to apply a cross product between 2 vectors
  61779. */
  61780. export class CrossBlock extends NodeMaterialBlock {
  61781. /**
  61782. * Creates a new CrossBlock
  61783. * @param name defines the block name
  61784. */
  61785. constructor(name: string);
  61786. /**
  61787. * Gets the current class name
  61788. * @returns the class name
  61789. */
  61790. getClassName(): string;
  61791. /**
  61792. * Gets the left operand input component
  61793. */
  61794. get left(): NodeMaterialConnectionPoint;
  61795. /**
  61796. * Gets the right operand input component
  61797. */
  61798. get right(): NodeMaterialConnectionPoint;
  61799. /**
  61800. * Gets the output component
  61801. */
  61802. get output(): NodeMaterialConnectionPoint;
  61803. protected _buildBlock(state: NodeMaterialBuildState): this;
  61804. }
  61805. }
  61806. declare module BABYLON {
  61807. /**
  61808. * Block used to apply a dot product between 2 vectors
  61809. */
  61810. export class DotBlock extends NodeMaterialBlock {
  61811. /**
  61812. * Creates a new DotBlock
  61813. * @param name defines the block name
  61814. */
  61815. constructor(name: string);
  61816. /**
  61817. * Gets the current class name
  61818. * @returns the class name
  61819. */
  61820. getClassName(): string;
  61821. /**
  61822. * Gets the left operand input component
  61823. */
  61824. get left(): NodeMaterialConnectionPoint;
  61825. /**
  61826. * Gets the right operand input component
  61827. */
  61828. get right(): NodeMaterialConnectionPoint;
  61829. /**
  61830. * Gets the output component
  61831. */
  61832. get output(): NodeMaterialConnectionPoint;
  61833. protected _buildBlock(state: NodeMaterialBuildState): this;
  61834. }
  61835. }
  61836. declare module BABYLON {
  61837. /**
  61838. * Block used to normalize a vector
  61839. */
  61840. export class NormalizeBlock extends NodeMaterialBlock {
  61841. /**
  61842. * Creates a new NormalizeBlock
  61843. * @param name defines the block name
  61844. */
  61845. constructor(name: string);
  61846. /**
  61847. * Gets the current class name
  61848. * @returns the class name
  61849. */
  61850. getClassName(): string;
  61851. /**
  61852. * Gets the input component
  61853. */
  61854. get input(): NodeMaterialConnectionPoint;
  61855. /**
  61856. * Gets the output component
  61857. */
  61858. get output(): NodeMaterialConnectionPoint;
  61859. protected _buildBlock(state: NodeMaterialBuildState): this;
  61860. }
  61861. }
  61862. declare module BABYLON {
  61863. /**
  61864. * Operations supported by the Trigonometry block
  61865. */
  61866. export enum TrigonometryBlockOperations {
  61867. /** Cos */
  61868. Cos = 0,
  61869. /** Sin */
  61870. Sin = 1,
  61871. /** Abs */
  61872. Abs = 2,
  61873. /** Exp */
  61874. Exp = 3,
  61875. /** Exp2 */
  61876. Exp2 = 4,
  61877. /** Round */
  61878. Round = 5,
  61879. /** Floor */
  61880. Floor = 6,
  61881. /** Ceiling */
  61882. Ceiling = 7,
  61883. /** Square root */
  61884. Sqrt = 8,
  61885. /** Log */
  61886. Log = 9,
  61887. /** Tangent */
  61888. Tan = 10,
  61889. /** Arc tangent */
  61890. ArcTan = 11,
  61891. /** Arc cosinus */
  61892. ArcCos = 12,
  61893. /** Arc sinus */
  61894. ArcSin = 13,
  61895. /** Fraction */
  61896. Fract = 14,
  61897. /** Sign */
  61898. Sign = 15,
  61899. /** To radians (from degrees) */
  61900. Radians = 16,
  61901. /** To degrees (from radians) */
  61902. Degrees = 17
  61903. }
  61904. /**
  61905. * Block used to apply trigonometry operation to floats
  61906. */
  61907. export class TrigonometryBlock extends NodeMaterialBlock {
  61908. /**
  61909. * Gets or sets the operation applied by the block
  61910. */
  61911. operation: TrigonometryBlockOperations;
  61912. /**
  61913. * Creates a new TrigonometryBlock
  61914. * @param name defines the block name
  61915. */
  61916. constructor(name: string);
  61917. /**
  61918. * Gets the current class name
  61919. * @returns the class name
  61920. */
  61921. getClassName(): string;
  61922. /**
  61923. * Gets the input component
  61924. */
  61925. get input(): NodeMaterialConnectionPoint;
  61926. /**
  61927. * Gets the output component
  61928. */
  61929. get output(): NodeMaterialConnectionPoint;
  61930. protected _buildBlock(state: NodeMaterialBuildState): this;
  61931. serialize(): any;
  61932. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61933. protected _dumpPropertiesCode(): string;
  61934. }
  61935. }
  61936. declare module BABYLON {
  61937. /**
  61938. * Block used to create a Color3/4 out of individual inputs (one for each component)
  61939. */
  61940. export class ColorMergerBlock extends NodeMaterialBlock {
  61941. /**
  61942. * Create a new ColorMergerBlock
  61943. * @param name defines the block name
  61944. */
  61945. constructor(name: string);
  61946. /**
  61947. * Gets the current class name
  61948. * @returns the class name
  61949. */
  61950. getClassName(): string;
  61951. /**
  61952. * Gets the rgb component (input)
  61953. */
  61954. get rgbIn(): NodeMaterialConnectionPoint;
  61955. /**
  61956. * Gets the r component (input)
  61957. */
  61958. get r(): NodeMaterialConnectionPoint;
  61959. /**
  61960. * Gets the g component (input)
  61961. */
  61962. get g(): NodeMaterialConnectionPoint;
  61963. /**
  61964. * Gets the b component (input)
  61965. */
  61966. get b(): NodeMaterialConnectionPoint;
  61967. /**
  61968. * Gets the a component (input)
  61969. */
  61970. get a(): NodeMaterialConnectionPoint;
  61971. /**
  61972. * Gets the rgba component (output)
  61973. */
  61974. get rgba(): NodeMaterialConnectionPoint;
  61975. /**
  61976. * Gets the rgb component (output)
  61977. */
  61978. get rgbOut(): NodeMaterialConnectionPoint;
  61979. /**
  61980. * Gets the rgb component (output)
  61981. * @deprecated Please use rgbOut instead.
  61982. */
  61983. get rgb(): NodeMaterialConnectionPoint;
  61984. protected _buildBlock(state: NodeMaterialBuildState): this;
  61985. }
  61986. }
  61987. declare module BABYLON {
  61988. /**
  61989. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  61990. */
  61991. export class VectorSplitterBlock extends NodeMaterialBlock {
  61992. /**
  61993. * Create a new VectorSplitterBlock
  61994. * @param name defines the block name
  61995. */
  61996. constructor(name: string);
  61997. /**
  61998. * Gets the current class name
  61999. * @returns the class name
  62000. */
  62001. getClassName(): string;
  62002. /**
  62003. * Gets the xyzw component (input)
  62004. */
  62005. get xyzw(): NodeMaterialConnectionPoint;
  62006. /**
  62007. * Gets the xyz component (input)
  62008. */
  62009. get xyzIn(): NodeMaterialConnectionPoint;
  62010. /**
  62011. * Gets the xy component (input)
  62012. */
  62013. get xyIn(): NodeMaterialConnectionPoint;
  62014. /**
  62015. * Gets the xyz component (output)
  62016. */
  62017. get xyzOut(): NodeMaterialConnectionPoint;
  62018. /**
  62019. * Gets the xy component (output)
  62020. */
  62021. get xyOut(): NodeMaterialConnectionPoint;
  62022. /**
  62023. * Gets the x component (output)
  62024. */
  62025. get x(): NodeMaterialConnectionPoint;
  62026. /**
  62027. * Gets the y component (output)
  62028. */
  62029. get y(): NodeMaterialConnectionPoint;
  62030. /**
  62031. * Gets the z component (output)
  62032. */
  62033. get z(): NodeMaterialConnectionPoint;
  62034. /**
  62035. * Gets the w component (output)
  62036. */
  62037. get w(): NodeMaterialConnectionPoint;
  62038. protected _inputRename(name: string): string;
  62039. protected _outputRename(name: string): string;
  62040. protected _buildBlock(state: NodeMaterialBuildState): this;
  62041. }
  62042. }
  62043. declare module BABYLON {
  62044. /**
  62045. * Block used to lerp between 2 values
  62046. */
  62047. export class LerpBlock extends NodeMaterialBlock {
  62048. /**
  62049. * Creates a new LerpBlock
  62050. * @param name defines the block name
  62051. */
  62052. constructor(name: string);
  62053. /**
  62054. * Gets the current class name
  62055. * @returns the class name
  62056. */
  62057. getClassName(): string;
  62058. /**
  62059. * Gets the left operand input component
  62060. */
  62061. get left(): NodeMaterialConnectionPoint;
  62062. /**
  62063. * Gets the right operand input component
  62064. */
  62065. get right(): NodeMaterialConnectionPoint;
  62066. /**
  62067. * Gets the gradient operand input component
  62068. */
  62069. get gradient(): NodeMaterialConnectionPoint;
  62070. /**
  62071. * Gets the output component
  62072. */
  62073. get output(): NodeMaterialConnectionPoint;
  62074. protected _buildBlock(state: NodeMaterialBuildState): this;
  62075. }
  62076. }
  62077. declare module BABYLON {
  62078. /**
  62079. * Block used to divide 2 vectors
  62080. */
  62081. export class DivideBlock extends NodeMaterialBlock {
  62082. /**
  62083. * Creates a new DivideBlock
  62084. * @param name defines the block name
  62085. */
  62086. constructor(name: string);
  62087. /**
  62088. * Gets the current class name
  62089. * @returns the class name
  62090. */
  62091. getClassName(): string;
  62092. /**
  62093. * Gets the left operand input component
  62094. */
  62095. get left(): NodeMaterialConnectionPoint;
  62096. /**
  62097. * Gets the right operand input component
  62098. */
  62099. get right(): NodeMaterialConnectionPoint;
  62100. /**
  62101. * Gets the output component
  62102. */
  62103. get output(): NodeMaterialConnectionPoint;
  62104. protected _buildBlock(state: NodeMaterialBuildState): this;
  62105. }
  62106. }
  62107. declare module BABYLON {
  62108. /**
  62109. * Block used to subtract 2 vectors
  62110. */
  62111. export class SubtractBlock extends NodeMaterialBlock {
  62112. /**
  62113. * Creates a new SubtractBlock
  62114. * @param name defines the block name
  62115. */
  62116. constructor(name: string);
  62117. /**
  62118. * Gets the current class name
  62119. * @returns the class name
  62120. */
  62121. getClassName(): string;
  62122. /**
  62123. * Gets the left operand input component
  62124. */
  62125. get left(): NodeMaterialConnectionPoint;
  62126. /**
  62127. * Gets the right operand input component
  62128. */
  62129. get right(): NodeMaterialConnectionPoint;
  62130. /**
  62131. * Gets the output component
  62132. */
  62133. get output(): NodeMaterialConnectionPoint;
  62134. protected _buildBlock(state: NodeMaterialBuildState): this;
  62135. }
  62136. }
  62137. declare module BABYLON {
  62138. /**
  62139. * Block used to step a value
  62140. */
  62141. export class StepBlock extends NodeMaterialBlock {
  62142. /**
  62143. * Creates a new StepBlock
  62144. * @param name defines the block name
  62145. */
  62146. constructor(name: string);
  62147. /**
  62148. * Gets the current class name
  62149. * @returns the class name
  62150. */
  62151. getClassName(): string;
  62152. /**
  62153. * Gets the value operand input component
  62154. */
  62155. get value(): NodeMaterialConnectionPoint;
  62156. /**
  62157. * Gets the edge operand input component
  62158. */
  62159. get edge(): NodeMaterialConnectionPoint;
  62160. /**
  62161. * Gets the output component
  62162. */
  62163. get output(): NodeMaterialConnectionPoint;
  62164. protected _buildBlock(state: NodeMaterialBuildState): this;
  62165. }
  62166. }
  62167. declare module BABYLON {
  62168. /**
  62169. * Block used to get the opposite (1 - x) of a value
  62170. */
  62171. export class OneMinusBlock extends NodeMaterialBlock {
  62172. /**
  62173. * Creates a new OneMinusBlock
  62174. * @param name defines the block name
  62175. */
  62176. constructor(name: string);
  62177. /**
  62178. * Gets the current class name
  62179. * @returns the class name
  62180. */
  62181. getClassName(): string;
  62182. /**
  62183. * Gets the input component
  62184. */
  62185. get input(): NodeMaterialConnectionPoint;
  62186. /**
  62187. * Gets the output component
  62188. */
  62189. get output(): NodeMaterialConnectionPoint;
  62190. protected _buildBlock(state: NodeMaterialBuildState): this;
  62191. }
  62192. }
  62193. declare module BABYLON {
  62194. /**
  62195. * Block used to get the view direction
  62196. */
  62197. export class ViewDirectionBlock extends NodeMaterialBlock {
  62198. /**
  62199. * Creates a new ViewDirectionBlock
  62200. * @param name defines the block name
  62201. */
  62202. constructor(name: string);
  62203. /**
  62204. * Gets the current class name
  62205. * @returns the class name
  62206. */
  62207. getClassName(): string;
  62208. /**
  62209. * Gets the world position component
  62210. */
  62211. get worldPosition(): NodeMaterialConnectionPoint;
  62212. /**
  62213. * Gets the camera position component
  62214. */
  62215. get cameraPosition(): NodeMaterialConnectionPoint;
  62216. /**
  62217. * Gets the output component
  62218. */
  62219. get output(): NodeMaterialConnectionPoint;
  62220. autoConfigure(material: NodeMaterial): void;
  62221. protected _buildBlock(state: NodeMaterialBuildState): this;
  62222. }
  62223. }
  62224. declare module BABYLON {
  62225. /**
  62226. * Block used to compute fresnel value
  62227. */
  62228. export class FresnelBlock extends NodeMaterialBlock {
  62229. /**
  62230. * Create a new FresnelBlock
  62231. * @param name defines the block name
  62232. */
  62233. constructor(name: string);
  62234. /**
  62235. * Gets the current class name
  62236. * @returns the class name
  62237. */
  62238. getClassName(): string;
  62239. /**
  62240. * Gets the world normal input component
  62241. */
  62242. get worldNormal(): NodeMaterialConnectionPoint;
  62243. /**
  62244. * Gets the view direction input component
  62245. */
  62246. get viewDirection(): NodeMaterialConnectionPoint;
  62247. /**
  62248. * Gets the bias input component
  62249. */
  62250. get bias(): NodeMaterialConnectionPoint;
  62251. /**
  62252. * Gets the camera (or eye) position component
  62253. */
  62254. get power(): NodeMaterialConnectionPoint;
  62255. /**
  62256. * Gets the fresnel output component
  62257. */
  62258. get fresnel(): NodeMaterialConnectionPoint;
  62259. autoConfigure(material: NodeMaterial): void;
  62260. protected _buildBlock(state: NodeMaterialBuildState): this;
  62261. }
  62262. }
  62263. declare module BABYLON {
  62264. /**
  62265. * Block used to get the max of 2 values
  62266. */
  62267. export class MaxBlock extends NodeMaterialBlock {
  62268. /**
  62269. * Creates a new MaxBlock
  62270. * @param name defines the block name
  62271. */
  62272. constructor(name: string);
  62273. /**
  62274. * Gets the current class name
  62275. * @returns the class name
  62276. */
  62277. getClassName(): string;
  62278. /**
  62279. * Gets the left operand input component
  62280. */
  62281. get left(): NodeMaterialConnectionPoint;
  62282. /**
  62283. * Gets the right operand input component
  62284. */
  62285. get right(): NodeMaterialConnectionPoint;
  62286. /**
  62287. * Gets the output component
  62288. */
  62289. get output(): NodeMaterialConnectionPoint;
  62290. protected _buildBlock(state: NodeMaterialBuildState): this;
  62291. }
  62292. }
  62293. declare module BABYLON {
  62294. /**
  62295. * Block used to get the min of 2 values
  62296. */
  62297. export class MinBlock extends NodeMaterialBlock {
  62298. /**
  62299. * Creates a new MinBlock
  62300. * @param name defines the block name
  62301. */
  62302. constructor(name: string);
  62303. /**
  62304. * Gets the current class name
  62305. * @returns the class name
  62306. */
  62307. getClassName(): string;
  62308. /**
  62309. * Gets the left operand input component
  62310. */
  62311. get left(): NodeMaterialConnectionPoint;
  62312. /**
  62313. * Gets the right operand input component
  62314. */
  62315. get right(): NodeMaterialConnectionPoint;
  62316. /**
  62317. * Gets the output component
  62318. */
  62319. get output(): NodeMaterialConnectionPoint;
  62320. protected _buildBlock(state: NodeMaterialBuildState): this;
  62321. }
  62322. }
  62323. declare module BABYLON {
  62324. /**
  62325. * Block used to get the distance between 2 values
  62326. */
  62327. export class DistanceBlock extends NodeMaterialBlock {
  62328. /**
  62329. * Creates a new DistanceBlock
  62330. * @param name defines the block name
  62331. */
  62332. constructor(name: string);
  62333. /**
  62334. * Gets the current class name
  62335. * @returns the class name
  62336. */
  62337. getClassName(): string;
  62338. /**
  62339. * Gets the left operand input component
  62340. */
  62341. get left(): NodeMaterialConnectionPoint;
  62342. /**
  62343. * Gets the right operand input component
  62344. */
  62345. get right(): NodeMaterialConnectionPoint;
  62346. /**
  62347. * Gets the output component
  62348. */
  62349. get output(): NodeMaterialConnectionPoint;
  62350. protected _buildBlock(state: NodeMaterialBuildState): this;
  62351. }
  62352. }
  62353. declare module BABYLON {
  62354. /**
  62355. * Block used to get the length of a vector
  62356. */
  62357. export class LengthBlock extends NodeMaterialBlock {
  62358. /**
  62359. * Creates a new LengthBlock
  62360. * @param name defines the block name
  62361. */
  62362. constructor(name: string);
  62363. /**
  62364. * Gets the current class name
  62365. * @returns the class name
  62366. */
  62367. getClassName(): string;
  62368. /**
  62369. * Gets the value input component
  62370. */
  62371. get value(): NodeMaterialConnectionPoint;
  62372. /**
  62373. * Gets the output component
  62374. */
  62375. get output(): NodeMaterialConnectionPoint;
  62376. protected _buildBlock(state: NodeMaterialBuildState): this;
  62377. }
  62378. }
  62379. declare module BABYLON {
  62380. /**
  62381. * Block used to get negative version of a value (i.e. x * -1)
  62382. */
  62383. export class NegateBlock extends NodeMaterialBlock {
  62384. /**
  62385. * Creates a new NegateBlock
  62386. * @param name defines the block name
  62387. */
  62388. constructor(name: string);
  62389. /**
  62390. * Gets the current class name
  62391. * @returns the class name
  62392. */
  62393. getClassName(): string;
  62394. /**
  62395. * Gets the value input component
  62396. */
  62397. get value(): NodeMaterialConnectionPoint;
  62398. /**
  62399. * Gets the output component
  62400. */
  62401. get output(): NodeMaterialConnectionPoint;
  62402. protected _buildBlock(state: NodeMaterialBuildState): this;
  62403. }
  62404. }
  62405. declare module BABYLON {
  62406. /**
  62407. * Block used to get the value of the first parameter raised to the power of the second
  62408. */
  62409. export class PowBlock extends NodeMaterialBlock {
  62410. /**
  62411. * Creates a new PowBlock
  62412. * @param name defines the block name
  62413. */
  62414. constructor(name: string);
  62415. /**
  62416. * Gets the current class name
  62417. * @returns the class name
  62418. */
  62419. getClassName(): string;
  62420. /**
  62421. * Gets the value operand input component
  62422. */
  62423. get value(): NodeMaterialConnectionPoint;
  62424. /**
  62425. * Gets the power operand input component
  62426. */
  62427. get power(): NodeMaterialConnectionPoint;
  62428. /**
  62429. * Gets the output component
  62430. */
  62431. get output(): NodeMaterialConnectionPoint;
  62432. protected _buildBlock(state: NodeMaterialBuildState): this;
  62433. }
  62434. }
  62435. declare module BABYLON {
  62436. /**
  62437. * Block used to get a random number
  62438. */
  62439. export class RandomNumberBlock extends NodeMaterialBlock {
  62440. /**
  62441. * Creates a new RandomNumberBlock
  62442. * @param name defines the block name
  62443. */
  62444. constructor(name: string);
  62445. /**
  62446. * Gets the current class name
  62447. * @returns the class name
  62448. */
  62449. getClassName(): string;
  62450. /**
  62451. * Gets the seed input component
  62452. */
  62453. get seed(): NodeMaterialConnectionPoint;
  62454. /**
  62455. * Gets the output component
  62456. */
  62457. get output(): NodeMaterialConnectionPoint;
  62458. protected _buildBlock(state: NodeMaterialBuildState): this;
  62459. }
  62460. }
  62461. declare module BABYLON {
  62462. /**
  62463. * Block used to compute arc tangent of 2 values
  62464. */
  62465. export class ArcTan2Block extends NodeMaterialBlock {
  62466. /**
  62467. * Creates a new ArcTan2Block
  62468. * @param name defines the block name
  62469. */
  62470. constructor(name: string);
  62471. /**
  62472. * Gets the current class name
  62473. * @returns the class name
  62474. */
  62475. getClassName(): string;
  62476. /**
  62477. * Gets the x operand input component
  62478. */
  62479. get x(): NodeMaterialConnectionPoint;
  62480. /**
  62481. * Gets the y operand input component
  62482. */
  62483. get y(): NodeMaterialConnectionPoint;
  62484. /**
  62485. * Gets the output component
  62486. */
  62487. get output(): NodeMaterialConnectionPoint;
  62488. protected _buildBlock(state: NodeMaterialBuildState): this;
  62489. }
  62490. }
  62491. declare module BABYLON {
  62492. /**
  62493. * Block used to smooth step a value
  62494. */
  62495. export class SmoothStepBlock extends NodeMaterialBlock {
  62496. /**
  62497. * Creates a new SmoothStepBlock
  62498. * @param name defines the block name
  62499. */
  62500. constructor(name: string);
  62501. /**
  62502. * Gets the current class name
  62503. * @returns the class name
  62504. */
  62505. getClassName(): string;
  62506. /**
  62507. * Gets the value operand input component
  62508. */
  62509. get value(): NodeMaterialConnectionPoint;
  62510. /**
  62511. * Gets the first edge operand input component
  62512. */
  62513. get edge0(): NodeMaterialConnectionPoint;
  62514. /**
  62515. * Gets the second edge operand input component
  62516. */
  62517. get edge1(): NodeMaterialConnectionPoint;
  62518. /**
  62519. * Gets the output component
  62520. */
  62521. get output(): NodeMaterialConnectionPoint;
  62522. protected _buildBlock(state: NodeMaterialBuildState): this;
  62523. }
  62524. }
  62525. declare module BABYLON {
  62526. /**
  62527. * Block used to get the reciprocal (1 / x) of a value
  62528. */
  62529. export class ReciprocalBlock extends NodeMaterialBlock {
  62530. /**
  62531. * Creates a new ReciprocalBlock
  62532. * @param name defines the block name
  62533. */
  62534. constructor(name: string);
  62535. /**
  62536. * Gets the current class name
  62537. * @returns the class name
  62538. */
  62539. getClassName(): string;
  62540. /**
  62541. * Gets the input component
  62542. */
  62543. get input(): NodeMaterialConnectionPoint;
  62544. /**
  62545. * Gets the output component
  62546. */
  62547. get output(): NodeMaterialConnectionPoint;
  62548. protected _buildBlock(state: NodeMaterialBuildState): this;
  62549. }
  62550. }
  62551. declare module BABYLON {
  62552. /**
  62553. * Block used to replace a color by another one
  62554. */
  62555. export class ReplaceColorBlock extends NodeMaterialBlock {
  62556. /**
  62557. * Creates a new ReplaceColorBlock
  62558. * @param name defines the block name
  62559. */
  62560. constructor(name: string);
  62561. /**
  62562. * Gets the current class name
  62563. * @returns the class name
  62564. */
  62565. getClassName(): string;
  62566. /**
  62567. * Gets the value input component
  62568. */
  62569. get value(): NodeMaterialConnectionPoint;
  62570. /**
  62571. * Gets the reference input component
  62572. */
  62573. get reference(): NodeMaterialConnectionPoint;
  62574. /**
  62575. * Gets the distance input component
  62576. */
  62577. get distance(): NodeMaterialConnectionPoint;
  62578. /**
  62579. * Gets the replacement input component
  62580. */
  62581. get replacement(): NodeMaterialConnectionPoint;
  62582. /**
  62583. * Gets the output component
  62584. */
  62585. get output(): NodeMaterialConnectionPoint;
  62586. protected _buildBlock(state: NodeMaterialBuildState): this;
  62587. }
  62588. }
  62589. declare module BABYLON {
  62590. /**
  62591. * Block used to posterize a value
  62592. * @see https://en.wikipedia.org/wiki/Posterization
  62593. */
  62594. export class PosterizeBlock extends NodeMaterialBlock {
  62595. /**
  62596. * Creates a new PosterizeBlock
  62597. * @param name defines the block name
  62598. */
  62599. constructor(name: string);
  62600. /**
  62601. * Gets the current class name
  62602. * @returns the class name
  62603. */
  62604. getClassName(): string;
  62605. /**
  62606. * Gets the value input component
  62607. */
  62608. get value(): NodeMaterialConnectionPoint;
  62609. /**
  62610. * Gets the steps input component
  62611. */
  62612. get steps(): NodeMaterialConnectionPoint;
  62613. /**
  62614. * Gets the output component
  62615. */
  62616. get output(): NodeMaterialConnectionPoint;
  62617. protected _buildBlock(state: NodeMaterialBuildState): this;
  62618. }
  62619. }
  62620. declare module BABYLON {
  62621. /**
  62622. * Operations supported by the Wave block
  62623. */
  62624. export enum WaveBlockKind {
  62625. /** SawTooth */
  62626. SawTooth = 0,
  62627. /** Square */
  62628. Square = 1,
  62629. /** Triangle */
  62630. Triangle = 2
  62631. }
  62632. /**
  62633. * Block used to apply wave operation to floats
  62634. */
  62635. export class WaveBlock extends NodeMaterialBlock {
  62636. /**
  62637. * Gets or sets the kibnd of wave to be applied by the block
  62638. */
  62639. kind: WaveBlockKind;
  62640. /**
  62641. * Creates a new WaveBlock
  62642. * @param name defines the block name
  62643. */
  62644. constructor(name: string);
  62645. /**
  62646. * Gets the current class name
  62647. * @returns the class name
  62648. */
  62649. getClassName(): string;
  62650. /**
  62651. * Gets the input component
  62652. */
  62653. get input(): NodeMaterialConnectionPoint;
  62654. /**
  62655. * Gets the output component
  62656. */
  62657. get output(): NodeMaterialConnectionPoint;
  62658. protected _buildBlock(state: NodeMaterialBuildState): this;
  62659. serialize(): any;
  62660. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62661. }
  62662. }
  62663. declare module BABYLON {
  62664. /**
  62665. * Class used to store a color step for the GradientBlock
  62666. */
  62667. export class GradientBlockColorStep {
  62668. /**
  62669. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62670. */
  62671. step: number;
  62672. /**
  62673. * Gets or sets the color associated with this step
  62674. */
  62675. color: Color3;
  62676. /**
  62677. * Creates a new GradientBlockColorStep
  62678. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62679. * @param color defines the color associated with this step
  62680. */
  62681. constructor(
  62682. /**
  62683. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62684. */
  62685. step: number,
  62686. /**
  62687. * Gets or sets the color associated with this step
  62688. */
  62689. color: Color3);
  62690. }
  62691. /**
  62692. * Block used to return a color from a gradient based on an input value between 0 and 1
  62693. */
  62694. export class GradientBlock extends NodeMaterialBlock {
  62695. /**
  62696. * Gets or sets the list of color steps
  62697. */
  62698. colorSteps: GradientBlockColorStep[];
  62699. /**
  62700. * Creates a new GradientBlock
  62701. * @param name defines the block name
  62702. */
  62703. constructor(name: string);
  62704. /**
  62705. * Gets the current class name
  62706. * @returns the class name
  62707. */
  62708. getClassName(): string;
  62709. /**
  62710. * Gets the gradient input component
  62711. */
  62712. get gradient(): NodeMaterialConnectionPoint;
  62713. /**
  62714. * Gets the output component
  62715. */
  62716. get output(): NodeMaterialConnectionPoint;
  62717. private _writeColorConstant;
  62718. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62719. serialize(): any;
  62720. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62721. protected _dumpPropertiesCode(): string;
  62722. }
  62723. }
  62724. declare module BABYLON {
  62725. /**
  62726. * Block used to normalize lerp between 2 values
  62727. */
  62728. export class NLerpBlock extends NodeMaterialBlock {
  62729. /**
  62730. * Creates a new NLerpBlock
  62731. * @param name defines the block name
  62732. */
  62733. constructor(name: string);
  62734. /**
  62735. * Gets the current class name
  62736. * @returns the class name
  62737. */
  62738. getClassName(): string;
  62739. /**
  62740. * Gets the left operand input component
  62741. */
  62742. get left(): NodeMaterialConnectionPoint;
  62743. /**
  62744. * Gets the right operand input component
  62745. */
  62746. get right(): NodeMaterialConnectionPoint;
  62747. /**
  62748. * Gets the gradient operand input component
  62749. */
  62750. get gradient(): NodeMaterialConnectionPoint;
  62751. /**
  62752. * Gets the output component
  62753. */
  62754. get output(): NodeMaterialConnectionPoint;
  62755. protected _buildBlock(state: NodeMaterialBuildState): this;
  62756. }
  62757. }
  62758. declare module BABYLON {
  62759. /**
  62760. * block used to Generate a Worley Noise 3D Noise Pattern
  62761. */
  62762. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62763. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62764. manhattanDistance: boolean;
  62765. /**
  62766. * Creates a new WorleyNoise3DBlock
  62767. * @param name defines the block name
  62768. */
  62769. constructor(name: string);
  62770. /**
  62771. * Gets the current class name
  62772. * @returns the class name
  62773. */
  62774. getClassName(): string;
  62775. /**
  62776. * Gets the seed input component
  62777. */
  62778. get seed(): NodeMaterialConnectionPoint;
  62779. /**
  62780. * Gets the jitter input component
  62781. */
  62782. get jitter(): NodeMaterialConnectionPoint;
  62783. /**
  62784. * Gets the output component
  62785. */
  62786. get output(): NodeMaterialConnectionPoint;
  62787. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62788. /**
  62789. * Exposes the properties to the UI?
  62790. */
  62791. protected _dumpPropertiesCode(): string;
  62792. /**
  62793. * Exposes the properties to the Seralize?
  62794. */
  62795. serialize(): any;
  62796. /**
  62797. * Exposes the properties to the deseralize?
  62798. */
  62799. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62800. }
  62801. }
  62802. declare module BABYLON {
  62803. /**
  62804. * block used to Generate a Simplex Perlin 3d Noise Pattern
  62805. */
  62806. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  62807. /**
  62808. * Creates a new SimplexPerlin3DBlock
  62809. * @param name defines the block name
  62810. */
  62811. constructor(name: string);
  62812. /**
  62813. * Gets the current class name
  62814. * @returns the class name
  62815. */
  62816. getClassName(): string;
  62817. /**
  62818. * Gets the seed operand input component
  62819. */
  62820. get seed(): NodeMaterialConnectionPoint;
  62821. /**
  62822. * Gets the output component
  62823. */
  62824. get output(): NodeMaterialConnectionPoint;
  62825. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62826. }
  62827. }
  62828. declare module BABYLON {
  62829. /**
  62830. * Block used to blend normals
  62831. */
  62832. export class NormalBlendBlock extends NodeMaterialBlock {
  62833. /**
  62834. * Creates a new NormalBlendBlock
  62835. * @param name defines the block name
  62836. */
  62837. constructor(name: string);
  62838. /**
  62839. * Gets the current class name
  62840. * @returns the class name
  62841. */
  62842. getClassName(): string;
  62843. /**
  62844. * Gets the first input component
  62845. */
  62846. get normalMap0(): NodeMaterialConnectionPoint;
  62847. /**
  62848. * Gets the second input component
  62849. */
  62850. get normalMap1(): NodeMaterialConnectionPoint;
  62851. /**
  62852. * Gets the output component
  62853. */
  62854. get output(): NodeMaterialConnectionPoint;
  62855. protected _buildBlock(state: NodeMaterialBuildState): this;
  62856. }
  62857. }
  62858. declare module BABYLON {
  62859. /**
  62860. * Block used to rotate a 2d vector by a given angle
  62861. */
  62862. export class Rotate2dBlock extends NodeMaterialBlock {
  62863. /**
  62864. * Creates a new Rotate2dBlock
  62865. * @param name defines the block name
  62866. */
  62867. constructor(name: string);
  62868. /**
  62869. * Gets the current class name
  62870. * @returns the class name
  62871. */
  62872. getClassName(): string;
  62873. /**
  62874. * Gets the input vector
  62875. */
  62876. get input(): NodeMaterialConnectionPoint;
  62877. /**
  62878. * Gets the input angle
  62879. */
  62880. get angle(): NodeMaterialConnectionPoint;
  62881. /**
  62882. * Gets the output component
  62883. */
  62884. get output(): NodeMaterialConnectionPoint;
  62885. autoConfigure(material: NodeMaterial): void;
  62886. protected _buildBlock(state: NodeMaterialBuildState): this;
  62887. }
  62888. }
  62889. declare module BABYLON {
  62890. /**
  62891. * Block used to get the reflected vector from a direction and a normal
  62892. */
  62893. export class ReflectBlock extends NodeMaterialBlock {
  62894. /**
  62895. * Creates a new ReflectBlock
  62896. * @param name defines the block name
  62897. */
  62898. constructor(name: string);
  62899. /**
  62900. * Gets the current class name
  62901. * @returns the class name
  62902. */
  62903. getClassName(): string;
  62904. /**
  62905. * Gets the incident component
  62906. */
  62907. get incident(): NodeMaterialConnectionPoint;
  62908. /**
  62909. * Gets the normal component
  62910. */
  62911. get normal(): NodeMaterialConnectionPoint;
  62912. /**
  62913. * Gets the output component
  62914. */
  62915. get output(): NodeMaterialConnectionPoint;
  62916. protected _buildBlock(state: NodeMaterialBuildState): this;
  62917. }
  62918. }
  62919. declare module BABYLON {
  62920. /**
  62921. * Block used to get the refracted vector from a direction and a normal
  62922. */
  62923. export class RefractBlock extends NodeMaterialBlock {
  62924. /**
  62925. * Creates a new RefractBlock
  62926. * @param name defines the block name
  62927. */
  62928. constructor(name: string);
  62929. /**
  62930. * Gets the current class name
  62931. * @returns the class name
  62932. */
  62933. getClassName(): string;
  62934. /**
  62935. * Gets the incident component
  62936. */
  62937. get incident(): NodeMaterialConnectionPoint;
  62938. /**
  62939. * Gets the normal component
  62940. */
  62941. get normal(): NodeMaterialConnectionPoint;
  62942. /**
  62943. * Gets the index of refraction component
  62944. */
  62945. get ior(): NodeMaterialConnectionPoint;
  62946. /**
  62947. * Gets the output component
  62948. */
  62949. get output(): NodeMaterialConnectionPoint;
  62950. protected _buildBlock(state: NodeMaterialBuildState): this;
  62951. }
  62952. }
  62953. declare module BABYLON {
  62954. /**
  62955. * Block used to desaturate a color
  62956. */
  62957. export class DesaturateBlock extends NodeMaterialBlock {
  62958. /**
  62959. * Creates a new DesaturateBlock
  62960. * @param name defines the block name
  62961. */
  62962. constructor(name: string);
  62963. /**
  62964. * Gets the current class name
  62965. * @returns the class name
  62966. */
  62967. getClassName(): string;
  62968. /**
  62969. * Gets the color operand input component
  62970. */
  62971. get color(): NodeMaterialConnectionPoint;
  62972. /**
  62973. * Gets the level operand input component
  62974. */
  62975. get level(): NodeMaterialConnectionPoint;
  62976. /**
  62977. * Gets the output component
  62978. */
  62979. get output(): NodeMaterialConnectionPoint;
  62980. protected _buildBlock(state: NodeMaterialBuildState): this;
  62981. }
  62982. }
  62983. declare module BABYLON {
  62984. /**
  62985. * Block used to implement the ambient occlusion module of the PBR material
  62986. */
  62987. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  62988. /**
  62989. * Create a new AmbientOcclusionBlock
  62990. * @param name defines the block name
  62991. */
  62992. constructor(name: string);
  62993. /**
  62994. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  62995. */
  62996. useAmbientInGrayScale: boolean;
  62997. /**
  62998. * Initialize the block and prepare the context for build
  62999. * @param state defines the state that will be used for the build
  63000. */
  63001. initialize(state: NodeMaterialBuildState): void;
  63002. /**
  63003. * Gets the current class name
  63004. * @returns the class name
  63005. */
  63006. getClassName(): string;
  63007. /**
  63008. * Gets the texture input component
  63009. */
  63010. get texture(): NodeMaterialConnectionPoint;
  63011. /**
  63012. * Gets the texture intensity component
  63013. */
  63014. get intensity(): NodeMaterialConnectionPoint;
  63015. /**
  63016. * Gets the direct light intensity input component
  63017. */
  63018. get directLightIntensity(): NodeMaterialConnectionPoint;
  63019. /**
  63020. * Gets the ambient occlusion object output component
  63021. */
  63022. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63023. /**
  63024. * Gets the main code of the block (fragment side)
  63025. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  63026. * @returns the shader code
  63027. */
  63028. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  63029. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63030. protected _buildBlock(state: NodeMaterialBuildState): this;
  63031. protected _dumpPropertiesCode(): string;
  63032. serialize(): any;
  63033. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63034. }
  63035. }
  63036. declare module BABYLON {
  63037. /**
  63038. * Block used to implement the reflection module of the PBR material
  63039. */
  63040. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  63041. /** @hidden */
  63042. _defineLODReflectionAlpha: string;
  63043. /** @hidden */
  63044. _defineLinearSpecularReflection: string;
  63045. private _vEnvironmentIrradianceName;
  63046. /** @hidden */
  63047. _vReflectionMicrosurfaceInfosName: string;
  63048. /** @hidden */
  63049. _vReflectionInfosName: string;
  63050. /** @hidden */
  63051. _vReflectionFilteringInfoName: string;
  63052. private _scene;
  63053. /**
  63054. * The three properties below are set by the main PBR block prior to calling methods of this class.
  63055. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  63056. * It's less burden on the user side in the editor part.
  63057. */
  63058. /** @hidden */
  63059. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  63060. /** @hidden */
  63061. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  63062. /** @hidden */
  63063. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  63064. /**
  63065. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  63066. * diffuse part of the IBL.
  63067. */
  63068. useSphericalHarmonics: boolean;
  63069. /**
  63070. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  63071. */
  63072. forceIrradianceInFragment: boolean;
  63073. /**
  63074. * Create a new ReflectionBlock
  63075. * @param name defines the block name
  63076. */
  63077. constructor(name: string);
  63078. /**
  63079. * Gets the current class name
  63080. * @returns the class name
  63081. */
  63082. getClassName(): string;
  63083. /**
  63084. * Gets the position input component
  63085. */
  63086. get position(): NodeMaterialConnectionPoint;
  63087. /**
  63088. * Gets the world position input component
  63089. */
  63090. get worldPosition(): NodeMaterialConnectionPoint;
  63091. /**
  63092. * Gets the world normal input component
  63093. */
  63094. get worldNormal(): NodeMaterialConnectionPoint;
  63095. /**
  63096. * Gets the world input component
  63097. */
  63098. get world(): NodeMaterialConnectionPoint;
  63099. /**
  63100. * Gets the camera (or eye) position component
  63101. */
  63102. get cameraPosition(): NodeMaterialConnectionPoint;
  63103. /**
  63104. * Gets the view input component
  63105. */
  63106. get view(): NodeMaterialConnectionPoint;
  63107. /**
  63108. * Gets the color input component
  63109. */
  63110. get color(): NodeMaterialConnectionPoint;
  63111. /**
  63112. * Gets the reflection object output component
  63113. */
  63114. get reflection(): NodeMaterialConnectionPoint;
  63115. /**
  63116. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  63117. */
  63118. get hasTexture(): boolean;
  63119. /**
  63120. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  63121. */
  63122. get reflectionColor(): string;
  63123. protected _getTexture(): Nullable<BaseTexture>;
  63124. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63125. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63126. /**
  63127. * Gets the code to inject in the vertex shader
  63128. * @param state current state of the node material building
  63129. * @returns the shader code
  63130. */
  63131. handleVertexSide(state: NodeMaterialBuildState): string;
  63132. /**
  63133. * Gets the main code of the block (fragment side)
  63134. * @param state current state of the node material building
  63135. * @param normalVarName name of the existing variable corresponding to the normal
  63136. * @returns the shader code
  63137. */
  63138. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  63139. protected _buildBlock(state: NodeMaterialBuildState): this;
  63140. protected _dumpPropertiesCode(): string;
  63141. serialize(): any;
  63142. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63143. }
  63144. }
  63145. declare module BABYLON {
  63146. /**
  63147. * Block used to implement the sheen module of the PBR material
  63148. */
  63149. export class SheenBlock extends NodeMaterialBlock {
  63150. /**
  63151. * Create a new SheenBlock
  63152. * @param name defines the block name
  63153. */
  63154. constructor(name: string);
  63155. /**
  63156. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  63157. * It allows the strength of the sheen effect to not depend on the base color of the material,
  63158. * making it easier to setup and tweak the effect
  63159. */
  63160. albedoScaling: boolean;
  63161. /**
  63162. * Defines if the sheen is linked to the sheen color.
  63163. */
  63164. linkSheenWithAlbedo: boolean;
  63165. /**
  63166. * Initialize the block and prepare the context for build
  63167. * @param state defines the state that will be used for the build
  63168. */
  63169. initialize(state: NodeMaterialBuildState): void;
  63170. /**
  63171. * Gets the current class name
  63172. * @returns the class name
  63173. */
  63174. getClassName(): string;
  63175. /**
  63176. * Gets the intensity input component
  63177. */
  63178. get intensity(): NodeMaterialConnectionPoint;
  63179. /**
  63180. * Gets the color input component
  63181. */
  63182. get color(): NodeMaterialConnectionPoint;
  63183. /**
  63184. * Gets the roughness input component
  63185. */
  63186. get roughness(): NodeMaterialConnectionPoint;
  63187. /**
  63188. * Gets the sheen object output component
  63189. */
  63190. get sheen(): NodeMaterialConnectionPoint;
  63191. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63192. /**
  63193. * Gets the main code of the block (fragment side)
  63194. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63195. * @returns the shader code
  63196. */
  63197. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  63198. protected _buildBlock(state: NodeMaterialBuildState): this;
  63199. protected _dumpPropertiesCode(): string;
  63200. serialize(): any;
  63201. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63202. }
  63203. }
  63204. declare module BABYLON {
  63205. /**
  63206. * Block used to implement the reflectivity module of the PBR material
  63207. */
  63208. export class ReflectivityBlock extends NodeMaterialBlock {
  63209. private _metallicReflectanceColor;
  63210. private _metallicF0Factor;
  63211. /** @hidden */
  63212. _vMetallicReflectanceFactorsName: string;
  63213. /**
  63214. * The property below is set by the main PBR block prior to calling methods of this class.
  63215. */
  63216. /** @hidden */
  63217. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  63218. /**
  63219. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  63220. */
  63221. useAmbientOcclusionFromMetallicTextureRed: boolean;
  63222. /**
  63223. * Specifies if the metallic texture contains the metallness information in its blue channel.
  63224. */
  63225. useMetallnessFromMetallicTextureBlue: boolean;
  63226. /**
  63227. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  63228. */
  63229. useRoughnessFromMetallicTextureAlpha: boolean;
  63230. /**
  63231. * Specifies if the metallic texture contains the roughness information in its green channel.
  63232. */
  63233. useRoughnessFromMetallicTextureGreen: boolean;
  63234. /**
  63235. * Create a new ReflectivityBlock
  63236. * @param name defines the block name
  63237. */
  63238. constructor(name: string);
  63239. /**
  63240. * Initialize the block and prepare the context for build
  63241. * @param state defines the state that will be used for the build
  63242. */
  63243. initialize(state: NodeMaterialBuildState): void;
  63244. /**
  63245. * Gets the current class name
  63246. * @returns the class name
  63247. */
  63248. getClassName(): string;
  63249. /**
  63250. * Gets the metallic input component
  63251. */
  63252. get metallic(): NodeMaterialConnectionPoint;
  63253. /**
  63254. * Gets the roughness input component
  63255. */
  63256. get roughness(): NodeMaterialConnectionPoint;
  63257. /**
  63258. * Gets the texture input component
  63259. */
  63260. get texture(): NodeMaterialConnectionPoint;
  63261. /**
  63262. * Gets the reflectivity object output component
  63263. */
  63264. get reflectivity(): NodeMaterialConnectionPoint;
  63265. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63266. /**
  63267. * Gets the main code of the block (fragment side)
  63268. * @param state current state of the node material building
  63269. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  63270. * @returns the shader code
  63271. */
  63272. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  63273. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63274. protected _buildBlock(state: NodeMaterialBuildState): this;
  63275. protected _dumpPropertiesCode(): string;
  63276. serialize(): any;
  63277. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63278. }
  63279. }
  63280. declare module BABYLON {
  63281. /**
  63282. * Block used to implement the anisotropy module of the PBR material
  63283. */
  63284. export class AnisotropyBlock extends NodeMaterialBlock {
  63285. /**
  63286. * The two properties below are set by the main PBR block prior to calling methods of this class.
  63287. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  63288. * It's less burden on the user side in the editor part.
  63289. */
  63290. /** @hidden */
  63291. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  63292. /** @hidden */
  63293. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  63294. /**
  63295. * Create a new AnisotropyBlock
  63296. * @param name defines the block name
  63297. */
  63298. constructor(name: string);
  63299. /**
  63300. * Initialize the block and prepare the context for build
  63301. * @param state defines the state that will be used for the build
  63302. */
  63303. initialize(state: NodeMaterialBuildState): void;
  63304. /**
  63305. * Gets the current class name
  63306. * @returns the class name
  63307. */
  63308. getClassName(): string;
  63309. /**
  63310. * Gets the intensity input component
  63311. */
  63312. get intensity(): NodeMaterialConnectionPoint;
  63313. /**
  63314. * Gets the direction input component
  63315. */
  63316. get direction(): NodeMaterialConnectionPoint;
  63317. /**
  63318. * Gets the texture input component
  63319. */
  63320. get texture(): NodeMaterialConnectionPoint;
  63321. /**
  63322. * Gets the uv input component
  63323. */
  63324. get uv(): NodeMaterialConnectionPoint;
  63325. /**
  63326. * Gets the worldTangent input component
  63327. */
  63328. get worldTangent(): NodeMaterialConnectionPoint;
  63329. /**
  63330. * Gets the anisotropy object output component
  63331. */
  63332. get anisotropy(): NodeMaterialConnectionPoint;
  63333. private _generateTBNSpace;
  63334. /**
  63335. * Gets the main code of the block (fragment side)
  63336. * @param state current state of the node material building
  63337. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  63338. * @returns the shader code
  63339. */
  63340. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  63341. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63342. protected _buildBlock(state: NodeMaterialBuildState): this;
  63343. }
  63344. }
  63345. declare module BABYLON {
  63346. /**
  63347. * Block used to implement the clear coat module of the PBR material
  63348. */
  63349. export class ClearCoatBlock extends NodeMaterialBlock {
  63350. private _scene;
  63351. /**
  63352. * Create a new ClearCoatBlock
  63353. * @param name defines the block name
  63354. */
  63355. constructor(name: string);
  63356. /**
  63357. * Initialize the block and prepare the context for build
  63358. * @param state defines the state that will be used for the build
  63359. */
  63360. initialize(state: NodeMaterialBuildState): void;
  63361. /**
  63362. * Gets the current class name
  63363. * @returns the class name
  63364. */
  63365. getClassName(): string;
  63366. /**
  63367. * Gets the intensity input component
  63368. */
  63369. get intensity(): NodeMaterialConnectionPoint;
  63370. /**
  63371. * Gets the roughness input component
  63372. */
  63373. get roughness(): NodeMaterialConnectionPoint;
  63374. /**
  63375. * Gets the ior input component
  63376. */
  63377. get ior(): NodeMaterialConnectionPoint;
  63378. /**
  63379. * Gets the texture input component
  63380. */
  63381. get texture(): NodeMaterialConnectionPoint;
  63382. /**
  63383. * Gets the bump texture input component
  63384. */
  63385. get bumpTexture(): NodeMaterialConnectionPoint;
  63386. /**
  63387. * Gets the uv input component
  63388. */
  63389. get uv(): NodeMaterialConnectionPoint;
  63390. /**
  63391. * Gets the tint color input component
  63392. */
  63393. get tintColor(): NodeMaterialConnectionPoint;
  63394. /**
  63395. * Gets the tint "at distance" input component
  63396. */
  63397. get tintAtDistance(): NodeMaterialConnectionPoint;
  63398. /**
  63399. * Gets the tint thickness input component
  63400. */
  63401. get tintThickness(): NodeMaterialConnectionPoint;
  63402. /**
  63403. * Gets the world tangent input component
  63404. */
  63405. get worldTangent(): NodeMaterialConnectionPoint;
  63406. /**
  63407. * Gets the clear coat object output component
  63408. */
  63409. get clearcoat(): NodeMaterialConnectionPoint;
  63410. autoConfigure(material: NodeMaterial): void;
  63411. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63412. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63413. private _generateTBNSpace;
  63414. /**
  63415. * Gets the main code of the block (fragment side)
  63416. * @param state current state of the node material building
  63417. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  63418. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63419. * @param worldPosVarName name of the variable holding the world position
  63420. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  63421. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  63422. * @param worldNormalVarName name of the variable holding the world normal
  63423. * @returns the shader code
  63424. */
  63425. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  63426. protected _buildBlock(state: NodeMaterialBuildState): this;
  63427. }
  63428. }
  63429. declare module BABYLON {
  63430. /**
  63431. * Block used to implement the sub surface module of the PBR material
  63432. */
  63433. export class SubSurfaceBlock extends NodeMaterialBlock {
  63434. /**
  63435. * Create a new SubSurfaceBlock
  63436. * @param name defines the block name
  63437. */
  63438. constructor(name: string);
  63439. /**
  63440. * Stores the intensity of the different subsurface effects in the thickness texture.
  63441. * * the green channel is the translucency intensity.
  63442. * * the blue channel is the scattering intensity.
  63443. * * the alpha channel is the refraction intensity.
  63444. */
  63445. useMaskFromThicknessTexture: boolean;
  63446. /**
  63447. * Initialize the block and prepare the context for build
  63448. * @param state defines the state that will be used for the build
  63449. */
  63450. initialize(state: NodeMaterialBuildState): void;
  63451. /**
  63452. * Gets the current class name
  63453. * @returns the class name
  63454. */
  63455. getClassName(): string;
  63456. /**
  63457. * Gets the min thickness input component
  63458. */
  63459. get minThickness(): NodeMaterialConnectionPoint;
  63460. /**
  63461. * Gets the max thickness input component
  63462. */
  63463. get maxThickness(): NodeMaterialConnectionPoint;
  63464. /**
  63465. * Gets the thickness texture component
  63466. */
  63467. get thicknessTexture(): NodeMaterialConnectionPoint;
  63468. /**
  63469. * Gets the tint color input component
  63470. */
  63471. get tintColor(): NodeMaterialConnectionPoint;
  63472. /**
  63473. * Gets the translucency intensity input component
  63474. */
  63475. get translucencyIntensity(): NodeMaterialConnectionPoint;
  63476. /**
  63477. * Gets the translucency diffusion distance input component
  63478. */
  63479. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  63480. /**
  63481. * Gets the refraction object parameters
  63482. */
  63483. get refraction(): NodeMaterialConnectionPoint;
  63484. /**
  63485. * Gets the sub surface object output component
  63486. */
  63487. get subsurface(): NodeMaterialConnectionPoint;
  63488. autoConfigure(material: NodeMaterial): void;
  63489. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63490. /**
  63491. * Gets the main code of the block (fragment side)
  63492. * @param state current state of the node material building
  63493. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  63494. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63495. * @param worldPosVarName name of the variable holding the world position
  63496. * @returns the shader code
  63497. */
  63498. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  63499. protected _buildBlock(state: NodeMaterialBuildState): this;
  63500. }
  63501. }
  63502. declare module BABYLON {
  63503. /**
  63504. * Block used to implement the PBR metallic/roughness model
  63505. */
  63506. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  63507. /**
  63508. * Gets or sets the light associated with this block
  63509. */
  63510. light: Nullable<Light>;
  63511. private _lightId;
  63512. private _scene;
  63513. private _environmentBRDFTexture;
  63514. private _environmentBrdfSamplerName;
  63515. private _vNormalWName;
  63516. private _invertNormalName;
  63517. /**
  63518. * Create a new ReflectionBlock
  63519. * @param name defines the block name
  63520. */
  63521. constructor(name: string);
  63522. /**
  63523. * Intensity of the direct lights e.g. the four lights available in your scene.
  63524. * This impacts both the direct diffuse and specular highlights.
  63525. */
  63526. directIntensity: number;
  63527. /**
  63528. * Intensity of the environment e.g. how much the environment will light the object
  63529. * either through harmonics for rough material or through the refelction for shiny ones.
  63530. */
  63531. environmentIntensity: number;
  63532. /**
  63533. * This is a special control allowing the reduction of the specular highlights coming from the
  63534. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  63535. */
  63536. specularIntensity: number;
  63537. /**
  63538. * Defines the falloff type used in this material.
  63539. * It by default is Physical.
  63540. */
  63541. lightFalloff: number;
  63542. /**
  63543. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  63544. */
  63545. useAlphaFromAlbedoTexture: boolean;
  63546. /**
  63547. * Specifies that alpha test should be used
  63548. */
  63549. useAlphaTest: boolean;
  63550. /**
  63551. * Defines the alpha limits in alpha test mode.
  63552. */
  63553. alphaTestCutoff: number;
  63554. /**
  63555. * Specifies that alpha blending should be used
  63556. */
  63557. useAlphaBlending: boolean;
  63558. /**
  63559. * Defines if the alpha value should be determined via the rgb values.
  63560. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  63561. */
  63562. opacityRGB: boolean;
  63563. /**
  63564. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  63565. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  63566. */
  63567. useRadianceOverAlpha: boolean;
  63568. /**
  63569. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  63570. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  63571. */
  63572. useSpecularOverAlpha: boolean;
  63573. /**
  63574. * Enables specular anti aliasing in the PBR shader.
  63575. * It will both interacts on the Geometry for analytical and IBL lighting.
  63576. * It also prefilter the roughness map based on the bump values.
  63577. */
  63578. enableSpecularAntiAliasing: boolean;
  63579. /**
  63580. * Enables realtime filtering on the texture.
  63581. */
  63582. realTimeFiltering: boolean;
  63583. /**
  63584. * Quality switch for realtime filtering
  63585. */
  63586. realTimeFilteringQuality: number;
  63587. /**
  63588. * Defines if the material uses energy conservation.
  63589. */
  63590. useEnergyConservation: boolean;
  63591. /**
  63592. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  63593. * too much the area relying on ambient texture to define their ambient occlusion.
  63594. */
  63595. useRadianceOcclusion: boolean;
  63596. /**
  63597. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  63598. * makes the reflect vector face the model (under horizon).
  63599. */
  63600. useHorizonOcclusion: boolean;
  63601. /**
  63602. * If set to true, no lighting calculations will be applied.
  63603. */
  63604. unlit: boolean;
  63605. /**
  63606. * Force normal to face away from face.
  63607. */
  63608. forceNormalForward: boolean;
  63609. /**
  63610. * Defines the material debug mode.
  63611. * It helps seeing only some components of the material while troubleshooting.
  63612. */
  63613. debugMode: number;
  63614. /**
  63615. * Specify from where on screen the debug mode should start.
  63616. * The value goes from -1 (full screen) to 1 (not visible)
  63617. * It helps with side by side comparison against the final render
  63618. * This defaults to 0
  63619. */
  63620. debugLimit: number;
  63621. /**
  63622. * As the default viewing range might not be enough (if the ambient is really small for instance)
  63623. * You can use the factor to better multiply the final value.
  63624. */
  63625. debugFactor: number;
  63626. /**
  63627. * Initialize the block and prepare the context for build
  63628. * @param state defines the state that will be used for the build
  63629. */
  63630. initialize(state: NodeMaterialBuildState): void;
  63631. /**
  63632. * Gets the current class name
  63633. * @returns the class name
  63634. */
  63635. getClassName(): string;
  63636. /**
  63637. * Gets the world position input component
  63638. */
  63639. get worldPosition(): NodeMaterialConnectionPoint;
  63640. /**
  63641. * Gets the world normal input component
  63642. */
  63643. get worldNormal(): NodeMaterialConnectionPoint;
  63644. /**
  63645. * Gets the perturbed normal input component
  63646. */
  63647. get perturbedNormal(): NodeMaterialConnectionPoint;
  63648. /**
  63649. * Gets the camera position input component
  63650. */
  63651. get cameraPosition(): NodeMaterialConnectionPoint;
  63652. /**
  63653. * Gets the base color input component
  63654. */
  63655. get baseColor(): NodeMaterialConnectionPoint;
  63656. /**
  63657. * Gets the opacity texture input component
  63658. */
  63659. get opacityTexture(): NodeMaterialConnectionPoint;
  63660. /**
  63661. * Gets the ambient color input component
  63662. */
  63663. get ambientColor(): NodeMaterialConnectionPoint;
  63664. /**
  63665. * Gets the reflectivity object parameters
  63666. */
  63667. get reflectivity(): NodeMaterialConnectionPoint;
  63668. /**
  63669. * Gets the ambient occlusion object parameters
  63670. */
  63671. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63672. /**
  63673. * Gets the reflection object parameters
  63674. */
  63675. get reflection(): NodeMaterialConnectionPoint;
  63676. /**
  63677. * Gets the sheen object parameters
  63678. */
  63679. get sheen(): NodeMaterialConnectionPoint;
  63680. /**
  63681. * Gets the clear coat object parameters
  63682. */
  63683. get clearcoat(): NodeMaterialConnectionPoint;
  63684. /**
  63685. * Gets the sub surface object parameters
  63686. */
  63687. get subsurface(): NodeMaterialConnectionPoint;
  63688. /**
  63689. * Gets the anisotropy object parameters
  63690. */
  63691. get anisotropy(): NodeMaterialConnectionPoint;
  63692. /**
  63693. * Gets the ambient output component
  63694. */
  63695. get ambient(): NodeMaterialConnectionPoint;
  63696. /**
  63697. * Gets the diffuse output component
  63698. */
  63699. get diffuse(): NodeMaterialConnectionPoint;
  63700. /**
  63701. * Gets the specular output component
  63702. */
  63703. get specular(): NodeMaterialConnectionPoint;
  63704. /**
  63705. * Gets the sheen output component
  63706. */
  63707. get sheenDir(): NodeMaterialConnectionPoint;
  63708. /**
  63709. * Gets the clear coat output component
  63710. */
  63711. get clearcoatDir(): NodeMaterialConnectionPoint;
  63712. /**
  63713. * Gets the indirect diffuse output component
  63714. */
  63715. get diffuseIndirect(): NodeMaterialConnectionPoint;
  63716. /**
  63717. * Gets the indirect specular output component
  63718. */
  63719. get specularIndirect(): NodeMaterialConnectionPoint;
  63720. /**
  63721. * Gets the indirect sheen output component
  63722. */
  63723. get sheenIndirect(): NodeMaterialConnectionPoint;
  63724. /**
  63725. * Gets the indirect clear coat output component
  63726. */
  63727. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  63728. /**
  63729. * Gets the refraction output component
  63730. */
  63731. get refraction(): NodeMaterialConnectionPoint;
  63732. /**
  63733. * Gets the global lighting output component
  63734. */
  63735. get lighting(): NodeMaterialConnectionPoint;
  63736. /**
  63737. * Gets the shadow output component
  63738. */
  63739. get shadow(): NodeMaterialConnectionPoint;
  63740. /**
  63741. * Gets the alpha output component
  63742. */
  63743. get alpha(): NodeMaterialConnectionPoint;
  63744. autoConfigure(material: NodeMaterial): void;
  63745. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63746. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  63747. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63748. private _injectVertexCode;
  63749. /**
  63750. * Gets the code corresponding to the albedo/opacity module
  63751. * @returns the shader code
  63752. */
  63753. getAlbedoOpacityCode(): string;
  63754. protected _buildBlock(state: NodeMaterialBuildState): this;
  63755. protected _dumpPropertiesCode(): string;
  63756. serialize(): any;
  63757. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63758. }
  63759. }
  63760. declare module BABYLON {
  63761. /**
  63762. * Block used to compute value of one parameter modulo another
  63763. */
  63764. export class ModBlock extends NodeMaterialBlock {
  63765. /**
  63766. * Creates a new ModBlock
  63767. * @param name defines the block name
  63768. */
  63769. constructor(name: string);
  63770. /**
  63771. * Gets the current class name
  63772. * @returns the class name
  63773. */
  63774. getClassName(): string;
  63775. /**
  63776. * Gets the left operand input component
  63777. */
  63778. get left(): NodeMaterialConnectionPoint;
  63779. /**
  63780. * Gets the right operand input component
  63781. */
  63782. get right(): NodeMaterialConnectionPoint;
  63783. /**
  63784. * Gets the output component
  63785. */
  63786. get output(): NodeMaterialConnectionPoint;
  63787. protected _buildBlock(state: NodeMaterialBuildState): this;
  63788. }
  63789. }
  63790. declare module BABYLON {
  63791. /**
  63792. * Helper class to push actions to a pool of workers.
  63793. */
  63794. export class WorkerPool implements IDisposable {
  63795. private _workerInfos;
  63796. private _pendingActions;
  63797. /**
  63798. * Constructor
  63799. * @param workers Array of workers to use for actions
  63800. */
  63801. constructor(workers: Array<Worker>);
  63802. /**
  63803. * Terminates all workers and clears any pending actions.
  63804. */
  63805. dispose(): void;
  63806. /**
  63807. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63808. * pended until a worker has completed its action.
  63809. * @param action The action to perform. Call onComplete when the action is complete.
  63810. */
  63811. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63812. private _execute;
  63813. }
  63814. }
  63815. declare module BABYLON {
  63816. /**
  63817. * Configuration for Draco compression
  63818. */
  63819. export interface IDracoCompressionConfiguration {
  63820. /**
  63821. * Configuration for the decoder.
  63822. */
  63823. decoder: {
  63824. /**
  63825. * The url to the WebAssembly module.
  63826. */
  63827. wasmUrl?: string;
  63828. /**
  63829. * The url to the WebAssembly binary.
  63830. */
  63831. wasmBinaryUrl?: string;
  63832. /**
  63833. * The url to the fallback JavaScript module.
  63834. */
  63835. fallbackUrl?: string;
  63836. };
  63837. }
  63838. /**
  63839. * Draco compression (https://google.github.io/draco/)
  63840. *
  63841. * This class wraps the Draco module.
  63842. *
  63843. * **Encoder**
  63844. *
  63845. * The encoder is not currently implemented.
  63846. *
  63847. * **Decoder**
  63848. *
  63849. * 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.
  63850. *
  63851. * To update the configuration, use the following code:
  63852. * ```javascript
  63853. * DracoCompression.Configuration = {
  63854. * decoder: {
  63855. * wasmUrl: "<url to the WebAssembly library>",
  63856. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63857. * fallbackUrl: "<url to the fallback JavaScript library>",
  63858. * }
  63859. * };
  63860. * ```
  63861. *
  63862. * 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.
  63863. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63864. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63865. *
  63866. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63867. * ```javascript
  63868. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63869. * ```
  63870. *
  63871. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63872. */
  63873. export class DracoCompression implements IDisposable {
  63874. private _workerPoolPromise?;
  63875. private _decoderModulePromise?;
  63876. /**
  63877. * The configuration. Defaults to the following urls:
  63878. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63879. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63880. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63881. */
  63882. static Configuration: IDracoCompressionConfiguration;
  63883. /**
  63884. * Returns true if the decoder configuration is available.
  63885. */
  63886. static get DecoderAvailable(): boolean;
  63887. /**
  63888. * Default number of workers to create when creating the draco compression object.
  63889. */
  63890. static DefaultNumWorkers: number;
  63891. private static GetDefaultNumWorkers;
  63892. private static _Default;
  63893. /**
  63894. * Default instance for the draco compression object.
  63895. */
  63896. static get Default(): DracoCompression;
  63897. /**
  63898. * Constructor
  63899. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63900. */
  63901. constructor(numWorkers?: number);
  63902. /**
  63903. * Stop all async operations and release resources.
  63904. */
  63905. dispose(): void;
  63906. /**
  63907. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63908. * @returns a promise that resolves when ready
  63909. */
  63910. whenReadyAsync(): Promise<void>;
  63911. /**
  63912. * Decode Draco compressed mesh data to vertex data.
  63913. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63914. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63915. * @returns A promise that resolves with the decoded vertex data
  63916. */
  63917. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63918. [kind: string]: number;
  63919. }): Promise<VertexData>;
  63920. }
  63921. }
  63922. declare module BABYLON {
  63923. /**
  63924. * Class for building Constructive Solid Geometry
  63925. */
  63926. export class CSG {
  63927. private polygons;
  63928. /**
  63929. * The world matrix
  63930. */
  63931. matrix: Matrix;
  63932. /**
  63933. * Stores the position
  63934. */
  63935. position: Vector3;
  63936. /**
  63937. * Stores the rotation
  63938. */
  63939. rotation: Vector3;
  63940. /**
  63941. * Stores the rotation quaternion
  63942. */
  63943. rotationQuaternion: Nullable<Quaternion>;
  63944. /**
  63945. * Stores the scaling vector
  63946. */
  63947. scaling: Vector3;
  63948. /**
  63949. * Convert the Mesh to CSG
  63950. * @param mesh The Mesh to convert to CSG
  63951. * @returns A new CSG from the Mesh
  63952. */
  63953. static FromMesh(mesh: Mesh): CSG;
  63954. /**
  63955. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63956. * @param polygons Polygons used to construct a CSG solid
  63957. */
  63958. private static FromPolygons;
  63959. /**
  63960. * Clones, or makes a deep copy, of the CSG
  63961. * @returns A new CSG
  63962. */
  63963. clone(): CSG;
  63964. /**
  63965. * Unions this CSG with another CSG
  63966. * @param csg The CSG to union against this CSG
  63967. * @returns The unioned CSG
  63968. */
  63969. union(csg: CSG): CSG;
  63970. /**
  63971. * Unions this CSG with another CSG in place
  63972. * @param csg The CSG to union against this CSG
  63973. */
  63974. unionInPlace(csg: CSG): void;
  63975. /**
  63976. * Subtracts this CSG with another CSG
  63977. * @param csg The CSG to subtract against this CSG
  63978. * @returns A new CSG
  63979. */
  63980. subtract(csg: CSG): CSG;
  63981. /**
  63982. * Subtracts this CSG with another CSG in place
  63983. * @param csg The CSG to subtact against this CSG
  63984. */
  63985. subtractInPlace(csg: CSG): void;
  63986. /**
  63987. * Intersect this CSG with another CSG
  63988. * @param csg The CSG to intersect against this CSG
  63989. * @returns A new CSG
  63990. */
  63991. intersect(csg: CSG): CSG;
  63992. /**
  63993. * Intersects this CSG with another CSG in place
  63994. * @param csg The CSG to intersect against this CSG
  63995. */
  63996. intersectInPlace(csg: CSG): void;
  63997. /**
  63998. * Return a new CSG solid with solid and empty space switched. This solid is
  63999. * not modified.
  64000. * @returns A new CSG solid with solid and empty space switched
  64001. */
  64002. inverse(): CSG;
  64003. /**
  64004. * Inverses the CSG in place
  64005. */
  64006. inverseInPlace(): void;
  64007. /**
  64008. * This is used to keep meshes transformations so they can be restored
  64009. * when we build back a Babylon Mesh
  64010. * NB : All CSG operations are performed in world coordinates
  64011. * @param csg The CSG to copy the transform attributes from
  64012. * @returns This CSG
  64013. */
  64014. copyTransformAttributes(csg: CSG): CSG;
  64015. /**
  64016. * Build Raw mesh from CSG
  64017. * Coordinates here are in world space
  64018. * @param name The name of the mesh geometry
  64019. * @param scene The Scene
  64020. * @param keepSubMeshes Specifies if the submeshes should be kept
  64021. * @returns A new Mesh
  64022. */
  64023. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64024. /**
  64025. * Build Mesh from CSG taking material and transforms into account
  64026. * @param name The name of the Mesh
  64027. * @param material The material of the Mesh
  64028. * @param scene The Scene
  64029. * @param keepSubMeshes Specifies if submeshes should be kept
  64030. * @returns The new Mesh
  64031. */
  64032. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64033. }
  64034. }
  64035. declare module BABYLON {
  64036. /**
  64037. * Class used to create a trail following a mesh
  64038. */
  64039. export class TrailMesh extends Mesh {
  64040. private _generator;
  64041. private _autoStart;
  64042. private _running;
  64043. private _diameter;
  64044. private _length;
  64045. private _sectionPolygonPointsCount;
  64046. private _sectionVectors;
  64047. private _sectionNormalVectors;
  64048. private _beforeRenderObserver;
  64049. /**
  64050. * @constructor
  64051. * @param name The value used by scene.getMeshByName() to do a lookup.
  64052. * @param generator The mesh or transform node to generate a trail.
  64053. * @param scene The scene to add this mesh to.
  64054. * @param diameter Diameter of trailing mesh. Default is 1.
  64055. * @param length Length of trailing mesh. Default is 60.
  64056. * @param autoStart Automatically start trailing mesh. Default true.
  64057. */
  64058. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  64059. /**
  64060. * "TrailMesh"
  64061. * @returns "TrailMesh"
  64062. */
  64063. getClassName(): string;
  64064. private _createMesh;
  64065. /**
  64066. * Start trailing mesh.
  64067. */
  64068. start(): void;
  64069. /**
  64070. * Stop trailing mesh.
  64071. */
  64072. stop(): void;
  64073. /**
  64074. * Update trailing mesh geometry.
  64075. */
  64076. update(): void;
  64077. /**
  64078. * Returns a new TrailMesh object.
  64079. * @param name is a string, the name given to the new mesh
  64080. * @param newGenerator use new generator object for cloned trail mesh
  64081. * @returns a new mesh
  64082. */
  64083. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  64084. /**
  64085. * Serializes this trail mesh
  64086. * @param serializationObject object to write serialization to
  64087. */
  64088. serialize(serializationObject: any): void;
  64089. /**
  64090. * Parses a serialized trail mesh
  64091. * @param parsedMesh the serialized mesh
  64092. * @param scene the scene to create the trail mesh in
  64093. * @returns the created trail mesh
  64094. */
  64095. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  64096. }
  64097. }
  64098. declare module BABYLON {
  64099. /**
  64100. * Class containing static functions to help procedurally build meshes
  64101. */
  64102. export class TiledBoxBuilder {
  64103. /**
  64104. * Creates a box mesh
  64105. * 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)
  64106. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64107. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64108. * * 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
  64109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64110. * @param name defines the name of the mesh
  64111. * @param options defines the options used to create the mesh
  64112. * @param scene defines the hosting scene
  64113. * @returns the box mesh
  64114. */
  64115. static CreateTiledBox(name: string, options: {
  64116. pattern?: number;
  64117. width?: number;
  64118. height?: number;
  64119. depth?: number;
  64120. tileSize?: number;
  64121. tileWidth?: number;
  64122. tileHeight?: number;
  64123. alignHorizontal?: number;
  64124. alignVertical?: number;
  64125. faceUV?: Vector4[];
  64126. faceColors?: Color4[];
  64127. sideOrientation?: number;
  64128. updatable?: boolean;
  64129. }, scene?: Nullable<Scene>): Mesh;
  64130. }
  64131. }
  64132. declare module BABYLON {
  64133. /**
  64134. * Class containing static functions to help procedurally build meshes
  64135. */
  64136. export class TorusKnotBuilder {
  64137. /**
  64138. * Creates a torus knot mesh
  64139. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64140. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64141. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64142. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64143. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64144. * * 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
  64145. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64146. * @param name defines the name of the mesh
  64147. * @param options defines the options used to create the mesh
  64148. * @param scene defines the hosting scene
  64149. * @returns the torus knot mesh
  64150. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64151. */
  64152. static CreateTorusKnot(name: string, options: {
  64153. radius?: number;
  64154. tube?: number;
  64155. radialSegments?: number;
  64156. tubularSegments?: number;
  64157. p?: number;
  64158. q?: number;
  64159. updatable?: boolean;
  64160. sideOrientation?: number;
  64161. frontUVs?: Vector4;
  64162. backUVs?: Vector4;
  64163. }, scene: any): Mesh;
  64164. }
  64165. }
  64166. declare module BABYLON {
  64167. /**
  64168. * Polygon
  64169. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  64170. */
  64171. export class Polygon {
  64172. /**
  64173. * Creates a rectangle
  64174. * @param xmin bottom X coord
  64175. * @param ymin bottom Y coord
  64176. * @param xmax top X coord
  64177. * @param ymax top Y coord
  64178. * @returns points that make the resulting rectation
  64179. */
  64180. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  64181. /**
  64182. * Creates a circle
  64183. * @param radius radius of circle
  64184. * @param cx scale in x
  64185. * @param cy scale in y
  64186. * @param numberOfSides number of sides that make up the circle
  64187. * @returns points that make the resulting circle
  64188. */
  64189. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  64190. /**
  64191. * Creates a polygon from input string
  64192. * @param input Input polygon data
  64193. * @returns the parsed points
  64194. */
  64195. static Parse(input: string): Vector2[];
  64196. /**
  64197. * Starts building a polygon from x and y coordinates
  64198. * @param x x coordinate
  64199. * @param y y coordinate
  64200. * @returns the started path2
  64201. */
  64202. static StartingAt(x: number, y: number): Path2;
  64203. }
  64204. /**
  64205. * Builds a polygon
  64206. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  64207. */
  64208. export class PolygonMeshBuilder {
  64209. private _points;
  64210. private _outlinepoints;
  64211. private _holes;
  64212. private _name;
  64213. private _scene;
  64214. private _epoints;
  64215. private _eholes;
  64216. private _addToepoint;
  64217. /**
  64218. * Babylon reference to the earcut plugin.
  64219. */
  64220. bjsEarcut: any;
  64221. /**
  64222. * Creates a PolygonMeshBuilder
  64223. * @param name name of the builder
  64224. * @param contours Path of the polygon
  64225. * @param scene scene to add to when creating the mesh
  64226. * @param earcutInjection can be used to inject your own earcut reference
  64227. */
  64228. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  64229. /**
  64230. * Adds a whole within the polygon
  64231. * @param hole Array of points defining the hole
  64232. * @returns this
  64233. */
  64234. addHole(hole: Vector2[]): PolygonMeshBuilder;
  64235. /**
  64236. * Creates the polygon
  64237. * @param updatable If the mesh should be updatable
  64238. * @param depth The depth of the mesh created
  64239. * @returns the created mesh
  64240. */
  64241. build(updatable?: boolean, depth?: number): Mesh;
  64242. /**
  64243. * Creates the polygon
  64244. * @param depth The depth of the mesh created
  64245. * @returns the created VertexData
  64246. */
  64247. buildVertexData(depth?: number): VertexData;
  64248. /**
  64249. * Adds a side to the polygon
  64250. * @param positions points that make the polygon
  64251. * @param normals normals of the polygon
  64252. * @param uvs uvs of the polygon
  64253. * @param indices indices of the polygon
  64254. * @param bounds bounds of the polygon
  64255. * @param points points of the polygon
  64256. * @param depth depth of the polygon
  64257. * @param flip flip of the polygon
  64258. */
  64259. private addSide;
  64260. }
  64261. }
  64262. declare module BABYLON {
  64263. /**
  64264. * Class containing static functions to help procedurally build meshes
  64265. */
  64266. export class PolygonBuilder {
  64267. /**
  64268. * Creates a polygon mesh
  64269. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64270. * * 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
  64271. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64273. * * 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)
  64274. * * Remember you can only change the shape positions, not their number when updating a polygon
  64275. * @param name defines the name of the mesh
  64276. * @param options defines the options used to create the mesh
  64277. * @param scene defines the hosting scene
  64278. * @param earcutInjection can be used to inject your own earcut reference
  64279. * @returns the polygon mesh
  64280. */
  64281. static CreatePolygon(name: string, options: {
  64282. shape: Vector3[];
  64283. holes?: Vector3[][];
  64284. depth?: number;
  64285. faceUV?: Vector4[];
  64286. faceColors?: Color4[];
  64287. updatable?: boolean;
  64288. sideOrientation?: number;
  64289. frontUVs?: Vector4;
  64290. backUVs?: Vector4;
  64291. wrap?: boolean;
  64292. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64293. /**
  64294. * Creates an extruded polygon mesh, with depth in the Y direction.
  64295. * * 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)
  64296. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64297. * @param name defines the name of the mesh
  64298. * @param options defines the options used to create the mesh
  64299. * @param scene defines the hosting scene
  64300. * @param earcutInjection can be used to inject your own earcut reference
  64301. * @returns the polygon mesh
  64302. */
  64303. static ExtrudePolygon(name: string, options: {
  64304. shape: Vector3[];
  64305. holes?: Vector3[][];
  64306. depth?: number;
  64307. faceUV?: Vector4[];
  64308. faceColors?: Color4[];
  64309. updatable?: boolean;
  64310. sideOrientation?: number;
  64311. frontUVs?: Vector4;
  64312. backUVs?: Vector4;
  64313. wrap?: boolean;
  64314. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64315. }
  64316. }
  64317. declare module BABYLON {
  64318. /**
  64319. * Class containing static functions to help procedurally build meshes
  64320. */
  64321. export class LatheBuilder {
  64322. /**
  64323. * Creates lathe mesh.
  64324. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64325. * * 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
  64326. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64327. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64328. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64329. * * 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
  64330. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64331. * * 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
  64332. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64333. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64334. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64336. * @param name defines the name of the mesh
  64337. * @param options defines the options used to create the mesh
  64338. * @param scene defines the hosting scene
  64339. * @returns the lathe mesh
  64340. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64341. */
  64342. static CreateLathe(name: string, options: {
  64343. shape: Vector3[];
  64344. radius?: number;
  64345. tessellation?: number;
  64346. clip?: number;
  64347. arc?: number;
  64348. closed?: boolean;
  64349. updatable?: boolean;
  64350. sideOrientation?: number;
  64351. frontUVs?: Vector4;
  64352. backUVs?: Vector4;
  64353. cap?: number;
  64354. invertUV?: boolean;
  64355. }, scene?: Nullable<Scene>): Mesh;
  64356. }
  64357. }
  64358. declare module BABYLON {
  64359. /**
  64360. * Class containing static functions to help procedurally build meshes
  64361. */
  64362. export class TiledPlaneBuilder {
  64363. /**
  64364. * Creates a tiled plane mesh
  64365. * * The parameter `pattern` will, depending on value, do nothing or
  64366. * * * flip (reflect about central vertical) alternate tiles across and up
  64367. * * * flip every tile on alternate rows
  64368. * * * rotate (180 degs) alternate tiles across and up
  64369. * * * rotate every tile on alternate rows
  64370. * * * flip and rotate alternate tiles across and up
  64371. * * * flip and rotate every tile on alternate rows
  64372. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  64373. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  64374. * * 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
  64375. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64376. * * 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)
  64377. * * 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)
  64378. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64379. * @param name defines the name of the mesh
  64380. * @param options defines the options used to create the mesh
  64381. * @param scene defines the hosting scene
  64382. * @returns the box mesh
  64383. */
  64384. static CreateTiledPlane(name: string, options: {
  64385. pattern?: number;
  64386. tileSize?: number;
  64387. tileWidth?: number;
  64388. tileHeight?: number;
  64389. size?: number;
  64390. width?: number;
  64391. height?: number;
  64392. alignHorizontal?: number;
  64393. alignVertical?: number;
  64394. sideOrientation?: number;
  64395. frontUVs?: Vector4;
  64396. backUVs?: Vector4;
  64397. updatable?: boolean;
  64398. }, scene?: Nullable<Scene>): Mesh;
  64399. }
  64400. }
  64401. declare module BABYLON {
  64402. /**
  64403. * Class containing static functions to help procedurally build meshes
  64404. */
  64405. export class TubeBuilder {
  64406. /**
  64407. * Creates a tube mesh.
  64408. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64409. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64410. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64411. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64412. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64413. * * 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)
  64414. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64415. * * 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
  64416. * * 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
  64417. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64418. * * 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
  64419. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64421. * @param name defines the name of the mesh
  64422. * @param options defines the options used to create the mesh
  64423. * @param scene defines the hosting scene
  64424. * @returns the tube mesh
  64425. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64426. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64427. */
  64428. static CreateTube(name: string, options: {
  64429. path: Vector3[];
  64430. radius?: number;
  64431. tessellation?: number;
  64432. radiusFunction?: {
  64433. (i: number, distance: number): number;
  64434. };
  64435. cap?: number;
  64436. arc?: number;
  64437. updatable?: boolean;
  64438. sideOrientation?: number;
  64439. frontUVs?: Vector4;
  64440. backUVs?: Vector4;
  64441. instance?: Mesh;
  64442. invertUV?: boolean;
  64443. }, scene?: Nullable<Scene>): Mesh;
  64444. }
  64445. }
  64446. declare module BABYLON {
  64447. /**
  64448. * Class containing static functions to help procedurally build meshes
  64449. */
  64450. export class IcoSphereBuilder {
  64451. /**
  64452. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64453. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64454. * * 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`)
  64455. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64456. * * 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
  64457. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64458. * * 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
  64459. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64460. * @param name defines the name of the mesh
  64461. * @param options defines the options used to create the mesh
  64462. * @param scene defines the hosting scene
  64463. * @returns the icosahedron mesh
  64464. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64465. */
  64466. static CreateIcoSphere(name: string, options: {
  64467. radius?: number;
  64468. radiusX?: number;
  64469. radiusY?: number;
  64470. radiusZ?: number;
  64471. flat?: boolean;
  64472. subdivisions?: number;
  64473. sideOrientation?: number;
  64474. frontUVs?: Vector4;
  64475. backUVs?: Vector4;
  64476. updatable?: boolean;
  64477. }, scene?: Nullable<Scene>): Mesh;
  64478. }
  64479. }
  64480. declare module BABYLON {
  64481. /**
  64482. * Class containing static functions to help procedurally build meshes
  64483. */
  64484. export class DecalBuilder {
  64485. /**
  64486. * Creates a decal mesh.
  64487. * 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
  64488. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64489. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64490. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64491. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64492. * @param name defines the name of the mesh
  64493. * @param sourceMesh defines the mesh where the decal must be applied
  64494. * @param options defines the options used to create the mesh
  64495. * @param scene defines the hosting scene
  64496. * @returns the decal mesh
  64497. * @see https://doc.babylonjs.com/how_to/decals
  64498. */
  64499. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64500. position?: Vector3;
  64501. normal?: Vector3;
  64502. size?: Vector3;
  64503. angle?: number;
  64504. }): Mesh;
  64505. }
  64506. }
  64507. declare module BABYLON {
  64508. /**
  64509. * Class containing static functions to help procedurally build meshes
  64510. */
  64511. export class MeshBuilder {
  64512. /**
  64513. * Creates a box mesh
  64514. * * The parameter `size` sets the size (float) of each box side (default 1)
  64515. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64516. * * 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)
  64517. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64518. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64519. * * 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
  64520. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64521. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64522. * @param name defines the name of the mesh
  64523. * @param options defines the options used to create the mesh
  64524. * @param scene defines the hosting scene
  64525. * @returns the box mesh
  64526. */
  64527. static CreateBox(name: string, options: {
  64528. size?: number;
  64529. width?: number;
  64530. height?: number;
  64531. depth?: number;
  64532. faceUV?: Vector4[];
  64533. faceColors?: Color4[];
  64534. sideOrientation?: number;
  64535. frontUVs?: Vector4;
  64536. backUVs?: Vector4;
  64537. wrap?: boolean;
  64538. topBaseAt?: number;
  64539. bottomBaseAt?: number;
  64540. updatable?: boolean;
  64541. }, scene?: Nullable<Scene>): Mesh;
  64542. /**
  64543. * Creates a tiled box mesh
  64544. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64545. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64546. * @param name defines the name of the mesh
  64547. * @param options defines the options used to create the mesh
  64548. * @param scene defines the hosting scene
  64549. * @returns the tiled box mesh
  64550. */
  64551. static CreateTiledBox(name: string, options: {
  64552. pattern?: number;
  64553. size?: number;
  64554. width?: number;
  64555. height?: number;
  64556. depth: number;
  64557. tileSize?: number;
  64558. tileWidth?: number;
  64559. tileHeight?: number;
  64560. faceUV?: Vector4[];
  64561. faceColors?: Color4[];
  64562. alignHorizontal?: number;
  64563. alignVertical?: number;
  64564. sideOrientation?: number;
  64565. updatable?: boolean;
  64566. }, scene?: Nullable<Scene>): Mesh;
  64567. /**
  64568. * Creates a sphere mesh
  64569. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64570. * * 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`)
  64571. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64572. * * 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
  64573. * * 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)
  64574. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64575. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64576. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64577. * @param name defines the name of the mesh
  64578. * @param options defines the options used to create the mesh
  64579. * @param scene defines the hosting scene
  64580. * @returns the sphere mesh
  64581. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64582. */
  64583. static CreateSphere(name: string, options: {
  64584. segments?: number;
  64585. diameter?: number;
  64586. diameterX?: number;
  64587. diameterY?: number;
  64588. diameterZ?: number;
  64589. arc?: number;
  64590. slice?: number;
  64591. sideOrientation?: number;
  64592. frontUVs?: Vector4;
  64593. backUVs?: Vector4;
  64594. updatable?: boolean;
  64595. }, scene?: Nullable<Scene>): Mesh;
  64596. /**
  64597. * Creates a plane polygonal mesh. By default, this is a disc
  64598. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64599. * * 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
  64600. * * 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
  64601. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64602. * * 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
  64603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64604. * @param name defines the name of the mesh
  64605. * @param options defines the options used to create the mesh
  64606. * @param scene defines the hosting scene
  64607. * @returns the plane polygonal mesh
  64608. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64609. */
  64610. static CreateDisc(name: string, options: {
  64611. radius?: number;
  64612. tessellation?: number;
  64613. arc?: number;
  64614. updatable?: boolean;
  64615. sideOrientation?: number;
  64616. frontUVs?: Vector4;
  64617. backUVs?: Vector4;
  64618. }, scene?: Nullable<Scene>): Mesh;
  64619. /**
  64620. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64621. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64622. * * 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`)
  64623. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64624. * * 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
  64625. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64626. * * 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
  64627. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64628. * @param name defines the name of the mesh
  64629. * @param options defines the options used to create the mesh
  64630. * @param scene defines the hosting scene
  64631. * @returns the icosahedron mesh
  64632. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64633. */
  64634. static CreateIcoSphere(name: string, options: {
  64635. radius?: number;
  64636. radiusX?: number;
  64637. radiusY?: number;
  64638. radiusZ?: number;
  64639. flat?: boolean;
  64640. subdivisions?: number;
  64641. sideOrientation?: number;
  64642. frontUVs?: Vector4;
  64643. backUVs?: Vector4;
  64644. updatable?: boolean;
  64645. }, scene?: Nullable<Scene>): Mesh;
  64646. /**
  64647. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64648. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64649. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64650. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64651. * * 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
  64652. * * 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
  64653. * * 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
  64654. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64655. * * 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
  64656. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64657. * * 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
  64658. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64659. * * 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
  64660. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64661. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64662. * @param name defines the name of the mesh
  64663. * @param options defines the options used to create the mesh
  64664. * @param scene defines the hosting scene
  64665. * @returns the ribbon mesh
  64666. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64667. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64668. */
  64669. static CreateRibbon(name: string, options: {
  64670. pathArray: Vector3[][];
  64671. closeArray?: boolean;
  64672. closePath?: boolean;
  64673. offset?: number;
  64674. updatable?: boolean;
  64675. sideOrientation?: number;
  64676. frontUVs?: Vector4;
  64677. backUVs?: Vector4;
  64678. instance?: Mesh;
  64679. invertUV?: boolean;
  64680. uvs?: Vector2[];
  64681. colors?: Color4[];
  64682. }, scene?: Nullable<Scene>): Mesh;
  64683. /**
  64684. * Creates a cylinder or a cone mesh
  64685. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64686. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64687. * * 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.
  64688. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64689. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64690. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64691. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64692. * * 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).
  64693. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64694. * * 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).
  64695. * * 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
  64696. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64697. * * 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
  64698. * * 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.
  64699. * * If `enclose` is false, a ring surface is one element.
  64700. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64701. * * 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
  64702. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64703. * * 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
  64704. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64705. * @param name defines the name of the mesh
  64706. * @param options defines the options used to create the mesh
  64707. * @param scene defines the hosting scene
  64708. * @returns the cylinder mesh
  64709. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64710. */
  64711. static CreateCylinder(name: string, options: {
  64712. height?: number;
  64713. diameterTop?: number;
  64714. diameterBottom?: number;
  64715. diameter?: number;
  64716. tessellation?: number;
  64717. subdivisions?: number;
  64718. arc?: number;
  64719. faceColors?: Color4[];
  64720. faceUV?: Vector4[];
  64721. updatable?: boolean;
  64722. hasRings?: boolean;
  64723. enclose?: boolean;
  64724. cap?: number;
  64725. sideOrientation?: number;
  64726. frontUVs?: Vector4;
  64727. backUVs?: Vector4;
  64728. }, scene?: Nullable<Scene>): Mesh;
  64729. /**
  64730. * Creates a torus mesh
  64731. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64732. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64733. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64734. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64735. * * 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
  64736. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64737. * @param name defines the name of the mesh
  64738. * @param options defines the options used to create the mesh
  64739. * @param scene defines the hosting scene
  64740. * @returns the torus mesh
  64741. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64742. */
  64743. static CreateTorus(name: string, options: {
  64744. diameter?: number;
  64745. thickness?: number;
  64746. tessellation?: number;
  64747. updatable?: boolean;
  64748. sideOrientation?: number;
  64749. frontUVs?: Vector4;
  64750. backUVs?: Vector4;
  64751. }, scene?: Nullable<Scene>): Mesh;
  64752. /**
  64753. * Creates a torus knot mesh
  64754. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64755. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64756. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64757. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64758. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64759. * * 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
  64760. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64761. * @param name defines the name of the mesh
  64762. * @param options defines the options used to create the mesh
  64763. * @param scene defines the hosting scene
  64764. * @returns the torus knot mesh
  64765. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64766. */
  64767. static CreateTorusKnot(name: string, options: {
  64768. radius?: number;
  64769. tube?: number;
  64770. radialSegments?: number;
  64771. tubularSegments?: number;
  64772. p?: number;
  64773. q?: number;
  64774. updatable?: boolean;
  64775. sideOrientation?: number;
  64776. frontUVs?: Vector4;
  64777. backUVs?: Vector4;
  64778. }, scene?: Nullable<Scene>): Mesh;
  64779. /**
  64780. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64781. * * 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
  64782. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64783. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64784. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64785. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64786. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64787. * * 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
  64788. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64790. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64791. * @param name defines the name of the new line system
  64792. * @param options defines the options used to create the line system
  64793. * @param scene defines the hosting scene
  64794. * @returns a new line system mesh
  64795. */
  64796. static CreateLineSystem(name: string, options: {
  64797. lines: Vector3[][];
  64798. updatable?: boolean;
  64799. instance?: Nullable<LinesMesh>;
  64800. colors?: Nullable<Color4[][]>;
  64801. useVertexAlpha?: boolean;
  64802. }, scene: Nullable<Scene>): LinesMesh;
  64803. /**
  64804. * Creates a line mesh
  64805. * 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
  64806. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64807. * * The parameter `points` is an array successive Vector3
  64808. * * 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
  64809. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64810. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64811. * * When updating an instance, remember that only point positions can change, not the number of points
  64812. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64813. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64814. * @param name defines the name of the new line system
  64815. * @param options defines the options used to create the line system
  64816. * @param scene defines the hosting scene
  64817. * @returns a new line mesh
  64818. */
  64819. static CreateLines(name: string, options: {
  64820. points: Vector3[];
  64821. updatable?: boolean;
  64822. instance?: Nullable<LinesMesh>;
  64823. colors?: Color4[];
  64824. useVertexAlpha?: boolean;
  64825. }, scene?: Nullable<Scene>): LinesMesh;
  64826. /**
  64827. * Creates a dashed line mesh
  64828. * * 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
  64829. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64830. * * The parameter `points` is an array successive Vector3
  64831. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64832. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64833. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64834. * * 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
  64835. * * When updating an instance, remember that only point positions can change, not the number of points
  64836. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64837. * @param name defines the name of the mesh
  64838. * @param options defines the options used to create the mesh
  64839. * @param scene defines the hosting scene
  64840. * @returns the dashed line mesh
  64841. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64842. */
  64843. static CreateDashedLines(name: string, options: {
  64844. points: Vector3[];
  64845. dashSize?: number;
  64846. gapSize?: number;
  64847. dashNb?: number;
  64848. updatable?: boolean;
  64849. instance?: LinesMesh;
  64850. }, scene?: Nullable<Scene>): LinesMesh;
  64851. /**
  64852. * 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.
  64853. * * 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.
  64854. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64855. * * 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.
  64856. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64857. * * 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
  64858. * * 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
  64859. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64860. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64861. * * 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
  64862. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64863. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64864. * @param name defines the name of the mesh
  64865. * @param options defines the options used to create the mesh
  64866. * @param scene defines the hosting scene
  64867. * @returns the extruded shape mesh
  64868. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64869. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64870. */
  64871. static ExtrudeShape(name: string, options: {
  64872. shape: Vector3[];
  64873. path: Vector3[];
  64874. scale?: number;
  64875. rotation?: number;
  64876. cap?: number;
  64877. updatable?: boolean;
  64878. sideOrientation?: number;
  64879. frontUVs?: Vector4;
  64880. backUVs?: Vector4;
  64881. instance?: Mesh;
  64882. invertUV?: boolean;
  64883. }, scene?: Nullable<Scene>): Mesh;
  64884. /**
  64885. * Creates an custom extruded shape mesh.
  64886. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64887. * * 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.
  64888. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64889. * * 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
  64890. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64891. * * 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
  64892. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64893. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64894. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64895. * * 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
  64896. * * 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
  64897. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64898. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64899. * * 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
  64900. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64901. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64902. * @param name defines the name of the mesh
  64903. * @param options defines the options used to create the mesh
  64904. * @param scene defines the hosting scene
  64905. * @returns the custom extruded shape mesh
  64906. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64907. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64908. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64909. */
  64910. static ExtrudeShapeCustom(name: string, options: {
  64911. shape: Vector3[];
  64912. path: Vector3[];
  64913. scaleFunction?: any;
  64914. rotationFunction?: any;
  64915. ribbonCloseArray?: boolean;
  64916. ribbonClosePath?: boolean;
  64917. cap?: number;
  64918. updatable?: boolean;
  64919. sideOrientation?: number;
  64920. frontUVs?: Vector4;
  64921. backUVs?: Vector4;
  64922. instance?: Mesh;
  64923. invertUV?: boolean;
  64924. }, scene?: Nullable<Scene>): Mesh;
  64925. /**
  64926. * Creates lathe mesh.
  64927. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64928. * * 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
  64929. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64930. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64931. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64932. * * 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
  64933. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64934. * * 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
  64935. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64936. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64937. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64938. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64939. * @param name defines the name of the mesh
  64940. * @param options defines the options used to create the mesh
  64941. * @param scene defines the hosting scene
  64942. * @returns the lathe mesh
  64943. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64944. */
  64945. static CreateLathe(name: string, options: {
  64946. shape: Vector3[];
  64947. radius?: number;
  64948. tessellation?: number;
  64949. clip?: number;
  64950. arc?: number;
  64951. closed?: boolean;
  64952. updatable?: boolean;
  64953. sideOrientation?: number;
  64954. frontUVs?: Vector4;
  64955. backUVs?: Vector4;
  64956. cap?: number;
  64957. invertUV?: boolean;
  64958. }, scene?: Nullable<Scene>): Mesh;
  64959. /**
  64960. * Creates a tiled plane mesh
  64961. * * You can set a limited pattern arrangement with the tiles
  64962. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64963. * * 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
  64964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64965. * @param name defines the name of the mesh
  64966. * @param options defines the options used to create the mesh
  64967. * @param scene defines the hosting scene
  64968. * @returns the plane mesh
  64969. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64970. */
  64971. static CreateTiledPlane(name: string, options: {
  64972. pattern?: number;
  64973. tileSize?: number;
  64974. tileWidth?: number;
  64975. tileHeight?: number;
  64976. size?: number;
  64977. width?: number;
  64978. height?: number;
  64979. alignHorizontal?: number;
  64980. alignVertical?: number;
  64981. sideOrientation?: number;
  64982. frontUVs?: Vector4;
  64983. backUVs?: Vector4;
  64984. updatable?: boolean;
  64985. }, scene?: Nullable<Scene>): Mesh;
  64986. /**
  64987. * Creates a plane mesh
  64988. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64989. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64990. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64991. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64992. * * 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
  64993. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64994. * @param name defines the name of the mesh
  64995. * @param options defines the options used to create the mesh
  64996. * @param scene defines the hosting scene
  64997. * @returns the plane mesh
  64998. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64999. */
  65000. static CreatePlane(name: string, options: {
  65001. size?: number;
  65002. width?: number;
  65003. height?: number;
  65004. sideOrientation?: number;
  65005. frontUVs?: Vector4;
  65006. backUVs?: Vector4;
  65007. updatable?: boolean;
  65008. sourcePlane?: Plane;
  65009. }, scene?: Nullable<Scene>): Mesh;
  65010. /**
  65011. * Creates a ground mesh
  65012. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  65013. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  65014. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65015. * @param name defines the name of the mesh
  65016. * @param options defines the options used to create the mesh
  65017. * @param scene defines the hosting scene
  65018. * @returns the ground mesh
  65019. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  65020. */
  65021. static CreateGround(name: string, options: {
  65022. width?: number;
  65023. height?: number;
  65024. subdivisions?: number;
  65025. subdivisionsX?: number;
  65026. subdivisionsY?: number;
  65027. updatable?: boolean;
  65028. }, scene?: Nullable<Scene>): Mesh;
  65029. /**
  65030. * Creates a tiled ground mesh
  65031. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  65032. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  65033. * * 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
  65034. * * 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
  65035. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65036. * @param name defines the name of the mesh
  65037. * @param options defines the options used to create the mesh
  65038. * @param scene defines the hosting scene
  65039. * @returns the tiled ground mesh
  65040. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  65041. */
  65042. static CreateTiledGround(name: string, options: {
  65043. xmin: number;
  65044. zmin: number;
  65045. xmax: number;
  65046. zmax: number;
  65047. subdivisions?: {
  65048. w: number;
  65049. h: number;
  65050. };
  65051. precision?: {
  65052. w: number;
  65053. h: number;
  65054. };
  65055. updatable?: boolean;
  65056. }, scene?: Nullable<Scene>): Mesh;
  65057. /**
  65058. * Creates a ground mesh from a height map
  65059. * * The parameter `url` sets the URL of the height map image resource.
  65060. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  65061. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  65062. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  65063. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  65064. * * 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.
  65065. * * 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).
  65066. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  65067. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65068. * @param name defines the name of the mesh
  65069. * @param url defines the url to the height map
  65070. * @param options defines the options used to create the mesh
  65071. * @param scene defines the hosting scene
  65072. * @returns the ground mesh
  65073. * @see https://doc.babylonjs.com/babylon101/height_map
  65074. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  65075. */
  65076. static CreateGroundFromHeightMap(name: string, url: string, options: {
  65077. width?: number;
  65078. height?: number;
  65079. subdivisions?: number;
  65080. minHeight?: number;
  65081. maxHeight?: number;
  65082. colorFilter?: Color3;
  65083. alphaFilter?: number;
  65084. updatable?: boolean;
  65085. onReady?: (mesh: GroundMesh) => void;
  65086. }, scene?: Nullable<Scene>): GroundMesh;
  65087. /**
  65088. * Creates a polygon mesh
  65089. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65090. * * 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
  65091. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65092. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65093. * * 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)
  65094. * * Remember you can only change the shape positions, not their number when updating a polygon
  65095. * @param name defines the name of the mesh
  65096. * @param options defines the options used to create the mesh
  65097. * @param scene defines the hosting scene
  65098. * @param earcutInjection can be used to inject your own earcut reference
  65099. * @returns the polygon mesh
  65100. */
  65101. static CreatePolygon(name: string, options: {
  65102. shape: Vector3[];
  65103. holes?: Vector3[][];
  65104. depth?: number;
  65105. faceUV?: Vector4[];
  65106. faceColors?: Color4[];
  65107. updatable?: boolean;
  65108. sideOrientation?: number;
  65109. frontUVs?: Vector4;
  65110. backUVs?: Vector4;
  65111. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65112. /**
  65113. * Creates an extruded polygon mesh, with depth in the Y direction.
  65114. * * 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)
  65115. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65116. * @param name defines the name of the mesh
  65117. * @param options defines the options used to create the mesh
  65118. * @param scene defines the hosting scene
  65119. * @param earcutInjection can be used to inject your own earcut reference
  65120. * @returns the polygon mesh
  65121. */
  65122. static ExtrudePolygon(name: string, options: {
  65123. shape: Vector3[];
  65124. holes?: Vector3[][];
  65125. depth?: number;
  65126. faceUV?: Vector4[];
  65127. faceColors?: Color4[];
  65128. updatable?: boolean;
  65129. sideOrientation?: number;
  65130. frontUVs?: Vector4;
  65131. backUVs?: Vector4;
  65132. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65133. /**
  65134. * Creates a tube mesh.
  65135. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65136. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65137. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65138. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65139. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65140. * * 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)
  65141. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65142. * * 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
  65143. * * 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
  65144. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65145. * * 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
  65146. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65147. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65148. * @param name defines the name of the mesh
  65149. * @param options defines the options used to create the mesh
  65150. * @param scene defines the hosting scene
  65151. * @returns the tube mesh
  65152. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65153. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65154. */
  65155. static CreateTube(name: string, options: {
  65156. path: Vector3[];
  65157. radius?: number;
  65158. tessellation?: number;
  65159. radiusFunction?: {
  65160. (i: number, distance: number): number;
  65161. };
  65162. cap?: number;
  65163. arc?: number;
  65164. updatable?: boolean;
  65165. sideOrientation?: number;
  65166. frontUVs?: Vector4;
  65167. backUVs?: Vector4;
  65168. instance?: Mesh;
  65169. invertUV?: boolean;
  65170. }, scene?: Nullable<Scene>): Mesh;
  65171. /**
  65172. * Creates a polyhedron mesh
  65173. * * 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
  65174. * * The parameter `size` (positive float, default 1) sets the polygon size
  65175. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  65176. * * 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`
  65177. * * 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
  65178. * * 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)`)
  65179. * * 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
  65180. * * 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
  65181. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65182. * * 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
  65183. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65184. * @param name defines the name of the mesh
  65185. * @param options defines the options used to create the mesh
  65186. * @param scene defines the hosting scene
  65187. * @returns the polyhedron mesh
  65188. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  65189. */
  65190. static CreatePolyhedron(name: string, options: {
  65191. type?: number;
  65192. size?: number;
  65193. sizeX?: number;
  65194. sizeY?: number;
  65195. sizeZ?: number;
  65196. custom?: any;
  65197. faceUV?: Vector4[];
  65198. faceColors?: Color4[];
  65199. flat?: boolean;
  65200. updatable?: boolean;
  65201. sideOrientation?: number;
  65202. frontUVs?: Vector4;
  65203. backUVs?: Vector4;
  65204. }, scene?: Nullable<Scene>): Mesh;
  65205. /**
  65206. * Creates a decal mesh.
  65207. * 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
  65208. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65209. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65210. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65211. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65212. * @param name defines the name of the mesh
  65213. * @param sourceMesh defines the mesh where the decal must be applied
  65214. * @param options defines the options used to create the mesh
  65215. * @param scene defines the hosting scene
  65216. * @returns the decal mesh
  65217. * @see https://doc.babylonjs.com/how_to/decals
  65218. */
  65219. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65220. position?: Vector3;
  65221. normal?: Vector3;
  65222. size?: Vector3;
  65223. angle?: number;
  65224. }): Mesh;
  65225. }
  65226. }
  65227. declare module BABYLON {
  65228. /**
  65229. * A simplifier interface for future simplification implementations
  65230. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65231. */
  65232. export interface ISimplifier {
  65233. /**
  65234. * Simplification of a given mesh according to the given settings.
  65235. * Since this requires computation, it is assumed that the function runs async.
  65236. * @param settings The settings of the simplification, including quality and distance
  65237. * @param successCallback A callback that will be called after the mesh was simplified.
  65238. * @param errorCallback in case of an error, this callback will be called. optional.
  65239. */
  65240. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  65241. }
  65242. /**
  65243. * Expected simplification settings.
  65244. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  65245. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65246. */
  65247. export interface ISimplificationSettings {
  65248. /**
  65249. * Gets or sets the expected quality
  65250. */
  65251. quality: number;
  65252. /**
  65253. * Gets or sets the distance when this optimized version should be used
  65254. */
  65255. distance: number;
  65256. /**
  65257. * Gets an already optimized mesh
  65258. */
  65259. optimizeMesh?: boolean;
  65260. }
  65261. /**
  65262. * Class used to specify simplification options
  65263. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65264. */
  65265. export class SimplificationSettings implements ISimplificationSettings {
  65266. /** expected quality */
  65267. quality: number;
  65268. /** distance when this optimized version should be used */
  65269. distance: number;
  65270. /** already optimized mesh */
  65271. optimizeMesh?: boolean | undefined;
  65272. /**
  65273. * Creates a SimplificationSettings
  65274. * @param quality expected quality
  65275. * @param distance distance when this optimized version should be used
  65276. * @param optimizeMesh already optimized mesh
  65277. */
  65278. constructor(
  65279. /** expected quality */
  65280. quality: number,
  65281. /** distance when this optimized version should be used */
  65282. distance: number,
  65283. /** already optimized mesh */
  65284. optimizeMesh?: boolean | undefined);
  65285. }
  65286. /**
  65287. * Interface used to define a simplification task
  65288. */
  65289. export interface ISimplificationTask {
  65290. /**
  65291. * Array of settings
  65292. */
  65293. settings: Array<ISimplificationSettings>;
  65294. /**
  65295. * Simplification type
  65296. */
  65297. simplificationType: SimplificationType;
  65298. /**
  65299. * Mesh to simplify
  65300. */
  65301. mesh: Mesh;
  65302. /**
  65303. * Callback called on success
  65304. */
  65305. successCallback?: () => void;
  65306. /**
  65307. * Defines if parallel processing can be used
  65308. */
  65309. parallelProcessing: boolean;
  65310. }
  65311. /**
  65312. * Queue used to order the simplification tasks
  65313. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65314. */
  65315. export class SimplificationQueue {
  65316. private _simplificationArray;
  65317. /**
  65318. * Gets a boolean indicating that the process is still running
  65319. */
  65320. running: boolean;
  65321. /**
  65322. * Creates a new queue
  65323. */
  65324. constructor();
  65325. /**
  65326. * Adds a new simplification task
  65327. * @param task defines a task to add
  65328. */
  65329. addTask(task: ISimplificationTask): void;
  65330. /**
  65331. * Execute next task
  65332. */
  65333. executeNext(): void;
  65334. /**
  65335. * Execute a simplification task
  65336. * @param task defines the task to run
  65337. */
  65338. runSimplification(task: ISimplificationTask): void;
  65339. private getSimplifier;
  65340. }
  65341. /**
  65342. * The implemented types of simplification
  65343. * At the moment only Quadratic Error Decimation is implemented
  65344. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65345. */
  65346. export enum SimplificationType {
  65347. /** Quadratic error decimation */
  65348. QUADRATIC = 0
  65349. }
  65350. /**
  65351. * An implementation of the Quadratic Error simplification algorithm.
  65352. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  65353. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  65354. * @author RaananW
  65355. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65356. */
  65357. export class QuadraticErrorSimplification implements ISimplifier {
  65358. private _mesh;
  65359. private triangles;
  65360. private vertices;
  65361. private references;
  65362. private _reconstructedMesh;
  65363. /** Gets or sets the number pf sync interations */
  65364. syncIterations: number;
  65365. /** Gets or sets the aggressiveness of the simplifier */
  65366. aggressiveness: number;
  65367. /** Gets or sets the number of allowed iterations for decimation */
  65368. decimationIterations: number;
  65369. /** Gets or sets the espilon to use for bounding box computation */
  65370. boundingBoxEpsilon: number;
  65371. /**
  65372. * Creates a new QuadraticErrorSimplification
  65373. * @param _mesh defines the target mesh
  65374. */
  65375. constructor(_mesh: Mesh);
  65376. /**
  65377. * Simplification of a given mesh according to the given settings.
  65378. * Since this requires computation, it is assumed that the function runs async.
  65379. * @param settings The settings of the simplification, including quality and distance
  65380. * @param successCallback A callback that will be called after the mesh was simplified.
  65381. */
  65382. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  65383. private runDecimation;
  65384. private initWithMesh;
  65385. private init;
  65386. private reconstructMesh;
  65387. private initDecimatedMesh;
  65388. private isFlipped;
  65389. private updateTriangles;
  65390. private identifyBorder;
  65391. private updateMesh;
  65392. private vertexError;
  65393. private calculateError;
  65394. }
  65395. }
  65396. declare module BABYLON {
  65397. interface Scene {
  65398. /** @hidden (Backing field) */
  65399. _simplificationQueue: SimplificationQueue;
  65400. /**
  65401. * Gets or sets the simplification queue attached to the scene
  65402. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65403. */
  65404. simplificationQueue: SimplificationQueue;
  65405. }
  65406. interface Mesh {
  65407. /**
  65408. * Simplify the mesh according to the given array of settings.
  65409. * Function will return immediately and will simplify async
  65410. * @param settings a collection of simplification settings
  65411. * @param parallelProcessing should all levels calculate parallel or one after the other
  65412. * @param simplificationType the type of simplification to run
  65413. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  65414. * @returns the current mesh
  65415. */
  65416. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  65417. }
  65418. /**
  65419. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  65420. * created in a scene
  65421. */
  65422. export class SimplicationQueueSceneComponent implements ISceneComponent {
  65423. /**
  65424. * The component name helpfull to identify the component in the list of scene components.
  65425. */
  65426. readonly name: string;
  65427. /**
  65428. * The scene the component belongs to.
  65429. */
  65430. scene: Scene;
  65431. /**
  65432. * Creates a new instance of the component for the given scene
  65433. * @param scene Defines the scene to register the component in
  65434. */
  65435. constructor(scene: Scene);
  65436. /**
  65437. * Registers the component in a given scene
  65438. */
  65439. register(): void;
  65440. /**
  65441. * Rebuilds the elements related to this component in case of
  65442. * context lost for instance.
  65443. */
  65444. rebuild(): void;
  65445. /**
  65446. * Disposes the component and the associated ressources
  65447. */
  65448. dispose(): void;
  65449. private _beforeCameraUpdate;
  65450. }
  65451. }
  65452. declare module BABYLON {
  65453. interface Mesh {
  65454. /**
  65455. * Creates a new thin instance
  65456. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  65457. * @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
  65458. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  65459. */
  65460. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  65461. /**
  65462. * Adds the transformation (matrix) of the current mesh as a thin instance
  65463. * @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
  65464. * @returns the thin instance index number
  65465. */
  65466. thinInstanceAddSelf(refresh: boolean): number;
  65467. /**
  65468. * Registers a custom attribute to be used with thin instances
  65469. * @param kind name of the attribute
  65470. * @param stride size in floats of the attribute
  65471. */
  65472. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  65473. /**
  65474. * Sets the matrix of a thin instance
  65475. * @param index index of the thin instance
  65476. * @param matrix matrix to set
  65477. * @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
  65478. */
  65479. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  65480. /**
  65481. * Sets the value of a custom attribute for a thin instance
  65482. * @param kind name of the attribute
  65483. * @param index index of the thin instance
  65484. * @param value value to set
  65485. * @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
  65486. */
  65487. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  65488. /**
  65489. * 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.
  65490. */
  65491. thinInstanceCount: number;
  65492. /**
  65493. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  65494. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  65495. * @param buffer buffer to set
  65496. * @param stride size in floats of each value of the buffer
  65497. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  65498. */
  65499. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  65500. /**
  65501. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  65502. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  65503. */
  65504. thinInstanceBufferUpdated(kind: string): void;
  65505. /**
  65506. * Refreshes the bounding info, taking into account all the thin instances defined
  65507. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  65508. */
  65509. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  65510. /** @hidden */
  65511. _thinInstanceInitializeUserStorage(): void;
  65512. /** @hidden */
  65513. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  65514. /** @hidden */
  65515. _userThinInstanceBuffersStorage: {
  65516. data: {
  65517. [key: string]: Float32Array;
  65518. };
  65519. sizes: {
  65520. [key: string]: number;
  65521. };
  65522. vertexBuffers: {
  65523. [key: string]: Nullable<VertexBuffer>;
  65524. };
  65525. strides: {
  65526. [key: string]: number;
  65527. };
  65528. };
  65529. }
  65530. }
  65531. declare module BABYLON {
  65532. /**
  65533. * Navigation plugin interface to add navigation constrained by a navigation mesh
  65534. */
  65535. export interface INavigationEnginePlugin {
  65536. /**
  65537. * plugin name
  65538. */
  65539. name: string;
  65540. /**
  65541. * Creates a navigation mesh
  65542. * @param meshes array of all the geometry used to compute the navigatio mesh
  65543. * @param parameters bunch of parameters used to filter geometry
  65544. */
  65545. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65546. /**
  65547. * Create a navigation mesh debug mesh
  65548. * @param scene is where the mesh will be added
  65549. * @returns debug display mesh
  65550. */
  65551. createDebugNavMesh(scene: Scene): Mesh;
  65552. /**
  65553. * Get a navigation mesh constrained position, closest to the parameter position
  65554. * @param position world position
  65555. * @returns the closest point to position constrained by the navigation mesh
  65556. */
  65557. getClosestPoint(position: Vector3): Vector3;
  65558. /**
  65559. * Get a navigation mesh constrained position, closest to the parameter position
  65560. * @param position world position
  65561. * @param result output the closest point to position constrained by the navigation mesh
  65562. */
  65563. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65564. /**
  65565. * Get a navigation mesh constrained position, within a particular radius
  65566. * @param position world position
  65567. * @param maxRadius the maximum distance to the constrained world position
  65568. * @returns the closest point to position constrained by the navigation mesh
  65569. */
  65570. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65571. /**
  65572. * Get a navigation mesh constrained position, within a particular radius
  65573. * @param position world position
  65574. * @param maxRadius the maximum distance to the constrained world position
  65575. * @param result output the closest point to position constrained by the navigation mesh
  65576. */
  65577. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65578. /**
  65579. * Compute the final position from a segment made of destination-position
  65580. * @param position world position
  65581. * @param destination world position
  65582. * @returns the resulting point along the navmesh
  65583. */
  65584. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65585. /**
  65586. * Compute the final position from a segment made of destination-position
  65587. * @param position world position
  65588. * @param destination world position
  65589. * @param result output the resulting point along the navmesh
  65590. */
  65591. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65592. /**
  65593. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65594. * @param start world position
  65595. * @param end world position
  65596. * @returns array containing world position composing the path
  65597. */
  65598. computePath(start: Vector3, end: Vector3): Vector3[];
  65599. /**
  65600. * If this plugin is supported
  65601. * @returns true if plugin is supported
  65602. */
  65603. isSupported(): boolean;
  65604. /**
  65605. * Create a new Crowd so you can add agents
  65606. * @param maxAgents the maximum agent count in the crowd
  65607. * @param maxAgentRadius the maximum radius an agent can have
  65608. * @param scene to attach the crowd to
  65609. * @returns the crowd you can add agents to
  65610. */
  65611. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65612. /**
  65613. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65614. * The queries will try to find a solution within those bounds
  65615. * default is (1,1,1)
  65616. * @param extent x,y,z value that define the extent around the queries point of reference
  65617. */
  65618. setDefaultQueryExtent(extent: Vector3): void;
  65619. /**
  65620. * Get the Bounding box extent specified by setDefaultQueryExtent
  65621. * @returns the box extent values
  65622. */
  65623. getDefaultQueryExtent(): Vector3;
  65624. /**
  65625. * build the navmesh from a previously saved state using getNavmeshData
  65626. * @param data the Uint8Array returned by getNavmeshData
  65627. */
  65628. buildFromNavmeshData(data: Uint8Array): void;
  65629. /**
  65630. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65631. * @returns data the Uint8Array that can be saved and reused
  65632. */
  65633. getNavmeshData(): Uint8Array;
  65634. /**
  65635. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65636. * @param result output the box extent values
  65637. */
  65638. getDefaultQueryExtentToRef(result: Vector3): void;
  65639. /**
  65640. * Release all resources
  65641. */
  65642. dispose(): void;
  65643. }
  65644. /**
  65645. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65646. */
  65647. export interface ICrowd {
  65648. /**
  65649. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65650. * You can attach anything to that node. The node position is updated in the scene update tick.
  65651. * @param pos world position that will be constrained by the navigation mesh
  65652. * @param parameters agent parameters
  65653. * @param transform hooked to the agent that will be update by the scene
  65654. * @returns agent index
  65655. */
  65656. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65657. /**
  65658. * Returns the agent position in world space
  65659. * @param index agent index returned by addAgent
  65660. * @returns world space position
  65661. */
  65662. getAgentPosition(index: number): Vector3;
  65663. /**
  65664. * Gets the agent position result in world space
  65665. * @param index agent index returned by addAgent
  65666. * @param result output world space position
  65667. */
  65668. getAgentPositionToRef(index: number, result: Vector3): void;
  65669. /**
  65670. * Gets the agent velocity in world space
  65671. * @param index agent index returned by addAgent
  65672. * @returns world space velocity
  65673. */
  65674. getAgentVelocity(index: number): Vector3;
  65675. /**
  65676. * Gets the agent velocity result in world space
  65677. * @param index agent index returned by addAgent
  65678. * @param result output world space velocity
  65679. */
  65680. getAgentVelocityToRef(index: number, result: Vector3): void;
  65681. /**
  65682. * remove a particular agent previously created
  65683. * @param index agent index returned by addAgent
  65684. */
  65685. removeAgent(index: number): void;
  65686. /**
  65687. * get the list of all agents attached to this crowd
  65688. * @returns list of agent indices
  65689. */
  65690. getAgents(): number[];
  65691. /**
  65692. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65693. * @param deltaTime in seconds
  65694. */
  65695. update(deltaTime: number): void;
  65696. /**
  65697. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65698. * @param index agent index returned by addAgent
  65699. * @param destination targeted world position
  65700. */
  65701. agentGoto(index: number, destination: Vector3): void;
  65702. /**
  65703. * Teleport the agent to a new position
  65704. * @param index agent index returned by addAgent
  65705. * @param destination targeted world position
  65706. */
  65707. agentTeleport(index: number, destination: Vector3): void;
  65708. /**
  65709. * Update agent parameters
  65710. * @param index agent index returned by addAgent
  65711. * @param parameters agent parameters
  65712. */
  65713. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65714. /**
  65715. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65716. * The queries will try to find a solution within those bounds
  65717. * default is (1,1,1)
  65718. * @param extent x,y,z value that define the extent around the queries point of reference
  65719. */
  65720. setDefaultQueryExtent(extent: Vector3): void;
  65721. /**
  65722. * Get the Bounding box extent specified by setDefaultQueryExtent
  65723. * @returns the box extent values
  65724. */
  65725. getDefaultQueryExtent(): Vector3;
  65726. /**
  65727. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65728. * @param result output the box extent values
  65729. */
  65730. getDefaultQueryExtentToRef(result: Vector3): void;
  65731. /**
  65732. * Release all resources
  65733. */
  65734. dispose(): void;
  65735. }
  65736. /**
  65737. * Configures an agent
  65738. */
  65739. export interface IAgentParameters {
  65740. /**
  65741. * Agent radius. [Limit: >= 0]
  65742. */
  65743. radius: number;
  65744. /**
  65745. * Agent height. [Limit: > 0]
  65746. */
  65747. height: number;
  65748. /**
  65749. * Maximum allowed acceleration. [Limit: >= 0]
  65750. */
  65751. maxAcceleration: number;
  65752. /**
  65753. * Maximum allowed speed. [Limit: >= 0]
  65754. */
  65755. maxSpeed: number;
  65756. /**
  65757. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65758. */
  65759. collisionQueryRange: number;
  65760. /**
  65761. * The path visibility optimization range. [Limit: > 0]
  65762. */
  65763. pathOptimizationRange: number;
  65764. /**
  65765. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65766. */
  65767. separationWeight: number;
  65768. }
  65769. /**
  65770. * Configures the navigation mesh creation
  65771. */
  65772. export interface INavMeshParameters {
  65773. /**
  65774. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65775. */
  65776. cs: number;
  65777. /**
  65778. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65779. */
  65780. ch: number;
  65781. /**
  65782. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65783. */
  65784. walkableSlopeAngle: number;
  65785. /**
  65786. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65787. * be considered walkable. [Limit: >= 3] [Units: vx]
  65788. */
  65789. walkableHeight: number;
  65790. /**
  65791. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65792. */
  65793. walkableClimb: number;
  65794. /**
  65795. * The distance to erode/shrink the walkable area of the heightfield away from
  65796. * obstructions. [Limit: >=0] [Units: vx]
  65797. */
  65798. walkableRadius: number;
  65799. /**
  65800. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65801. */
  65802. maxEdgeLen: number;
  65803. /**
  65804. * The maximum distance a simplfied contour's border edges should deviate
  65805. * the original raw contour. [Limit: >=0] [Units: vx]
  65806. */
  65807. maxSimplificationError: number;
  65808. /**
  65809. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65810. */
  65811. minRegionArea: number;
  65812. /**
  65813. * Any regions with a span count smaller than this value will, if possible,
  65814. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65815. */
  65816. mergeRegionArea: number;
  65817. /**
  65818. * The maximum number of vertices allowed for polygons generated during the
  65819. * contour to polygon conversion process. [Limit: >= 3]
  65820. */
  65821. maxVertsPerPoly: number;
  65822. /**
  65823. * Sets the sampling distance to use when generating the detail mesh.
  65824. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65825. */
  65826. detailSampleDist: number;
  65827. /**
  65828. * The maximum distance the detail mesh surface should deviate from heightfield
  65829. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65830. */
  65831. detailSampleMaxError: number;
  65832. }
  65833. }
  65834. declare module BABYLON {
  65835. /**
  65836. * RecastJS navigation plugin
  65837. */
  65838. export class RecastJSPlugin implements INavigationEnginePlugin {
  65839. /**
  65840. * Reference to the Recast library
  65841. */
  65842. bjsRECAST: any;
  65843. /**
  65844. * plugin name
  65845. */
  65846. name: string;
  65847. /**
  65848. * the first navmesh created. We might extend this to support multiple navmeshes
  65849. */
  65850. navMesh: any;
  65851. /**
  65852. * Initializes the recastJS plugin
  65853. * @param recastInjection can be used to inject your own recast reference
  65854. */
  65855. constructor(recastInjection?: any);
  65856. /**
  65857. * Creates a navigation mesh
  65858. * @param meshes array of all the geometry used to compute the navigatio mesh
  65859. * @param parameters bunch of parameters used to filter geometry
  65860. */
  65861. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65862. /**
  65863. * Create a navigation mesh debug mesh
  65864. * @param scene is where the mesh will be added
  65865. * @returns debug display mesh
  65866. */
  65867. createDebugNavMesh(scene: Scene): Mesh;
  65868. /**
  65869. * Get a navigation mesh constrained position, closest to the parameter position
  65870. * @param position world position
  65871. * @returns the closest point to position constrained by the navigation mesh
  65872. */
  65873. getClosestPoint(position: Vector3): Vector3;
  65874. /**
  65875. * Get a navigation mesh constrained position, closest to the parameter position
  65876. * @param position world position
  65877. * @param result output the closest point to position constrained by the navigation mesh
  65878. */
  65879. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65880. /**
  65881. * Get a navigation mesh constrained position, within a particular radius
  65882. * @param position world position
  65883. * @param maxRadius the maximum distance to the constrained world position
  65884. * @returns the closest point to position constrained by the navigation mesh
  65885. */
  65886. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65887. /**
  65888. * Get a navigation mesh constrained position, within a particular radius
  65889. * @param position world position
  65890. * @param maxRadius the maximum distance to the constrained world position
  65891. * @param result output the closest point to position constrained by the navigation mesh
  65892. */
  65893. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65894. /**
  65895. * Compute the final position from a segment made of destination-position
  65896. * @param position world position
  65897. * @param destination world position
  65898. * @returns the resulting point along the navmesh
  65899. */
  65900. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65901. /**
  65902. * Compute the final position from a segment made of destination-position
  65903. * @param position world position
  65904. * @param destination world position
  65905. * @param result output the resulting point along the navmesh
  65906. */
  65907. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65908. /**
  65909. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65910. * @param start world position
  65911. * @param end world position
  65912. * @returns array containing world position composing the path
  65913. */
  65914. computePath(start: Vector3, end: Vector3): Vector3[];
  65915. /**
  65916. * Create a new Crowd so you can add agents
  65917. * @param maxAgents the maximum agent count in the crowd
  65918. * @param maxAgentRadius the maximum radius an agent can have
  65919. * @param scene to attach the crowd to
  65920. * @returns the crowd you can add agents to
  65921. */
  65922. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65923. /**
  65924. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65925. * The queries will try to find a solution within those bounds
  65926. * default is (1,1,1)
  65927. * @param extent x,y,z value that define the extent around the queries point of reference
  65928. */
  65929. setDefaultQueryExtent(extent: Vector3): void;
  65930. /**
  65931. * Get the Bounding box extent specified by setDefaultQueryExtent
  65932. * @returns the box extent values
  65933. */
  65934. getDefaultQueryExtent(): Vector3;
  65935. /**
  65936. * build the navmesh from a previously saved state using getNavmeshData
  65937. * @param data the Uint8Array returned by getNavmeshData
  65938. */
  65939. buildFromNavmeshData(data: Uint8Array): void;
  65940. /**
  65941. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65942. * @returns data the Uint8Array that can be saved and reused
  65943. */
  65944. getNavmeshData(): Uint8Array;
  65945. /**
  65946. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65947. * @param result output the box extent values
  65948. */
  65949. getDefaultQueryExtentToRef(result: Vector3): void;
  65950. /**
  65951. * Disposes
  65952. */
  65953. dispose(): void;
  65954. /**
  65955. * If this plugin is supported
  65956. * @returns true if plugin is supported
  65957. */
  65958. isSupported(): boolean;
  65959. }
  65960. /**
  65961. * Recast detour crowd implementation
  65962. */
  65963. export class RecastJSCrowd implements ICrowd {
  65964. /**
  65965. * Recast/detour plugin
  65966. */
  65967. bjsRECASTPlugin: RecastJSPlugin;
  65968. /**
  65969. * Link to the detour crowd
  65970. */
  65971. recastCrowd: any;
  65972. /**
  65973. * One transform per agent
  65974. */
  65975. transforms: TransformNode[];
  65976. /**
  65977. * All agents created
  65978. */
  65979. agents: number[];
  65980. /**
  65981. * Link to the scene is kept to unregister the crowd from the scene
  65982. */
  65983. private _scene;
  65984. /**
  65985. * Observer for crowd updates
  65986. */
  65987. private _onBeforeAnimationsObserver;
  65988. /**
  65989. * Constructor
  65990. * @param plugin recastJS plugin
  65991. * @param maxAgents the maximum agent count in the crowd
  65992. * @param maxAgentRadius the maximum radius an agent can have
  65993. * @param scene to attach the crowd to
  65994. * @returns the crowd you can add agents to
  65995. */
  65996. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65997. /**
  65998. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65999. * You can attach anything to that node. The node position is updated in the scene update tick.
  66000. * @param pos world position that will be constrained by the navigation mesh
  66001. * @param parameters agent parameters
  66002. * @param transform hooked to the agent that will be update by the scene
  66003. * @returns agent index
  66004. */
  66005. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66006. /**
  66007. * Returns the agent position in world space
  66008. * @param index agent index returned by addAgent
  66009. * @returns world space position
  66010. */
  66011. getAgentPosition(index: number): Vector3;
  66012. /**
  66013. * Returns the agent position result in world space
  66014. * @param index agent index returned by addAgent
  66015. * @param result output world space position
  66016. */
  66017. getAgentPositionToRef(index: number, result: Vector3): void;
  66018. /**
  66019. * Returns the agent velocity in world space
  66020. * @param index agent index returned by addAgent
  66021. * @returns world space velocity
  66022. */
  66023. getAgentVelocity(index: number): Vector3;
  66024. /**
  66025. * Returns the agent velocity result in world space
  66026. * @param index agent index returned by addAgent
  66027. * @param result output world space velocity
  66028. */
  66029. getAgentVelocityToRef(index: number, result: Vector3): void;
  66030. /**
  66031. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66032. * @param index agent index returned by addAgent
  66033. * @param destination targeted world position
  66034. */
  66035. agentGoto(index: number, destination: Vector3): void;
  66036. /**
  66037. * Teleport the agent to a new position
  66038. * @param index agent index returned by addAgent
  66039. * @param destination targeted world position
  66040. */
  66041. agentTeleport(index: number, destination: Vector3): void;
  66042. /**
  66043. * Update agent parameters
  66044. * @param index agent index returned by addAgent
  66045. * @param parameters agent parameters
  66046. */
  66047. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66048. /**
  66049. * remove a particular agent previously created
  66050. * @param index agent index returned by addAgent
  66051. */
  66052. removeAgent(index: number): void;
  66053. /**
  66054. * get the list of all agents attached to this crowd
  66055. * @returns list of agent indices
  66056. */
  66057. getAgents(): number[];
  66058. /**
  66059. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66060. * @param deltaTime in seconds
  66061. */
  66062. update(deltaTime: number): void;
  66063. /**
  66064. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66065. * The queries will try to find a solution within those bounds
  66066. * default is (1,1,1)
  66067. * @param extent x,y,z value that define the extent around the queries point of reference
  66068. */
  66069. setDefaultQueryExtent(extent: Vector3): void;
  66070. /**
  66071. * Get the Bounding box extent specified by setDefaultQueryExtent
  66072. * @returns the box extent values
  66073. */
  66074. getDefaultQueryExtent(): Vector3;
  66075. /**
  66076. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66077. * @param result output the box extent values
  66078. */
  66079. getDefaultQueryExtentToRef(result: Vector3): void;
  66080. /**
  66081. * Release all resources
  66082. */
  66083. dispose(): void;
  66084. }
  66085. }
  66086. declare module BABYLON {
  66087. /**
  66088. * Class used to enable access to IndexedDB
  66089. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  66090. */
  66091. export class Database implements IOfflineProvider {
  66092. private _callbackManifestChecked;
  66093. private _currentSceneUrl;
  66094. private _db;
  66095. private _enableSceneOffline;
  66096. private _enableTexturesOffline;
  66097. private _manifestVersionFound;
  66098. private _mustUpdateRessources;
  66099. private _hasReachedQuota;
  66100. private _isSupported;
  66101. private _idbFactory;
  66102. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  66103. private static IsUASupportingBlobStorage;
  66104. /**
  66105. * Gets a boolean indicating if Database storate is enabled (off by default)
  66106. */
  66107. static IDBStorageEnabled: boolean;
  66108. /**
  66109. * Gets a boolean indicating if scene must be saved in the database
  66110. */
  66111. get enableSceneOffline(): boolean;
  66112. /**
  66113. * Gets a boolean indicating if textures must be saved in the database
  66114. */
  66115. get enableTexturesOffline(): boolean;
  66116. /**
  66117. * Creates a new Database
  66118. * @param urlToScene defines the url to load the scene
  66119. * @param callbackManifestChecked defines the callback to use when manifest is checked
  66120. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  66121. */
  66122. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  66123. private static _ParseURL;
  66124. private static _ReturnFullUrlLocation;
  66125. private _checkManifestFile;
  66126. /**
  66127. * Open the database and make it available
  66128. * @param successCallback defines the callback to call on success
  66129. * @param errorCallback defines the callback to call on error
  66130. */
  66131. open(successCallback: () => void, errorCallback: () => void): void;
  66132. /**
  66133. * Loads an image from the database
  66134. * @param url defines the url to load from
  66135. * @param image defines the target DOM image
  66136. */
  66137. loadImage(url: string, image: HTMLImageElement): void;
  66138. private _loadImageFromDBAsync;
  66139. private _saveImageIntoDBAsync;
  66140. private _checkVersionFromDB;
  66141. private _loadVersionFromDBAsync;
  66142. private _saveVersionIntoDBAsync;
  66143. /**
  66144. * Loads a file from database
  66145. * @param url defines the URL to load from
  66146. * @param sceneLoaded defines a callback to call on success
  66147. * @param progressCallBack defines a callback to call when progress changed
  66148. * @param errorCallback defines a callback to call on error
  66149. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  66150. */
  66151. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  66152. private _loadFileAsync;
  66153. private _saveFileAsync;
  66154. /**
  66155. * Validates if xhr data is correct
  66156. * @param xhr defines the request to validate
  66157. * @param dataType defines the expected data type
  66158. * @returns true if data is correct
  66159. */
  66160. private static _ValidateXHRData;
  66161. }
  66162. }
  66163. declare module BABYLON {
  66164. /** @hidden */
  66165. export var gpuUpdateParticlesPixelShader: {
  66166. name: string;
  66167. shader: string;
  66168. };
  66169. }
  66170. declare module BABYLON {
  66171. /** @hidden */
  66172. export var gpuUpdateParticlesVertexShader: {
  66173. name: string;
  66174. shader: string;
  66175. };
  66176. }
  66177. declare module BABYLON {
  66178. /** @hidden */
  66179. export var clipPlaneFragmentDeclaration2: {
  66180. name: string;
  66181. shader: string;
  66182. };
  66183. }
  66184. declare module BABYLON {
  66185. /** @hidden */
  66186. export var gpuRenderParticlesPixelShader: {
  66187. name: string;
  66188. shader: string;
  66189. };
  66190. }
  66191. declare module BABYLON {
  66192. /** @hidden */
  66193. export var clipPlaneVertexDeclaration2: {
  66194. name: string;
  66195. shader: string;
  66196. };
  66197. }
  66198. declare module BABYLON {
  66199. /** @hidden */
  66200. export var gpuRenderParticlesVertexShader: {
  66201. name: string;
  66202. shader: string;
  66203. };
  66204. }
  66205. declare module BABYLON {
  66206. /**
  66207. * This represents a GPU particle system in Babylon
  66208. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  66209. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  66210. */
  66211. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  66212. /**
  66213. * The layer mask we are rendering the particles through.
  66214. */
  66215. layerMask: number;
  66216. private _capacity;
  66217. private _activeCount;
  66218. private _currentActiveCount;
  66219. private _accumulatedCount;
  66220. private _renderEffect;
  66221. private _updateEffect;
  66222. private _buffer0;
  66223. private _buffer1;
  66224. private _spriteBuffer;
  66225. private _updateVAO;
  66226. private _renderVAO;
  66227. private _targetIndex;
  66228. private _sourceBuffer;
  66229. private _targetBuffer;
  66230. private _engine;
  66231. private _currentRenderId;
  66232. private _started;
  66233. private _stopped;
  66234. private _timeDelta;
  66235. private _randomTexture;
  66236. private _randomTexture2;
  66237. private _attributesStrideSize;
  66238. private _updateEffectOptions;
  66239. private _randomTextureSize;
  66240. private _actualFrame;
  66241. private _customEffect;
  66242. private readonly _rawTextureWidth;
  66243. /**
  66244. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  66245. */
  66246. static get IsSupported(): boolean;
  66247. /**
  66248. * An event triggered when the system is disposed.
  66249. */
  66250. onDisposeObservable: Observable<IParticleSystem>;
  66251. /**
  66252. * Gets the maximum number of particles active at the same time.
  66253. * @returns The max number of active particles.
  66254. */
  66255. getCapacity(): number;
  66256. /**
  66257. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  66258. * to override the particles.
  66259. */
  66260. forceDepthWrite: boolean;
  66261. /**
  66262. * Gets or set the number of active particles
  66263. */
  66264. get activeParticleCount(): number;
  66265. set activeParticleCount(value: number);
  66266. private _preWarmDone;
  66267. /**
  66268. * Specifies if the particles are updated in emitter local space or world space.
  66269. */
  66270. isLocal: boolean;
  66271. /**
  66272. * Is this system ready to be used/rendered
  66273. * @return true if the system is ready
  66274. */
  66275. isReady(): boolean;
  66276. /**
  66277. * Gets if the system has been started. (Note: this will still be true after stop is called)
  66278. * @returns True if it has been started, otherwise false.
  66279. */
  66280. isStarted(): boolean;
  66281. /**
  66282. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  66283. * @returns True if it has been stopped, otherwise false.
  66284. */
  66285. isStopped(): boolean;
  66286. /**
  66287. * Gets a boolean indicating that the system is stopping
  66288. * @returns true if the system is currently stopping
  66289. */
  66290. isStopping(): boolean;
  66291. /**
  66292. * Gets the number of particles active at the same time.
  66293. * @returns The number of active particles.
  66294. */
  66295. getActiveCount(): number;
  66296. /**
  66297. * Starts the particle system and begins to emit
  66298. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  66299. */
  66300. start(delay?: number): void;
  66301. /**
  66302. * Stops the particle system.
  66303. */
  66304. stop(): void;
  66305. /**
  66306. * Remove all active particles
  66307. */
  66308. reset(): void;
  66309. /**
  66310. * Returns the string "GPUParticleSystem"
  66311. * @returns a string containing the class name
  66312. */
  66313. getClassName(): string;
  66314. /**
  66315. * Gets the custom effect used to render the particles
  66316. * @param blendMode Blend mode for which the effect should be retrieved
  66317. * @returns The effect
  66318. */
  66319. getCustomEffect(blendMode?: number): Nullable<Effect>;
  66320. /**
  66321. * Sets the custom effect used to render the particles
  66322. * @param effect The effect to set
  66323. * @param blendMode Blend mode for which the effect should be set
  66324. */
  66325. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  66326. /** @hidden */
  66327. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  66328. /**
  66329. * Observable that will be called just before the particles are drawn
  66330. */
  66331. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  66332. /**
  66333. * Gets the name of the particle vertex shader
  66334. */
  66335. get vertexShaderName(): string;
  66336. private _colorGradientsTexture;
  66337. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  66338. /**
  66339. * Adds a new color gradient
  66340. * @param gradient defines the gradient to use (between 0 and 1)
  66341. * @param color1 defines the color to affect to the specified gradient
  66342. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  66343. * @returns the current particle system
  66344. */
  66345. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  66346. private _refreshColorGradient;
  66347. /** Force the system to rebuild all gradients that need to be resync */
  66348. forceRefreshGradients(): void;
  66349. /**
  66350. * Remove a specific color gradient
  66351. * @param gradient defines the gradient to remove
  66352. * @returns the current particle system
  66353. */
  66354. removeColorGradient(gradient: number): GPUParticleSystem;
  66355. private _angularSpeedGradientsTexture;
  66356. private _sizeGradientsTexture;
  66357. private _velocityGradientsTexture;
  66358. private _limitVelocityGradientsTexture;
  66359. private _dragGradientsTexture;
  66360. private _addFactorGradient;
  66361. /**
  66362. * Adds a new size gradient
  66363. * @param gradient defines the gradient to use (between 0 and 1)
  66364. * @param factor defines the size factor to affect to the specified gradient
  66365. * @returns the current particle system
  66366. */
  66367. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  66368. /**
  66369. * Remove a specific size gradient
  66370. * @param gradient defines the gradient to remove
  66371. * @returns the current particle system
  66372. */
  66373. removeSizeGradient(gradient: number): GPUParticleSystem;
  66374. private _refreshFactorGradient;
  66375. /**
  66376. * Adds a new angular speed gradient
  66377. * @param gradient defines the gradient to use (between 0 and 1)
  66378. * @param factor defines the angular speed to affect to the specified gradient
  66379. * @returns the current particle system
  66380. */
  66381. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  66382. /**
  66383. * Remove a specific angular speed gradient
  66384. * @param gradient defines the gradient to remove
  66385. * @returns the current particle system
  66386. */
  66387. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  66388. /**
  66389. * Adds a new velocity gradient
  66390. * @param gradient defines the gradient to use (between 0 and 1)
  66391. * @param factor defines the velocity to affect to the specified gradient
  66392. * @returns the current particle system
  66393. */
  66394. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66395. /**
  66396. * Remove a specific velocity gradient
  66397. * @param gradient defines the gradient to remove
  66398. * @returns the current particle system
  66399. */
  66400. removeVelocityGradient(gradient: number): GPUParticleSystem;
  66401. /**
  66402. * Adds a new limit velocity gradient
  66403. * @param gradient defines the gradient to use (between 0 and 1)
  66404. * @param factor defines the limit velocity value to affect to the specified gradient
  66405. * @returns the current particle system
  66406. */
  66407. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66408. /**
  66409. * Remove a specific limit velocity gradient
  66410. * @param gradient defines the gradient to remove
  66411. * @returns the current particle system
  66412. */
  66413. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  66414. /**
  66415. * Adds a new drag gradient
  66416. * @param gradient defines the gradient to use (between 0 and 1)
  66417. * @param factor defines the drag value to affect to the specified gradient
  66418. * @returns the current particle system
  66419. */
  66420. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  66421. /**
  66422. * Remove a specific drag gradient
  66423. * @param gradient defines the gradient to remove
  66424. * @returns the current particle system
  66425. */
  66426. removeDragGradient(gradient: number): GPUParticleSystem;
  66427. /**
  66428. * Not supported by GPUParticleSystem
  66429. * @param gradient defines the gradient to use (between 0 and 1)
  66430. * @param factor defines the emit rate value to affect to the specified gradient
  66431. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66432. * @returns the current particle system
  66433. */
  66434. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66435. /**
  66436. * Not supported by GPUParticleSystem
  66437. * @param gradient defines the gradient to remove
  66438. * @returns the current particle system
  66439. */
  66440. removeEmitRateGradient(gradient: number): IParticleSystem;
  66441. /**
  66442. * Not supported by GPUParticleSystem
  66443. * @param gradient defines the gradient to use (between 0 and 1)
  66444. * @param factor defines the start size value to affect to the specified gradient
  66445. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66446. * @returns the current particle system
  66447. */
  66448. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66449. /**
  66450. * Not supported by GPUParticleSystem
  66451. * @param gradient defines the gradient to remove
  66452. * @returns the current particle system
  66453. */
  66454. removeStartSizeGradient(gradient: number): IParticleSystem;
  66455. /**
  66456. * Not supported by GPUParticleSystem
  66457. * @param gradient defines the gradient to use (between 0 and 1)
  66458. * @param min defines the color remap minimal range
  66459. * @param max defines the color remap maximal range
  66460. * @returns the current particle system
  66461. */
  66462. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66463. /**
  66464. * Not supported by GPUParticleSystem
  66465. * @param gradient defines the gradient to remove
  66466. * @returns the current particle system
  66467. */
  66468. removeColorRemapGradient(): IParticleSystem;
  66469. /**
  66470. * Not supported by GPUParticleSystem
  66471. * @param gradient defines the gradient to use (between 0 and 1)
  66472. * @param min defines the alpha remap minimal range
  66473. * @param max defines the alpha remap maximal range
  66474. * @returns the current particle system
  66475. */
  66476. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66477. /**
  66478. * Not supported by GPUParticleSystem
  66479. * @param gradient defines the gradient to remove
  66480. * @returns the current particle system
  66481. */
  66482. removeAlphaRemapGradient(): IParticleSystem;
  66483. /**
  66484. * Not supported by GPUParticleSystem
  66485. * @param gradient defines the gradient to use (between 0 and 1)
  66486. * @param color defines the color to affect to the specified gradient
  66487. * @returns the current particle system
  66488. */
  66489. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  66490. /**
  66491. * Not supported by GPUParticleSystem
  66492. * @param gradient defines the gradient to remove
  66493. * @returns the current particle system
  66494. */
  66495. removeRampGradient(): IParticleSystem;
  66496. /**
  66497. * Not supported by GPUParticleSystem
  66498. * @returns the list of ramp gradients
  66499. */
  66500. getRampGradients(): Nullable<Array<Color3Gradient>>;
  66501. /**
  66502. * Not supported by GPUParticleSystem
  66503. * Gets or sets a boolean indicating that ramp gradients must be used
  66504. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  66505. */
  66506. get useRampGradients(): boolean;
  66507. set useRampGradients(value: boolean);
  66508. /**
  66509. * Not supported by GPUParticleSystem
  66510. * @param gradient defines the gradient to use (between 0 and 1)
  66511. * @param factor defines the life time factor to affect to the specified gradient
  66512. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66513. * @returns the current particle system
  66514. */
  66515. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66516. /**
  66517. * Not supported by GPUParticleSystem
  66518. * @param gradient defines the gradient to remove
  66519. * @returns the current particle system
  66520. */
  66521. removeLifeTimeGradient(gradient: number): IParticleSystem;
  66522. /**
  66523. * Instantiates a GPU particle system.
  66524. * 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.
  66525. * @param name The name of the particle system
  66526. * @param options The options used to create the system
  66527. * @param scene The scene the particle system belongs to
  66528. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  66529. * @param customEffect a custom effect used to change the way particles are rendered by default
  66530. */
  66531. constructor(name: string, options: Partial<{
  66532. capacity: number;
  66533. randomTextureSize: number;
  66534. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  66535. protected _reset(): void;
  66536. private _createUpdateVAO;
  66537. private _createRenderVAO;
  66538. private _initialize;
  66539. /** @hidden */
  66540. _recreateUpdateEffect(): void;
  66541. private _getEffect;
  66542. /**
  66543. * Fill the defines array according to the current settings of the particle system
  66544. * @param defines Array to be updated
  66545. * @param blendMode blend mode to take into account when updating the array
  66546. */
  66547. fillDefines(defines: Array<string>, blendMode?: number): void;
  66548. /**
  66549. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  66550. * @param uniforms Uniforms array to fill
  66551. * @param attributes Attributes array to fill
  66552. * @param samplers Samplers array to fill
  66553. */
  66554. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  66555. /** @hidden */
  66556. _recreateRenderEffect(): Effect;
  66557. /**
  66558. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  66559. * @param preWarm defines if we are in the pre-warmimg phase
  66560. */
  66561. animate(preWarm?: boolean): void;
  66562. private _createFactorGradientTexture;
  66563. private _createSizeGradientTexture;
  66564. private _createAngularSpeedGradientTexture;
  66565. private _createVelocityGradientTexture;
  66566. private _createLimitVelocityGradientTexture;
  66567. private _createDragGradientTexture;
  66568. private _createColorGradientTexture;
  66569. /**
  66570. * Renders the particle system in its current state
  66571. * @param preWarm defines if the system should only update the particles but not render them
  66572. * @returns the current number of particles
  66573. */
  66574. render(preWarm?: boolean): number;
  66575. /**
  66576. * Rebuilds the particle system
  66577. */
  66578. rebuild(): void;
  66579. private _releaseBuffers;
  66580. private _releaseVAOs;
  66581. /**
  66582. * Disposes the particle system and free the associated resources
  66583. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  66584. */
  66585. dispose(disposeTexture?: boolean): void;
  66586. /**
  66587. * Clones the particle system.
  66588. * @param name The name of the cloned object
  66589. * @param newEmitter The new emitter to use
  66590. * @returns the cloned particle system
  66591. */
  66592. clone(name: string, newEmitter: any): GPUParticleSystem;
  66593. /**
  66594. * Serializes the particle system to a JSON object
  66595. * @param serializeTexture defines if the texture must be serialized as well
  66596. * @returns the JSON object
  66597. */
  66598. serialize(serializeTexture?: boolean): any;
  66599. /**
  66600. * Parses a JSON object to create a GPU particle system.
  66601. * @param parsedParticleSystem The JSON object to parse
  66602. * @param scene The scene to create the particle system in
  66603. * @param rootUrl The root url to use to load external dependencies like texture
  66604. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  66605. * @returns the parsed GPU particle system
  66606. */
  66607. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  66608. }
  66609. }
  66610. declare module BABYLON {
  66611. /**
  66612. * Represents a set of particle systems working together to create a specific effect
  66613. */
  66614. export class ParticleSystemSet implements IDisposable {
  66615. /**
  66616. * Gets or sets base Assets URL
  66617. */
  66618. static BaseAssetsUrl: string;
  66619. private _emitterCreationOptions;
  66620. private _emitterNode;
  66621. /**
  66622. * Gets the particle system list
  66623. */
  66624. systems: IParticleSystem[];
  66625. /**
  66626. * Gets the emitter node used with this set
  66627. */
  66628. get emitterNode(): Nullable<TransformNode>;
  66629. /**
  66630. * Creates a new emitter mesh as a sphere
  66631. * @param options defines the options used to create the sphere
  66632. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  66633. * @param scene defines the hosting scene
  66634. */
  66635. setEmitterAsSphere(options: {
  66636. diameter: number;
  66637. segments: number;
  66638. color: Color3;
  66639. }, renderingGroupId: number, scene: Scene): void;
  66640. /**
  66641. * Starts all particle systems of the set
  66642. * @param emitter defines an optional mesh to use as emitter for the particle systems
  66643. */
  66644. start(emitter?: AbstractMesh): void;
  66645. /**
  66646. * Release all associated resources
  66647. */
  66648. dispose(): void;
  66649. /**
  66650. * Serialize the set into a JSON compatible object
  66651. * @param serializeTexture defines if the texture must be serialized as well
  66652. * @returns a JSON compatible representation of the set
  66653. */
  66654. serialize(serializeTexture?: boolean): any;
  66655. /**
  66656. * Parse a new ParticleSystemSet from a serialized source
  66657. * @param data defines a JSON compatible representation of the set
  66658. * @param scene defines the hosting scene
  66659. * @param gpu defines if we want GPU particles or CPU particles
  66660. * @returns a new ParticleSystemSet
  66661. */
  66662. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66663. }
  66664. }
  66665. declare module BABYLON {
  66666. /**
  66667. * This class is made for on one-liner static method to help creating particle system set.
  66668. */
  66669. export class ParticleHelper {
  66670. /**
  66671. * Gets or sets base Assets URL
  66672. */
  66673. static BaseAssetsUrl: string;
  66674. /** Define the Url to load snippets */
  66675. static SnippetUrl: string;
  66676. /**
  66677. * Create a default particle system that you can tweak
  66678. * @param emitter defines the emitter to use
  66679. * @param capacity defines the system capacity (default is 500 particles)
  66680. * @param scene defines the hosting scene
  66681. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66682. * @returns the new Particle system
  66683. */
  66684. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66685. /**
  66686. * This is the main static method (one-liner) of this helper to create different particle systems
  66687. * @param type This string represents the type to the particle system to create
  66688. * @param scene The scene where the particle system should live
  66689. * @param gpu If the system will use gpu
  66690. * @returns the ParticleSystemSet created
  66691. */
  66692. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66693. /**
  66694. * Static function used to export a particle system to a ParticleSystemSet variable.
  66695. * Please note that the emitter shape is not exported
  66696. * @param systems defines the particle systems to export
  66697. * @returns the created particle system set
  66698. */
  66699. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66700. /**
  66701. * Creates a particle system from a snippet saved in a remote file
  66702. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  66703. * @param url defines the url to load from
  66704. * @param scene defines the hosting scene
  66705. * @param gpu If the system will use gpu
  66706. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66707. * @returns a promise that will resolve to the new particle system
  66708. */
  66709. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66710. /**
  66711. * Creates a particle system from a snippet saved by the particle system editor
  66712. * @param snippetId defines the snippet to load
  66713. * @param scene defines the hosting scene
  66714. * @param gpu If the system will use gpu
  66715. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66716. * @returns a promise that will resolve to the new particle system
  66717. */
  66718. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66719. }
  66720. }
  66721. declare module BABYLON {
  66722. interface Engine {
  66723. /**
  66724. * Create an effect to use with particle systems.
  66725. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  66726. * the particle system for which you want to create a custom effect in the last parameter
  66727. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66728. * @param uniformsNames defines a list of attribute names
  66729. * @param samplers defines an array of string used to represent textures
  66730. * @param defines defines the string containing the defines to use to compile the shaders
  66731. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66732. * @param onCompiled defines a function to call when the effect creation is successful
  66733. * @param onError defines a function to call when the effect creation has failed
  66734. * @param particleSystem the particle system you want to create the effect for
  66735. * @returns the new Effect
  66736. */
  66737. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  66738. }
  66739. interface Mesh {
  66740. /**
  66741. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66742. * @returns an array of IParticleSystem
  66743. */
  66744. getEmittedParticleSystems(): IParticleSystem[];
  66745. /**
  66746. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66747. * @returns an array of IParticleSystem
  66748. */
  66749. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66750. }
  66751. }
  66752. declare module BABYLON {
  66753. /** Defines the 4 color options */
  66754. export enum PointColor {
  66755. /** color value */
  66756. Color = 2,
  66757. /** uv value */
  66758. UV = 1,
  66759. /** random value */
  66760. Random = 0,
  66761. /** stated value */
  66762. Stated = 3
  66763. }
  66764. /**
  66765. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66766. * 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.
  66767. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66768. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66769. *
  66770. * Full documentation here : TO BE ENTERED
  66771. */
  66772. export class PointsCloudSystem implements IDisposable {
  66773. /**
  66774. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66775. * Example : var p = SPS.particles[i];
  66776. */
  66777. particles: CloudPoint[];
  66778. /**
  66779. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66780. */
  66781. nbParticles: number;
  66782. /**
  66783. * This a counter for your own usage. It's not set by any SPS functions.
  66784. */
  66785. counter: number;
  66786. /**
  66787. * The PCS name. This name is also given to the underlying mesh.
  66788. */
  66789. name: string;
  66790. /**
  66791. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66792. */
  66793. mesh: Mesh;
  66794. /**
  66795. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66796. * Please read :
  66797. */
  66798. vars: any;
  66799. /**
  66800. * @hidden
  66801. */
  66802. _size: number;
  66803. private _scene;
  66804. private _promises;
  66805. private _positions;
  66806. private _indices;
  66807. private _normals;
  66808. private _colors;
  66809. private _uvs;
  66810. private _indices32;
  66811. private _positions32;
  66812. private _colors32;
  66813. private _uvs32;
  66814. private _updatable;
  66815. private _isVisibilityBoxLocked;
  66816. private _alwaysVisible;
  66817. private _groups;
  66818. private _groupCounter;
  66819. private _computeParticleColor;
  66820. private _computeParticleTexture;
  66821. private _computeParticleRotation;
  66822. private _computeBoundingBox;
  66823. private _isReady;
  66824. /**
  66825. * Creates a PCS (Points Cloud System) object
  66826. * @param name (String) is the PCS name, this will be the underlying mesh name
  66827. * @param pointSize (number) is the size for each point
  66828. * @param scene (Scene) is the scene in which the PCS is added
  66829. * @param options defines the options of the PCS e.g.
  66830. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66831. */
  66832. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66833. updatable?: boolean;
  66834. });
  66835. /**
  66836. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66837. * If no points were added to the PCS, the returned mesh is just a single point.
  66838. * @returns a promise for the created mesh
  66839. */
  66840. buildMeshAsync(): Promise<Mesh>;
  66841. /**
  66842. * @hidden
  66843. */
  66844. private _buildMesh;
  66845. private _addParticle;
  66846. private _randomUnitVector;
  66847. private _getColorIndicesForCoord;
  66848. private _setPointsColorOrUV;
  66849. private _colorFromTexture;
  66850. private _calculateDensity;
  66851. /**
  66852. * Adds points to the PCS in random positions within a unit sphere
  66853. * @param nb (positive integer) the number of particles to be created from this model
  66854. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66855. * @returns the number of groups in the system
  66856. */
  66857. addPoints(nb: number, pointFunction?: any): number;
  66858. /**
  66859. * Adds points to the PCS from the surface of the model shape
  66860. * @param mesh is any Mesh object that will be used as a surface model for the points
  66861. * @param nb (positive integer) the number of particles to be created from this model
  66862. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66863. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66864. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66865. * @returns the number of groups in the system
  66866. */
  66867. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66868. /**
  66869. * Adds points to the PCS inside the model shape
  66870. * @param mesh is any Mesh object that will be used as a surface model for the points
  66871. * @param nb (positive integer) the number of particles to be created from this model
  66872. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66873. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66874. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66875. * @returns the number of groups in the system
  66876. */
  66877. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66878. /**
  66879. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  66880. * This method calls `updateParticle()` for each particle of the SPS.
  66881. * For an animated SPS, it is usually called within the render loop.
  66882. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  66883. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  66884. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  66885. * @returns the PCS.
  66886. */
  66887. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  66888. /**
  66889. * Disposes the PCS.
  66890. */
  66891. dispose(): void;
  66892. /**
  66893. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  66894. * doc :
  66895. * @returns the PCS.
  66896. */
  66897. refreshVisibleSize(): PointsCloudSystem;
  66898. /**
  66899. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  66900. * @param size the size (float) of the visibility box
  66901. * note : this doesn't lock the PCS mesh bounding box.
  66902. * doc :
  66903. */
  66904. setVisibilityBox(size: number): void;
  66905. /**
  66906. * Gets whether the PCS is always visible or not
  66907. * doc :
  66908. */
  66909. get isAlwaysVisible(): boolean;
  66910. /**
  66911. * Sets the PCS as always visible or not
  66912. * doc :
  66913. */
  66914. set isAlwaysVisible(val: boolean);
  66915. /**
  66916. * Tells to `setParticles()` to compute the particle rotations or not
  66917. * Default value : false. The PCS is faster when it's set to false
  66918. * Note : particle rotations are only applied to parent particles
  66919. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  66920. */
  66921. set computeParticleRotation(val: boolean);
  66922. /**
  66923. * Tells to `setParticles()` to compute the particle colors or not.
  66924. * Default value : true. The PCS is faster when it's set to false.
  66925. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66926. */
  66927. set computeParticleColor(val: boolean);
  66928. set computeParticleTexture(val: boolean);
  66929. /**
  66930. * Gets if `setParticles()` computes the particle colors or not.
  66931. * Default value : false. The PCS is faster when it's set to false.
  66932. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66933. */
  66934. get computeParticleColor(): boolean;
  66935. /**
  66936. * Gets if `setParticles()` computes the particle textures or not.
  66937. * Default value : false. The PCS is faster when it's set to false.
  66938. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  66939. */
  66940. get computeParticleTexture(): boolean;
  66941. /**
  66942. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  66943. */
  66944. set computeBoundingBox(val: boolean);
  66945. /**
  66946. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  66947. */
  66948. get computeBoundingBox(): boolean;
  66949. /**
  66950. * This function does nothing. It may be overwritten to set all the particle first values.
  66951. * The PCS doesn't call this function, you may have to call it by your own.
  66952. * doc :
  66953. */
  66954. initParticles(): void;
  66955. /**
  66956. * This function does nothing. It may be overwritten to recycle a particle
  66957. * The PCS doesn't call this function, you can to call it
  66958. * doc :
  66959. * @param particle The particle to recycle
  66960. * @returns the recycled particle
  66961. */
  66962. recycleParticle(particle: CloudPoint): CloudPoint;
  66963. /**
  66964. * Updates a particle : this function should be overwritten by the user.
  66965. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  66966. * doc :
  66967. * @example : just set a particle position or velocity and recycle conditions
  66968. * @param particle The particle to update
  66969. * @returns the updated particle
  66970. */
  66971. updateParticle(particle: CloudPoint): CloudPoint;
  66972. /**
  66973. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  66974. * This does nothing and may be overwritten by the user.
  66975. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66976. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66977. * @param update the boolean update value actually passed to setParticles()
  66978. */
  66979. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66980. /**
  66981. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  66982. * This will be passed three parameters.
  66983. * This does nothing and may be overwritten by the user.
  66984. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66985. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66986. * @param update the boolean update value actually passed to setParticles()
  66987. */
  66988. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66989. }
  66990. }
  66991. declare module BABYLON {
  66992. /**
  66993. * Represents one particle of a points cloud system.
  66994. */
  66995. export class CloudPoint {
  66996. /**
  66997. * particle global index
  66998. */
  66999. idx: number;
  67000. /**
  67001. * The color of the particle
  67002. */
  67003. color: Nullable<Color4>;
  67004. /**
  67005. * The world space position of the particle.
  67006. */
  67007. position: Vector3;
  67008. /**
  67009. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  67010. */
  67011. rotation: Vector3;
  67012. /**
  67013. * The world space rotation quaternion of the particle.
  67014. */
  67015. rotationQuaternion: Nullable<Quaternion>;
  67016. /**
  67017. * The uv of the particle.
  67018. */
  67019. uv: Nullable<Vector2>;
  67020. /**
  67021. * The current speed of the particle.
  67022. */
  67023. velocity: Vector3;
  67024. /**
  67025. * The pivot point in the particle local space.
  67026. */
  67027. pivot: Vector3;
  67028. /**
  67029. * Must the particle be translated from its pivot point in its local space ?
  67030. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  67031. * Default : false
  67032. */
  67033. translateFromPivot: boolean;
  67034. /**
  67035. * Index of this particle in the global "positions" array (Internal use)
  67036. * @hidden
  67037. */
  67038. _pos: number;
  67039. /**
  67040. * @hidden Index of this particle in the global "indices" array (Internal use)
  67041. */
  67042. _ind: number;
  67043. /**
  67044. * Group this particle belongs to
  67045. */
  67046. _group: PointsGroup;
  67047. /**
  67048. * Group id of this particle
  67049. */
  67050. groupId: number;
  67051. /**
  67052. * Index of the particle in its group id (Internal use)
  67053. */
  67054. idxInGroup: number;
  67055. /**
  67056. * @hidden Particle BoundingInfo object (Internal use)
  67057. */
  67058. _boundingInfo: BoundingInfo;
  67059. /**
  67060. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  67061. */
  67062. _pcs: PointsCloudSystem;
  67063. /**
  67064. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  67065. */
  67066. _stillInvisible: boolean;
  67067. /**
  67068. * @hidden Last computed particle rotation matrix
  67069. */
  67070. _rotationMatrix: number[];
  67071. /**
  67072. * Parent particle Id, if any.
  67073. * Default null.
  67074. */
  67075. parentId: Nullable<number>;
  67076. /**
  67077. * @hidden Internal global position in the PCS.
  67078. */
  67079. _globalPosition: Vector3;
  67080. /**
  67081. * Creates a Point Cloud object.
  67082. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  67083. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  67084. * @param group (PointsGroup) is the group the particle belongs to
  67085. * @param groupId (integer) is the group identifier in the PCS.
  67086. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  67087. * @param pcs defines the PCS it is associated to
  67088. */
  67089. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  67090. /**
  67091. * get point size
  67092. */
  67093. get size(): Vector3;
  67094. /**
  67095. * Set point size
  67096. */
  67097. set size(scale: Vector3);
  67098. /**
  67099. * Legacy support, changed quaternion to rotationQuaternion
  67100. */
  67101. get quaternion(): Nullable<Quaternion>;
  67102. /**
  67103. * Legacy support, changed quaternion to rotationQuaternion
  67104. */
  67105. set quaternion(q: Nullable<Quaternion>);
  67106. /**
  67107. * Returns a boolean. True if the particle intersects a mesh, else false
  67108. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  67109. * @param target is the object (point or mesh) what the intersection is computed against
  67110. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  67111. * @returns true if it intersects
  67112. */
  67113. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  67114. /**
  67115. * get the rotation matrix of the particle
  67116. * @hidden
  67117. */
  67118. getRotationMatrix(m: Matrix): void;
  67119. }
  67120. /**
  67121. * Represents a group of points in a points cloud system
  67122. * * PCS internal tool, don't use it manually.
  67123. */
  67124. export class PointsGroup {
  67125. /**
  67126. * The group id
  67127. * @hidden
  67128. */
  67129. groupID: number;
  67130. /**
  67131. * image data for group (internal use)
  67132. * @hidden
  67133. */
  67134. _groupImageData: Nullable<ArrayBufferView>;
  67135. /**
  67136. * Image Width (internal use)
  67137. * @hidden
  67138. */
  67139. _groupImgWidth: number;
  67140. /**
  67141. * Image Height (internal use)
  67142. * @hidden
  67143. */
  67144. _groupImgHeight: number;
  67145. /**
  67146. * Custom position function (internal use)
  67147. * @hidden
  67148. */
  67149. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  67150. /**
  67151. * density per facet for surface points
  67152. * @hidden
  67153. */
  67154. _groupDensity: number[];
  67155. /**
  67156. * Only when points are colored by texture carries pointer to texture list array
  67157. * @hidden
  67158. */
  67159. _textureNb: number;
  67160. /**
  67161. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  67162. * PCS internal tool, don't use it manually.
  67163. * @hidden
  67164. */
  67165. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  67166. }
  67167. }
  67168. declare module BABYLON {
  67169. interface Scene {
  67170. /** @hidden (Backing field) */
  67171. _physicsEngine: Nullable<IPhysicsEngine>;
  67172. /** @hidden */
  67173. _physicsTimeAccumulator: number;
  67174. /**
  67175. * Gets the current physics engine
  67176. * @returns a IPhysicsEngine or null if none attached
  67177. */
  67178. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  67179. /**
  67180. * Enables physics to the current scene
  67181. * @param gravity defines the scene's gravity for the physics engine
  67182. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  67183. * @return a boolean indicating if the physics engine was initialized
  67184. */
  67185. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  67186. /**
  67187. * Disables and disposes the physics engine associated with the scene
  67188. */
  67189. disablePhysicsEngine(): void;
  67190. /**
  67191. * Gets a boolean indicating if there is an active physics engine
  67192. * @returns a boolean indicating if there is an active physics engine
  67193. */
  67194. isPhysicsEnabled(): boolean;
  67195. /**
  67196. * Deletes a physics compound impostor
  67197. * @param compound defines the compound to delete
  67198. */
  67199. deleteCompoundImpostor(compound: any): void;
  67200. /**
  67201. * An event triggered when physic simulation is about to be run
  67202. */
  67203. onBeforePhysicsObservable: Observable<Scene>;
  67204. /**
  67205. * An event triggered when physic simulation has been done
  67206. */
  67207. onAfterPhysicsObservable: Observable<Scene>;
  67208. }
  67209. interface AbstractMesh {
  67210. /** @hidden */
  67211. _physicsImpostor: Nullable<PhysicsImpostor>;
  67212. /**
  67213. * Gets or sets impostor used for physic simulation
  67214. * @see http://doc.babylonjs.com/features/physics_engine
  67215. */
  67216. physicsImpostor: Nullable<PhysicsImpostor>;
  67217. /**
  67218. * Gets the current physics impostor
  67219. * @see http://doc.babylonjs.com/features/physics_engine
  67220. * @returns a physics impostor or null
  67221. */
  67222. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  67223. /** Apply a physic impulse to the mesh
  67224. * @param force defines the force to apply
  67225. * @param contactPoint defines where to apply the force
  67226. * @returns the current mesh
  67227. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  67228. */
  67229. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  67230. /**
  67231. * Creates a physic joint between two meshes
  67232. * @param otherMesh defines the other mesh to use
  67233. * @param pivot1 defines the pivot to use on this mesh
  67234. * @param pivot2 defines the pivot to use on the other mesh
  67235. * @param options defines additional options (can be plugin dependent)
  67236. * @returns the current mesh
  67237. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  67238. */
  67239. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  67240. /** @hidden */
  67241. _disposePhysicsObserver: Nullable<Observer<Node>>;
  67242. }
  67243. /**
  67244. * Defines the physics engine scene component responsible to manage a physics engine
  67245. */
  67246. export class PhysicsEngineSceneComponent implements ISceneComponent {
  67247. /**
  67248. * The component name helpful to identify the component in the list of scene components.
  67249. */
  67250. readonly name: string;
  67251. /**
  67252. * The scene the component belongs to.
  67253. */
  67254. scene: Scene;
  67255. /**
  67256. * Creates a new instance of the component for the given scene
  67257. * @param scene Defines the scene to register the component in
  67258. */
  67259. constructor(scene: Scene);
  67260. /**
  67261. * Registers the component in a given scene
  67262. */
  67263. register(): void;
  67264. /**
  67265. * Rebuilds the elements related to this component in case of
  67266. * context lost for instance.
  67267. */
  67268. rebuild(): void;
  67269. /**
  67270. * Disposes the component and the associated ressources
  67271. */
  67272. dispose(): void;
  67273. }
  67274. }
  67275. declare module BABYLON {
  67276. /**
  67277. * A helper for physics simulations
  67278. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67279. */
  67280. export class PhysicsHelper {
  67281. private _scene;
  67282. private _physicsEngine;
  67283. /**
  67284. * Initializes the Physics helper
  67285. * @param scene Babylon.js scene
  67286. */
  67287. constructor(scene: Scene);
  67288. /**
  67289. * Applies a radial explosion impulse
  67290. * @param origin the origin of the explosion
  67291. * @param radiusOrEventOptions the radius or the options of radial explosion
  67292. * @param strength the explosion strength
  67293. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67294. * @returns A physics radial explosion event, or null
  67295. */
  67296. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67297. /**
  67298. * Applies a radial explosion force
  67299. * @param origin the origin of the explosion
  67300. * @param radiusOrEventOptions the radius or the options of radial explosion
  67301. * @param strength the explosion strength
  67302. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67303. * @returns A physics radial explosion event, or null
  67304. */
  67305. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67306. /**
  67307. * Creates a gravitational field
  67308. * @param origin the origin of the explosion
  67309. * @param radiusOrEventOptions the radius or the options of radial explosion
  67310. * @param strength the explosion strength
  67311. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67312. * @returns A physics gravitational field event, or null
  67313. */
  67314. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  67315. /**
  67316. * Creates a physics updraft event
  67317. * @param origin the origin of the updraft
  67318. * @param radiusOrEventOptions the radius or the options of the updraft
  67319. * @param strength the strength of the updraft
  67320. * @param height the height of the updraft
  67321. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  67322. * @returns A physics updraft event, or null
  67323. */
  67324. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  67325. /**
  67326. * Creates a physics vortex event
  67327. * @param origin the of the vortex
  67328. * @param radiusOrEventOptions the radius or the options of the vortex
  67329. * @param strength the strength of the vortex
  67330. * @param height the height of the vortex
  67331. * @returns a Physics vortex event, or null
  67332. * A physics vortex event or null
  67333. */
  67334. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  67335. }
  67336. /**
  67337. * Represents a physics radial explosion event
  67338. */
  67339. class PhysicsRadialExplosionEvent {
  67340. private _scene;
  67341. private _options;
  67342. private _sphere;
  67343. private _dataFetched;
  67344. /**
  67345. * Initializes a radial explosioin event
  67346. * @param _scene BabylonJS scene
  67347. * @param _options The options for the vortex event
  67348. */
  67349. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  67350. /**
  67351. * Returns the data related to the radial explosion event (sphere).
  67352. * @returns The radial explosion event data
  67353. */
  67354. getData(): PhysicsRadialExplosionEventData;
  67355. /**
  67356. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  67357. * @param impostor A physics imposter
  67358. * @param origin the origin of the explosion
  67359. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  67360. */
  67361. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  67362. /**
  67363. * Triggers affecterd impostors callbacks
  67364. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  67365. */
  67366. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  67367. /**
  67368. * Disposes the sphere.
  67369. * @param force Specifies if the sphere should be disposed by force
  67370. */
  67371. dispose(force?: boolean): void;
  67372. /*** Helpers ***/
  67373. private _prepareSphere;
  67374. private _intersectsWithSphere;
  67375. }
  67376. /**
  67377. * Represents a gravitational field event
  67378. */
  67379. class PhysicsGravitationalFieldEvent {
  67380. private _physicsHelper;
  67381. private _scene;
  67382. private _origin;
  67383. private _options;
  67384. private _tickCallback;
  67385. private _sphere;
  67386. private _dataFetched;
  67387. /**
  67388. * Initializes the physics gravitational field event
  67389. * @param _physicsHelper A physics helper
  67390. * @param _scene BabylonJS scene
  67391. * @param _origin The origin position of the gravitational field event
  67392. * @param _options The options for the vortex event
  67393. */
  67394. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  67395. /**
  67396. * Returns the data related to the gravitational field event (sphere).
  67397. * @returns A gravitational field event
  67398. */
  67399. getData(): PhysicsGravitationalFieldEventData;
  67400. /**
  67401. * Enables the gravitational field.
  67402. */
  67403. enable(): void;
  67404. /**
  67405. * Disables the gravitational field.
  67406. */
  67407. disable(): void;
  67408. /**
  67409. * Disposes the sphere.
  67410. * @param force The force to dispose from the gravitational field event
  67411. */
  67412. dispose(force?: boolean): void;
  67413. private _tick;
  67414. }
  67415. /**
  67416. * Represents a physics updraft event
  67417. */
  67418. class PhysicsUpdraftEvent {
  67419. private _scene;
  67420. private _origin;
  67421. private _options;
  67422. private _physicsEngine;
  67423. private _originTop;
  67424. private _originDirection;
  67425. private _tickCallback;
  67426. private _cylinder;
  67427. private _cylinderPosition;
  67428. private _dataFetched;
  67429. /**
  67430. * Initializes the physics updraft event
  67431. * @param _scene BabylonJS scene
  67432. * @param _origin The origin position of the updraft
  67433. * @param _options The options for the updraft event
  67434. */
  67435. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  67436. /**
  67437. * Returns the data related to the updraft event (cylinder).
  67438. * @returns A physics updraft event
  67439. */
  67440. getData(): PhysicsUpdraftEventData;
  67441. /**
  67442. * Enables the updraft.
  67443. */
  67444. enable(): void;
  67445. /**
  67446. * Disables the updraft.
  67447. */
  67448. disable(): void;
  67449. /**
  67450. * Disposes the cylinder.
  67451. * @param force Specifies if the updraft should be disposed by force
  67452. */
  67453. dispose(force?: boolean): void;
  67454. private getImpostorHitData;
  67455. private _tick;
  67456. /*** Helpers ***/
  67457. private _prepareCylinder;
  67458. private _intersectsWithCylinder;
  67459. }
  67460. /**
  67461. * Represents a physics vortex event
  67462. */
  67463. class PhysicsVortexEvent {
  67464. private _scene;
  67465. private _origin;
  67466. private _options;
  67467. private _physicsEngine;
  67468. private _originTop;
  67469. private _tickCallback;
  67470. private _cylinder;
  67471. private _cylinderPosition;
  67472. private _dataFetched;
  67473. /**
  67474. * Initializes the physics vortex event
  67475. * @param _scene The BabylonJS scene
  67476. * @param _origin The origin position of the vortex
  67477. * @param _options The options for the vortex event
  67478. */
  67479. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  67480. /**
  67481. * Returns the data related to the vortex event (cylinder).
  67482. * @returns The physics vortex event data
  67483. */
  67484. getData(): PhysicsVortexEventData;
  67485. /**
  67486. * Enables the vortex.
  67487. */
  67488. enable(): void;
  67489. /**
  67490. * Disables the cortex.
  67491. */
  67492. disable(): void;
  67493. /**
  67494. * Disposes the sphere.
  67495. * @param force
  67496. */
  67497. dispose(force?: boolean): void;
  67498. private getImpostorHitData;
  67499. private _tick;
  67500. /*** Helpers ***/
  67501. private _prepareCylinder;
  67502. private _intersectsWithCylinder;
  67503. }
  67504. /**
  67505. * Options fot the radial explosion event
  67506. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67507. */
  67508. export class PhysicsRadialExplosionEventOptions {
  67509. /**
  67510. * The radius of the sphere for the radial explosion.
  67511. */
  67512. radius: number;
  67513. /**
  67514. * The strenth of the explosion.
  67515. */
  67516. strength: number;
  67517. /**
  67518. * The strenght of the force in correspondence to the distance of the affected object
  67519. */
  67520. falloff: PhysicsRadialImpulseFalloff;
  67521. /**
  67522. * Sphere options for the radial explosion.
  67523. */
  67524. sphere: {
  67525. segments: number;
  67526. diameter: number;
  67527. };
  67528. /**
  67529. * Sphere options for the radial explosion.
  67530. */
  67531. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  67532. }
  67533. /**
  67534. * Options fot the updraft event
  67535. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67536. */
  67537. export class PhysicsUpdraftEventOptions {
  67538. /**
  67539. * The radius of the cylinder for the vortex
  67540. */
  67541. radius: number;
  67542. /**
  67543. * The strenth of the updraft.
  67544. */
  67545. strength: number;
  67546. /**
  67547. * The height of the cylinder for the updraft.
  67548. */
  67549. height: number;
  67550. /**
  67551. * The mode for the the updraft.
  67552. */
  67553. updraftMode: PhysicsUpdraftMode;
  67554. }
  67555. /**
  67556. * Options fot the vortex event
  67557. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67558. */
  67559. export class PhysicsVortexEventOptions {
  67560. /**
  67561. * The radius of the cylinder for the vortex
  67562. */
  67563. radius: number;
  67564. /**
  67565. * The strenth of the vortex.
  67566. */
  67567. strength: number;
  67568. /**
  67569. * The height of the cylinder for the vortex.
  67570. */
  67571. height: number;
  67572. /**
  67573. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  67574. */
  67575. centripetalForceThreshold: number;
  67576. /**
  67577. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  67578. */
  67579. centripetalForceMultiplier: number;
  67580. /**
  67581. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  67582. */
  67583. centrifugalForceMultiplier: number;
  67584. /**
  67585. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  67586. */
  67587. updraftForceMultiplier: number;
  67588. }
  67589. /**
  67590. * The strenght of the force in correspondence to the distance of the affected object
  67591. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67592. */
  67593. export enum PhysicsRadialImpulseFalloff {
  67594. /** Defines that impulse is constant in strength across it's whole radius */
  67595. Constant = 0,
  67596. /** Defines that impulse gets weaker if it's further from the origin */
  67597. Linear = 1
  67598. }
  67599. /**
  67600. * The strength of the force in correspondence to the distance of the affected object
  67601. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67602. */
  67603. export enum PhysicsUpdraftMode {
  67604. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  67605. Center = 0,
  67606. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  67607. Perpendicular = 1
  67608. }
  67609. /**
  67610. * Interface for a physics hit data
  67611. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67612. */
  67613. export interface PhysicsHitData {
  67614. /**
  67615. * The force applied at the contact point
  67616. */
  67617. force: Vector3;
  67618. /**
  67619. * The contact point
  67620. */
  67621. contactPoint: Vector3;
  67622. /**
  67623. * The distance from the origin to the contact point
  67624. */
  67625. distanceFromOrigin: number;
  67626. }
  67627. /**
  67628. * Interface for radial explosion event data
  67629. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67630. */
  67631. export interface PhysicsRadialExplosionEventData {
  67632. /**
  67633. * A sphere used for the radial explosion event
  67634. */
  67635. sphere: Mesh;
  67636. }
  67637. /**
  67638. * Interface for gravitational field event data
  67639. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67640. */
  67641. export interface PhysicsGravitationalFieldEventData {
  67642. /**
  67643. * A sphere mesh used for the gravitational field event
  67644. */
  67645. sphere: Mesh;
  67646. }
  67647. /**
  67648. * Interface for updraft event data
  67649. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67650. */
  67651. export interface PhysicsUpdraftEventData {
  67652. /**
  67653. * A cylinder used for the updraft event
  67654. */
  67655. cylinder: Mesh;
  67656. }
  67657. /**
  67658. * Interface for vortex event data
  67659. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67660. */
  67661. export interface PhysicsVortexEventData {
  67662. /**
  67663. * A cylinder used for the vortex event
  67664. */
  67665. cylinder: Mesh;
  67666. }
  67667. /**
  67668. * Interface for an affected physics impostor
  67669. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67670. */
  67671. export interface PhysicsAffectedImpostorWithData {
  67672. /**
  67673. * The impostor affected by the effect
  67674. */
  67675. impostor: PhysicsImpostor;
  67676. /**
  67677. * The data about the hit/horce from the explosion
  67678. */
  67679. hitData: PhysicsHitData;
  67680. }
  67681. }
  67682. declare module BABYLON {
  67683. /** @hidden */
  67684. export var blackAndWhitePixelShader: {
  67685. name: string;
  67686. shader: string;
  67687. };
  67688. }
  67689. declare module BABYLON {
  67690. /**
  67691. * Post process used to render in black and white
  67692. */
  67693. export class BlackAndWhitePostProcess extends PostProcess {
  67694. /**
  67695. * Linear about to convert he result to black and white (default: 1)
  67696. */
  67697. degree: number;
  67698. /**
  67699. * Creates a black and white post process
  67700. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67701. * @param name The name of the effect.
  67702. * @param options The required width/height ratio to downsize to before computing the render pass.
  67703. * @param camera The camera to apply the render pass to.
  67704. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67705. * @param engine The engine which the post process will be applied. (default: current engine)
  67706. * @param reusable If the post process can be reused on the same frame. (default: false)
  67707. */
  67708. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67709. }
  67710. }
  67711. declare module BABYLON {
  67712. /**
  67713. * This represents a set of one or more post processes in Babylon.
  67714. * A post process can be used to apply a shader to a texture after it is rendered.
  67715. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67716. */
  67717. export class PostProcessRenderEffect {
  67718. private _postProcesses;
  67719. private _getPostProcesses;
  67720. private _singleInstance;
  67721. private _cameras;
  67722. private _indicesForCamera;
  67723. /**
  67724. * Name of the effect
  67725. * @hidden
  67726. */
  67727. _name: string;
  67728. /**
  67729. * Instantiates a post process render effect.
  67730. * A post process can be used to apply a shader to a texture after it is rendered.
  67731. * @param engine The engine the effect is tied to
  67732. * @param name The name of the effect
  67733. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67734. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67735. */
  67736. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67737. /**
  67738. * Checks if all the post processes in the effect are supported.
  67739. */
  67740. get isSupported(): boolean;
  67741. /**
  67742. * Updates the current state of the effect
  67743. * @hidden
  67744. */
  67745. _update(): void;
  67746. /**
  67747. * Attaches the effect on cameras
  67748. * @param cameras The camera to attach to.
  67749. * @hidden
  67750. */
  67751. _attachCameras(cameras: Camera): void;
  67752. /**
  67753. * Attaches the effect on cameras
  67754. * @param cameras The camera to attach to.
  67755. * @hidden
  67756. */
  67757. _attachCameras(cameras: Camera[]): void;
  67758. /**
  67759. * Detaches the effect on cameras
  67760. * @param cameras The camera to detatch from.
  67761. * @hidden
  67762. */
  67763. _detachCameras(cameras: Camera): void;
  67764. /**
  67765. * Detatches the effect on cameras
  67766. * @param cameras The camera to detatch from.
  67767. * @hidden
  67768. */
  67769. _detachCameras(cameras: Camera[]): void;
  67770. /**
  67771. * Enables the effect on given cameras
  67772. * @param cameras The camera to enable.
  67773. * @hidden
  67774. */
  67775. _enable(cameras: Camera): void;
  67776. /**
  67777. * Enables the effect on given cameras
  67778. * @param cameras The camera to enable.
  67779. * @hidden
  67780. */
  67781. _enable(cameras: Nullable<Camera[]>): void;
  67782. /**
  67783. * Disables the effect on the given cameras
  67784. * @param cameras The camera to disable.
  67785. * @hidden
  67786. */
  67787. _disable(cameras: Camera): void;
  67788. /**
  67789. * Disables the effect on the given cameras
  67790. * @param cameras The camera to disable.
  67791. * @hidden
  67792. */
  67793. _disable(cameras: Nullable<Camera[]>): void;
  67794. /**
  67795. * Gets a list of the post processes contained in the effect.
  67796. * @param camera The camera to get the post processes on.
  67797. * @returns The list of the post processes in the effect.
  67798. */
  67799. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67800. }
  67801. }
  67802. declare module BABYLON {
  67803. /** @hidden */
  67804. export var extractHighlightsPixelShader: {
  67805. name: string;
  67806. shader: string;
  67807. };
  67808. }
  67809. declare module BABYLON {
  67810. /**
  67811. * 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.
  67812. */
  67813. export class ExtractHighlightsPostProcess extends PostProcess {
  67814. /**
  67815. * The luminance threshold, pixels below this value will be set to black.
  67816. */
  67817. threshold: number;
  67818. /** @hidden */
  67819. _exposure: number;
  67820. /**
  67821. * Post process which has the input texture to be used when performing highlight extraction
  67822. * @hidden
  67823. */
  67824. _inputPostProcess: Nullable<PostProcess>;
  67825. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67826. }
  67827. }
  67828. declare module BABYLON {
  67829. /** @hidden */
  67830. export var bloomMergePixelShader: {
  67831. name: string;
  67832. shader: string;
  67833. };
  67834. }
  67835. declare module BABYLON {
  67836. /**
  67837. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67838. */
  67839. export class BloomMergePostProcess extends PostProcess {
  67840. /** Weight of the bloom to be added to the original input. */
  67841. weight: number;
  67842. /**
  67843. * Creates a new instance of @see BloomMergePostProcess
  67844. * @param name The name of the effect.
  67845. * @param originalFromInput Post process which's input will be used for the merge.
  67846. * @param blurred Blurred highlights post process which's output will be used.
  67847. * @param weight Weight of the bloom to be added to the original input.
  67848. * @param options The required width/height ratio to downsize to before computing the render pass.
  67849. * @param camera The camera to apply the render pass to.
  67850. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67851. * @param engine The engine which the post process will be applied. (default: current engine)
  67852. * @param reusable If the post process can be reused on the same frame. (default: false)
  67853. * @param textureType Type of textures used when performing the post process. (default: 0)
  67854. * @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)
  67855. */
  67856. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67857. /** Weight of the bloom to be added to the original input. */
  67858. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67859. }
  67860. }
  67861. declare module BABYLON {
  67862. /**
  67863. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67864. */
  67865. export class BloomEffect extends PostProcessRenderEffect {
  67866. private bloomScale;
  67867. /**
  67868. * @hidden Internal
  67869. */
  67870. _effects: Array<PostProcess>;
  67871. /**
  67872. * @hidden Internal
  67873. */
  67874. _downscale: ExtractHighlightsPostProcess;
  67875. private _blurX;
  67876. private _blurY;
  67877. private _merge;
  67878. /**
  67879. * The luminance threshold to find bright areas of the image to bloom.
  67880. */
  67881. get threshold(): number;
  67882. set threshold(value: number);
  67883. /**
  67884. * The strength of the bloom.
  67885. */
  67886. get weight(): number;
  67887. set weight(value: number);
  67888. /**
  67889. * Specifies the size of the bloom blur kernel, relative to the final output size
  67890. */
  67891. get kernel(): number;
  67892. set kernel(value: number);
  67893. /**
  67894. * Creates a new instance of @see BloomEffect
  67895. * @param scene The scene the effect belongs to.
  67896. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  67897. * @param bloomKernel The size of the kernel to be used when applying the blur.
  67898. * @param bloomWeight The the strength of bloom.
  67899. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67900. * @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)
  67901. */
  67902. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  67903. /**
  67904. * Disposes each of the internal effects for a given camera.
  67905. * @param camera The camera to dispose the effect on.
  67906. */
  67907. disposeEffects(camera: Camera): void;
  67908. /**
  67909. * @hidden Internal
  67910. */
  67911. _updateEffects(): void;
  67912. /**
  67913. * Internal
  67914. * @returns if all the contained post processes are ready.
  67915. * @hidden
  67916. */
  67917. _isReady(): boolean;
  67918. }
  67919. }
  67920. declare module BABYLON {
  67921. /** @hidden */
  67922. export var chromaticAberrationPixelShader: {
  67923. name: string;
  67924. shader: string;
  67925. };
  67926. }
  67927. declare module BABYLON {
  67928. /**
  67929. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  67930. */
  67931. export class ChromaticAberrationPostProcess extends PostProcess {
  67932. /**
  67933. * The amount of seperation of rgb channels (default: 30)
  67934. */
  67935. aberrationAmount: number;
  67936. /**
  67937. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  67938. */
  67939. radialIntensity: number;
  67940. /**
  67941. * 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))
  67942. */
  67943. direction: Vector2;
  67944. /**
  67945. * 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))
  67946. */
  67947. centerPosition: Vector2;
  67948. /**
  67949. * Creates a new instance ChromaticAberrationPostProcess
  67950. * @param name The name of the effect.
  67951. * @param screenWidth The width of the screen to apply the effect on.
  67952. * @param screenHeight The height of the screen to apply the effect on.
  67953. * @param options The required width/height ratio to downsize to before computing the render pass.
  67954. * @param camera The camera to apply the render pass to.
  67955. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67956. * @param engine The engine which the post process will be applied. (default: current engine)
  67957. * @param reusable If the post process can be reused on the same frame. (default: false)
  67958. * @param textureType Type of textures used when performing the post process. (default: 0)
  67959. * @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)
  67960. */
  67961. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67962. }
  67963. }
  67964. declare module BABYLON {
  67965. /** @hidden */
  67966. export var circleOfConfusionPixelShader: {
  67967. name: string;
  67968. shader: string;
  67969. };
  67970. }
  67971. declare module BABYLON {
  67972. /**
  67973. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67974. */
  67975. export class CircleOfConfusionPostProcess extends PostProcess {
  67976. /**
  67977. * 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.
  67978. */
  67979. lensSize: number;
  67980. /**
  67981. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67982. */
  67983. fStop: number;
  67984. /**
  67985. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67986. */
  67987. focusDistance: number;
  67988. /**
  67989. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67990. */
  67991. focalLength: number;
  67992. private _depthTexture;
  67993. /**
  67994. * Creates a new instance CircleOfConfusionPostProcess
  67995. * @param name The name of the effect.
  67996. * @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.
  67997. * @param options The required width/height ratio to downsize to before computing the render pass.
  67998. * @param camera The camera to apply the render pass to.
  67999. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68000. * @param engine The engine which the post process will be applied. (default: current engine)
  68001. * @param reusable If the post process can be reused on the same frame. (default: false)
  68002. * @param textureType Type of textures used when performing the post process. (default: 0)
  68003. * @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)
  68004. */
  68005. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68006. /**
  68007. * 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.
  68008. */
  68009. set depthTexture(value: RenderTargetTexture);
  68010. }
  68011. }
  68012. declare module BABYLON {
  68013. /** @hidden */
  68014. export var colorCorrectionPixelShader: {
  68015. name: string;
  68016. shader: string;
  68017. };
  68018. }
  68019. declare module BABYLON {
  68020. /**
  68021. *
  68022. * This post-process allows the modification of rendered colors by using
  68023. * a 'look-up table' (LUT). This effect is also called Color Grading.
  68024. *
  68025. * The object needs to be provided an url to a texture containing the color
  68026. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  68027. * Use an image editing software to tweak the LUT to match your needs.
  68028. *
  68029. * For an example of a color LUT, see here:
  68030. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  68031. * For explanations on color grading, see here:
  68032. * @see http://udn.epicgames.com/Three/ColorGrading.html
  68033. *
  68034. */
  68035. export class ColorCorrectionPostProcess extends PostProcess {
  68036. private _colorTableTexture;
  68037. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68038. }
  68039. }
  68040. declare module BABYLON {
  68041. /** @hidden */
  68042. export var convolutionPixelShader: {
  68043. name: string;
  68044. shader: string;
  68045. };
  68046. }
  68047. declare module BABYLON {
  68048. /**
  68049. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  68050. * input texture to perform effects such as edge detection or sharpening
  68051. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68052. */
  68053. export class ConvolutionPostProcess extends PostProcess {
  68054. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68055. kernel: number[];
  68056. /**
  68057. * Creates a new instance ConvolutionPostProcess
  68058. * @param name The name of the effect.
  68059. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  68060. * @param options The required width/height ratio to downsize to before computing the render pass.
  68061. * @param camera The camera to apply the render pass to.
  68062. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68063. * @param engine The engine which the post process will be applied. (default: current engine)
  68064. * @param reusable If the post process can be reused on the same frame. (default: false)
  68065. * @param textureType Type of textures used when performing the post process. (default: 0)
  68066. */
  68067. constructor(name: string,
  68068. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68069. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68070. /**
  68071. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68072. */
  68073. static EdgeDetect0Kernel: number[];
  68074. /**
  68075. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68076. */
  68077. static EdgeDetect1Kernel: number[];
  68078. /**
  68079. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68080. */
  68081. static EdgeDetect2Kernel: number[];
  68082. /**
  68083. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68084. */
  68085. static SharpenKernel: number[];
  68086. /**
  68087. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68088. */
  68089. static EmbossKernel: number[];
  68090. /**
  68091. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68092. */
  68093. static GaussianKernel: number[];
  68094. }
  68095. }
  68096. declare module BABYLON {
  68097. /**
  68098. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  68099. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  68100. * based on samples that have a large difference in distance than the center pixel.
  68101. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  68102. */
  68103. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  68104. direction: Vector2;
  68105. /**
  68106. * Creates a new instance CircleOfConfusionPostProcess
  68107. * @param name The name of the effect.
  68108. * @param scene The scene the effect belongs to.
  68109. * @param direction The direction the blur should be applied.
  68110. * @param kernel The size of the kernel used to blur.
  68111. * @param options The required width/height ratio to downsize to before computing the render pass.
  68112. * @param camera The camera to apply the render pass to.
  68113. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  68114. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  68115. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68116. * @param engine The engine which the post process will be applied. (default: current engine)
  68117. * @param reusable If the post process can be reused on the same frame. (default: false)
  68118. * @param textureType Type of textures used when performing the post process. (default: 0)
  68119. * @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)
  68120. */
  68121. 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);
  68122. }
  68123. }
  68124. declare module BABYLON {
  68125. /** @hidden */
  68126. export var depthOfFieldMergePixelShader: {
  68127. name: string;
  68128. shader: string;
  68129. };
  68130. }
  68131. declare module BABYLON {
  68132. /**
  68133. * Options to be set when merging outputs from the default pipeline.
  68134. */
  68135. export class DepthOfFieldMergePostProcessOptions {
  68136. /**
  68137. * The original image to merge on top of
  68138. */
  68139. originalFromInput: PostProcess;
  68140. /**
  68141. * Parameters to perform the merge of the depth of field effect
  68142. */
  68143. depthOfField?: {
  68144. circleOfConfusion: PostProcess;
  68145. blurSteps: Array<PostProcess>;
  68146. };
  68147. /**
  68148. * Parameters to perform the merge of bloom effect
  68149. */
  68150. bloom?: {
  68151. blurred: PostProcess;
  68152. weight: number;
  68153. };
  68154. }
  68155. /**
  68156. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68157. */
  68158. export class DepthOfFieldMergePostProcess extends PostProcess {
  68159. private blurSteps;
  68160. /**
  68161. * Creates a new instance of DepthOfFieldMergePostProcess
  68162. * @param name The name of the effect.
  68163. * @param originalFromInput Post process which's input will be used for the merge.
  68164. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  68165. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  68166. * @param options The required width/height ratio to downsize to before computing the render pass.
  68167. * @param camera The camera to apply the render pass to.
  68168. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68169. * @param engine The engine which the post process will be applied. (default: current engine)
  68170. * @param reusable If the post process can be reused on the same frame. (default: false)
  68171. * @param textureType Type of textures used when performing the post process. (default: 0)
  68172. * @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)
  68173. */
  68174. 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);
  68175. /**
  68176. * Updates the effect with the current post process compile time values and recompiles the shader.
  68177. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68178. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68179. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68180. * @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
  68181. * @param onCompiled Called when the shader has been compiled.
  68182. * @param onError Called if there is an error when compiling a shader.
  68183. */
  68184. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68185. }
  68186. }
  68187. declare module BABYLON {
  68188. /**
  68189. * Specifies the level of max blur that should be applied when using the depth of field effect
  68190. */
  68191. export enum DepthOfFieldEffectBlurLevel {
  68192. /**
  68193. * Subtle blur
  68194. */
  68195. Low = 0,
  68196. /**
  68197. * Medium blur
  68198. */
  68199. Medium = 1,
  68200. /**
  68201. * Large blur
  68202. */
  68203. High = 2
  68204. }
  68205. /**
  68206. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  68207. */
  68208. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  68209. private _circleOfConfusion;
  68210. /**
  68211. * @hidden Internal, blurs from high to low
  68212. */
  68213. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  68214. private _depthOfFieldBlurY;
  68215. private _dofMerge;
  68216. /**
  68217. * @hidden Internal post processes in depth of field effect
  68218. */
  68219. _effects: Array<PostProcess>;
  68220. /**
  68221. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  68222. */
  68223. set focalLength(value: number);
  68224. get focalLength(): number;
  68225. /**
  68226. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68227. */
  68228. set fStop(value: number);
  68229. get fStop(): number;
  68230. /**
  68231. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68232. */
  68233. set focusDistance(value: number);
  68234. get focusDistance(): number;
  68235. /**
  68236. * 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.
  68237. */
  68238. set lensSize(value: number);
  68239. get lensSize(): number;
  68240. /**
  68241. * Creates a new instance DepthOfFieldEffect
  68242. * @param scene The scene the effect belongs to.
  68243. * @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.
  68244. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68245. * @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)
  68246. */
  68247. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  68248. /**
  68249. * Get the current class name of the current effet
  68250. * @returns "DepthOfFieldEffect"
  68251. */
  68252. getClassName(): string;
  68253. /**
  68254. * 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.
  68255. */
  68256. set depthTexture(value: RenderTargetTexture);
  68257. /**
  68258. * Disposes each of the internal effects for a given camera.
  68259. * @param camera The camera to dispose the effect on.
  68260. */
  68261. disposeEffects(camera: Camera): void;
  68262. /**
  68263. * @hidden Internal
  68264. */
  68265. _updateEffects(): void;
  68266. /**
  68267. * Internal
  68268. * @returns if all the contained post processes are ready.
  68269. * @hidden
  68270. */
  68271. _isReady(): boolean;
  68272. }
  68273. }
  68274. declare module BABYLON {
  68275. /** @hidden */
  68276. export var displayPassPixelShader: {
  68277. name: string;
  68278. shader: string;
  68279. };
  68280. }
  68281. declare module BABYLON {
  68282. /**
  68283. * DisplayPassPostProcess which produces an output the same as it's input
  68284. */
  68285. export class DisplayPassPostProcess extends PostProcess {
  68286. /**
  68287. * Creates the DisplayPassPostProcess
  68288. * @param name The name of the effect.
  68289. * @param options The required width/height ratio to downsize to before computing the render pass.
  68290. * @param camera The camera to apply the render pass to.
  68291. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68292. * @param engine The engine which the post process will be applied. (default: current engine)
  68293. * @param reusable If the post process can be reused on the same frame. (default: false)
  68294. */
  68295. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68296. }
  68297. }
  68298. declare module BABYLON {
  68299. /** @hidden */
  68300. export var filterPixelShader: {
  68301. name: string;
  68302. shader: string;
  68303. };
  68304. }
  68305. declare module BABYLON {
  68306. /**
  68307. * Applies a kernel filter to the image
  68308. */
  68309. export class FilterPostProcess extends PostProcess {
  68310. /** The matrix to be applied to the image */
  68311. kernelMatrix: Matrix;
  68312. /**
  68313. *
  68314. * @param name The name of the effect.
  68315. * @param kernelMatrix The matrix to be applied to the image
  68316. * @param options The required width/height ratio to downsize to before computing the render pass.
  68317. * @param camera The camera to apply the render pass to.
  68318. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68319. * @param engine The engine which the post process will be applied. (default: current engine)
  68320. * @param reusable If the post process can be reused on the same frame. (default: false)
  68321. */
  68322. constructor(name: string,
  68323. /** The matrix to be applied to the image */
  68324. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68325. }
  68326. }
  68327. declare module BABYLON {
  68328. /** @hidden */
  68329. export var fxaaPixelShader: {
  68330. name: string;
  68331. shader: string;
  68332. };
  68333. }
  68334. declare module BABYLON {
  68335. /** @hidden */
  68336. export var fxaaVertexShader: {
  68337. name: string;
  68338. shader: string;
  68339. };
  68340. }
  68341. declare module BABYLON {
  68342. /**
  68343. * Fxaa post process
  68344. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  68345. */
  68346. export class FxaaPostProcess extends PostProcess {
  68347. /** @hidden */
  68348. texelWidth: number;
  68349. /** @hidden */
  68350. texelHeight: number;
  68351. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68352. private _getDefines;
  68353. }
  68354. }
  68355. declare module BABYLON {
  68356. /** @hidden */
  68357. export var grainPixelShader: {
  68358. name: string;
  68359. shader: string;
  68360. };
  68361. }
  68362. declare module BABYLON {
  68363. /**
  68364. * The GrainPostProcess adds noise to the image at mid luminance levels
  68365. */
  68366. export class GrainPostProcess extends PostProcess {
  68367. /**
  68368. * The intensity of the grain added (default: 30)
  68369. */
  68370. intensity: number;
  68371. /**
  68372. * If the grain should be randomized on every frame
  68373. */
  68374. animated: boolean;
  68375. /**
  68376. * Creates a new instance of @see GrainPostProcess
  68377. * @param name The name of the effect.
  68378. * @param options The required width/height ratio to downsize to before computing the render pass.
  68379. * @param camera The camera to apply the render pass to.
  68380. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68381. * @param engine The engine which the post process will be applied. (default: current engine)
  68382. * @param reusable If the post process can be reused on the same frame. (default: false)
  68383. * @param textureType Type of textures used when performing the post process. (default: 0)
  68384. * @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)
  68385. */
  68386. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68387. }
  68388. }
  68389. declare module BABYLON {
  68390. /** @hidden */
  68391. export var highlightsPixelShader: {
  68392. name: string;
  68393. shader: string;
  68394. };
  68395. }
  68396. declare module BABYLON {
  68397. /**
  68398. * Extracts highlights from the image
  68399. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68400. */
  68401. export class HighlightsPostProcess extends PostProcess {
  68402. /**
  68403. * Extracts highlights from the image
  68404. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68405. * @param name The name of the effect.
  68406. * @param options The required width/height ratio to downsize to before computing the render pass.
  68407. * @param camera The camera to apply the render pass to.
  68408. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68409. * @param engine The engine which the post process will be applied. (default: current engine)
  68410. * @param reusable If the post process can be reused on the same frame. (default: false)
  68411. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  68412. */
  68413. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68414. }
  68415. }
  68416. declare module BABYLON {
  68417. /** @hidden */
  68418. export var mrtFragmentDeclaration: {
  68419. name: string;
  68420. shader: string;
  68421. };
  68422. }
  68423. declare module BABYLON {
  68424. /** @hidden */
  68425. export var geometryPixelShader: {
  68426. name: string;
  68427. shader: string;
  68428. };
  68429. }
  68430. declare module BABYLON {
  68431. /** @hidden */
  68432. export var geometryVertexShader: {
  68433. name: string;
  68434. shader: string;
  68435. };
  68436. }
  68437. declare module BABYLON {
  68438. /** @hidden */
  68439. interface ISavedTransformationMatrix {
  68440. world: Matrix;
  68441. viewProjection: Matrix;
  68442. }
  68443. /**
  68444. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  68445. */
  68446. export class GeometryBufferRenderer {
  68447. /**
  68448. * Constant used to retrieve the position texture index in the G-Buffer textures array
  68449. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  68450. */
  68451. static readonly POSITION_TEXTURE_TYPE: number;
  68452. /**
  68453. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  68454. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  68455. */
  68456. static readonly VELOCITY_TEXTURE_TYPE: number;
  68457. /**
  68458. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  68459. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  68460. */
  68461. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  68462. /**
  68463. * Dictionary used to store the previous transformation matrices of each rendered mesh
  68464. * in order to compute objects velocities when enableVelocity is set to "true"
  68465. * @hidden
  68466. */
  68467. _previousTransformationMatrices: {
  68468. [index: number]: ISavedTransformationMatrix;
  68469. };
  68470. /**
  68471. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  68472. * in order to compute objects velocities when enableVelocity is set to "true"
  68473. * @hidden
  68474. */
  68475. _previousBonesTransformationMatrices: {
  68476. [index: number]: Float32Array;
  68477. };
  68478. /**
  68479. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  68480. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  68481. */
  68482. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  68483. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  68484. renderTransparentMeshes: boolean;
  68485. private _scene;
  68486. private _multiRenderTarget;
  68487. private _ratio;
  68488. private _enablePosition;
  68489. private _enableVelocity;
  68490. private _enableReflectivity;
  68491. private _positionIndex;
  68492. private _velocityIndex;
  68493. private _reflectivityIndex;
  68494. protected _effect: Effect;
  68495. protected _cachedDefines: string;
  68496. /**
  68497. * Set the render list (meshes to be rendered) used in the G buffer.
  68498. */
  68499. set renderList(meshes: Mesh[]);
  68500. /**
  68501. * Gets wether or not G buffer are supported by the running hardware.
  68502. * This requires draw buffer supports
  68503. */
  68504. get isSupported(): boolean;
  68505. /**
  68506. * Returns the index of the given texture type in the G-Buffer textures array
  68507. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  68508. * @returns the index of the given texture type in the G-Buffer textures array
  68509. */
  68510. getTextureIndex(textureType: number): number;
  68511. /**
  68512. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  68513. */
  68514. get enablePosition(): boolean;
  68515. /**
  68516. * Sets whether or not objects positions are enabled for the G buffer.
  68517. */
  68518. set enablePosition(enable: boolean);
  68519. /**
  68520. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68521. */
  68522. get enableVelocity(): boolean;
  68523. /**
  68524. * Sets wether or not objects velocities are enabled for the G buffer.
  68525. */
  68526. set enableVelocity(enable: boolean);
  68527. /**
  68528. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68529. */
  68530. get enableReflectivity(): boolean;
  68531. /**
  68532. * Sets wether or not objects roughness are enabled for the G buffer.
  68533. */
  68534. set enableReflectivity(enable: boolean);
  68535. /**
  68536. * Gets the scene associated with the buffer.
  68537. */
  68538. get scene(): Scene;
  68539. /**
  68540. * Gets the ratio used by the buffer during its creation.
  68541. * How big is the buffer related to the main canvas.
  68542. */
  68543. get ratio(): number;
  68544. /** @hidden */
  68545. static _SceneComponentInitialization: (scene: Scene) => void;
  68546. /**
  68547. * Creates a new G Buffer for the scene
  68548. * @param scene The scene the buffer belongs to
  68549. * @param ratio How big is the buffer related to the main canvas.
  68550. */
  68551. constructor(scene: Scene, ratio?: number);
  68552. /**
  68553. * Checks wether everything is ready to render a submesh to the G buffer.
  68554. * @param subMesh the submesh to check readiness for
  68555. * @param useInstances is the mesh drawn using instance or not
  68556. * @returns true if ready otherwise false
  68557. */
  68558. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68559. /**
  68560. * Gets the current underlying G Buffer.
  68561. * @returns the buffer
  68562. */
  68563. getGBuffer(): MultiRenderTarget;
  68564. /**
  68565. * Gets the number of samples used to render the buffer (anti aliasing).
  68566. */
  68567. get samples(): number;
  68568. /**
  68569. * Sets the number of samples used to render the buffer (anti aliasing).
  68570. */
  68571. set samples(value: number);
  68572. /**
  68573. * Disposes the renderer and frees up associated resources.
  68574. */
  68575. dispose(): void;
  68576. protected _createRenderTargets(): void;
  68577. private _copyBonesTransformationMatrices;
  68578. }
  68579. }
  68580. declare module BABYLON {
  68581. interface Scene {
  68582. /** @hidden (Backing field) */
  68583. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68584. /**
  68585. * Gets or Sets the current geometry buffer associated to the scene.
  68586. */
  68587. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68588. /**
  68589. * Enables a GeometryBufferRender and associates it with the scene
  68590. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68591. * @returns the GeometryBufferRenderer
  68592. */
  68593. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68594. /**
  68595. * Disables the GeometryBufferRender associated with the scene
  68596. */
  68597. disableGeometryBufferRenderer(): void;
  68598. }
  68599. /**
  68600. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68601. * in several rendering techniques.
  68602. */
  68603. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68604. /**
  68605. * The component name helpful to identify the component in the list of scene components.
  68606. */
  68607. readonly name: string;
  68608. /**
  68609. * The scene the component belongs to.
  68610. */
  68611. scene: Scene;
  68612. /**
  68613. * Creates a new instance of the component for the given scene
  68614. * @param scene Defines the scene to register the component in
  68615. */
  68616. constructor(scene: Scene);
  68617. /**
  68618. * Registers the component in a given scene
  68619. */
  68620. register(): void;
  68621. /**
  68622. * Rebuilds the elements related to this component in case of
  68623. * context lost for instance.
  68624. */
  68625. rebuild(): void;
  68626. /**
  68627. * Disposes the component and the associated ressources
  68628. */
  68629. dispose(): void;
  68630. private _gatherRenderTargets;
  68631. }
  68632. }
  68633. declare module BABYLON {
  68634. /** @hidden */
  68635. export var motionBlurPixelShader: {
  68636. name: string;
  68637. shader: string;
  68638. };
  68639. }
  68640. declare module BABYLON {
  68641. /**
  68642. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68643. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68644. * As an example, all you have to do is to create the post-process:
  68645. * var mb = new BABYLON.MotionBlurPostProcess(
  68646. * 'mb', // The name of the effect.
  68647. * scene, // The scene containing the objects to blur according to their velocity.
  68648. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68649. * camera // The camera to apply the render pass to.
  68650. * );
  68651. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68652. */
  68653. export class MotionBlurPostProcess extends PostProcess {
  68654. /**
  68655. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68656. */
  68657. motionStrength: number;
  68658. /**
  68659. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68660. */
  68661. get motionBlurSamples(): number;
  68662. /**
  68663. * Sets the number of iterations to be used for motion blur quality
  68664. */
  68665. set motionBlurSamples(samples: number);
  68666. private _motionBlurSamples;
  68667. private _geometryBufferRenderer;
  68668. /**
  68669. * Creates a new instance MotionBlurPostProcess
  68670. * @param name The name of the effect.
  68671. * @param scene The scene containing the objects to blur according to their velocity.
  68672. * @param options The required width/height ratio to downsize to before computing the render pass.
  68673. * @param camera The camera to apply the render pass to.
  68674. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68675. * @param engine The engine which the post process will be applied. (default: current engine)
  68676. * @param reusable If the post process can be reused on the same frame. (default: false)
  68677. * @param textureType Type of textures used when performing the post process. (default: 0)
  68678. * @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)
  68679. */
  68680. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68681. /**
  68682. * Excludes the given skinned mesh from computing bones velocities.
  68683. * 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.
  68684. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68685. */
  68686. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68687. /**
  68688. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68689. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68690. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68691. */
  68692. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68693. /**
  68694. * Disposes the post process.
  68695. * @param camera The camera to dispose the post process on.
  68696. */
  68697. dispose(camera?: Camera): void;
  68698. }
  68699. }
  68700. declare module BABYLON {
  68701. /** @hidden */
  68702. export var refractionPixelShader: {
  68703. name: string;
  68704. shader: string;
  68705. };
  68706. }
  68707. declare module BABYLON {
  68708. /**
  68709. * Post process which applies a refractin texture
  68710. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68711. */
  68712. export class RefractionPostProcess extends PostProcess {
  68713. /** the base color of the refraction (used to taint the rendering) */
  68714. color: Color3;
  68715. /** simulated refraction depth */
  68716. depth: number;
  68717. /** the coefficient of the base color (0 to remove base color tainting) */
  68718. colorLevel: number;
  68719. private _refTexture;
  68720. private _ownRefractionTexture;
  68721. /**
  68722. * Gets or sets the refraction texture
  68723. * Please note that you are responsible for disposing the texture if you set it manually
  68724. */
  68725. get refractionTexture(): Texture;
  68726. set refractionTexture(value: Texture);
  68727. /**
  68728. * Initializes the RefractionPostProcess
  68729. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68730. * @param name The name of the effect.
  68731. * @param refractionTextureUrl Url of the refraction texture to use
  68732. * @param color the base color of the refraction (used to taint the rendering)
  68733. * @param depth simulated refraction depth
  68734. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68735. * @param camera The camera to apply the render pass to.
  68736. * @param options The required width/height ratio to downsize to before computing the render pass.
  68737. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68738. * @param engine The engine which the post process will be applied. (default: current engine)
  68739. * @param reusable If the post process can be reused on the same frame. (default: false)
  68740. */
  68741. constructor(name: string, refractionTextureUrl: string,
  68742. /** the base color of the refraction (used to taint the rendering) */
  68743. color: Color3,
  68744. /** simulated refraction depth */
  68745. depth: number,
  68746. /** the coefficient of the base color (0 to remove base color tainting) */
  68747. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68748. /**
  68749. * Disposes of the post process
  68750. * @param camera Camera to dispose post process on
  68751. */
  68752. dispose(camera: Camera): void;
  68753. }
  68754. }
  68755. declare module BABYLON {
  68756. /** @hidden */
  68757. export var sharpenPixelShader: {
  68758. name: string;
  68759. shader: string;
  68760. };
  68761. }
  68762. declare module BABYLON {
  68763. /**
  68764. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68765. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68766. */
  68767. export class SharpenPostProcess extends PostProcess {
  68768. /**
  68769. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68770. */
  68771. colorAmount: number;
  68772. /**
  68773. * How much sharpness should be applied (default: 0.3)
  68774. */
  68775. edgeAmount: number;
  68776. /**
  68777. * Creates a new instance ConvolutionPostProcess
  68778. * @param name The name of the effect.
  68779. * @param options The required width/height ratio to downsize to before computing the render pass.
  68780. * @param camera The camera to apply the render pass to.
  68781. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68782. * @param engine The engine which the post process will be applied. (default: current engine)
  68783. * @param reusable If the post process can be reused on the same frame. (default: false)
  68784. * @param textureType Type of textures used when performing the post process. (default: 0)
  68785. * @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)
  68786. */
  68787. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68788. }
  68789. }
  68790. declare module BABYLON {
  68791. /**
  68792. * PostProcessRenderPipeline
  68793. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68794. */
  68795. export class PostProcessRenderPipeline {
  68796. private engine;
  68797. private _renderEffects;
  68798. private _renderEffectsForIsolatedPass;
  68799. /**
  68800. * List of inspectable custom properties (used by the Inspector)
  68801. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68802. */
  68803. inspectableCustomProperties: IInspectable[];
  68804. /**
  68805. * @hidden
  68806. */
  68807. protected _cameras: Camera[];
  68808. /** @hidden */
  68809. _name: string;
  68810. /**
  68811. * Gets pipeline name
  68812. */
  68813. get name(): string;
  68814. /** Gets the list of attached cameras */
  68815. get cameras(): Camera[];
  68816. /**
  68817. * Initializes a PostProcessRenderPipeline
  68818. * @param engine engine to add the pipeline to
  68819. * @param name name of the pipeline
  68820. */
  68821. constructor(engine: Engine, name: string);
  68822. /**
  68823. * Gets the class name
  68824. * @returns "PostProcessRenderPipeline"
  68825. */
  68826. getClassName(): string;
  68827. /**
  68828. * If all the render effects in the pipeline are supported
  68829. */
  68830. get isSupported(): boolean;
  68831. /**
  68832. * Adds an effect to the pipeline
  68833. * @param renderEffect the effect to add
  68834. */
  68835. addEffect(renderEffect: PostProcessRenderEffect): void;
  68836. /** @hidden */
  68837. _rebuild(): void;
  68838. /** @hidden */
  68839. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68840. /** @hidden */
  68841. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68842. /** @hidden */
  68843. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68844. /** @hidden */
  68845. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68846. /** @hidden */
  68847. _attachCameras(cameras: Camera, unique: boolean): void;
  68848. /** @hidden */
  68849. _attachCameras(cameras: Camera[], unique: boolean): void;
  68850. /** @hidden */
  68851. _detachCameras(cameras: Camera): void;
  68852. /** @hidden */
  68853. _detachCameras(cameras: Nullable<Camera[]>): void;
  68854. /** @hidden */
  68855. _update(): void;
  68856. /** @hidden */
  68857. _reset(): void;
  68858. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68859. /**
  68860. * Disposes of the pipeline
  68861. */
  68862. dispose(): void;
  68863. }
  68864. }
  68865. declare module BABYLON {
  68866. /**
  68867. * PostProcessRenderPipelineManager class
  68868. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68869. */
  68870. export class PostProcessRenderPipelineManager {
  68871. private _renderPipelines;
  68872. /**
  68873. * Initializes a PostProcessRenderPipelineManager
  68874. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68875. */
  68876. constructor();
  68877. /**
  68878. * Gets the list of supported render pipelines
  68879. */
  68880. get supportedPipelines(): PostProcessRenderPipeline[];
  68881. /**
  68882. * Adds a pipeline to the manager
  68883. * @param renderPipeline The pipeline to add
  68884. */
  68885. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68886. /**
  68887. * Attaches a camera to the pipeline
  68888. * @param renderPipelineName The name of the pipeline to attach to
  68889. * @param cameras the camera to attach
  68890. * @param unique if the camera can be attached multiple times to the pipeline
  68891. */
  68892. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68893. /**
  68894. * Detaches a camera from the pipeline
  68895. * @param renderPipelineName The name of the pipeline to detach from
  68896. * @param cameras the camera to detach
  68897. */
  68898. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68899. /**
  68900. * Enables an effect by name on a pipeline
  68901. * @param renderPipelineName the name of the pipeline to enable the effect in
  68902. * @param renderEffectName the name of the effect to enable
  68903. * @param cameras the cameras that the effect should be enabled on
  68904. */
  68905. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68906. /**
  68907. * Disables an effect by name on a pipeline
  68908. * @param renderPipelineName the name of the pipeline to disable the effect in
  68909. * @param renderEffectName the name of the effect to disable
  68910. * @param cameras the cameras that the effect should be disabled on
  68911. */
  68912. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68913. /**
  68914. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68915. */
  68916. update(): void;
  68917. /** @hidden */
  68918. _rebuild(): void;
  68919. /**
  68920. * Disposes of the manager and pipelines
  68921. */
  68922. dispose(): void;
  68923. }
  68924. }
  68925. declare module BABYLON {
  68926. interface Scene {
  68927. /** @hidden (Backing field) */
  68928. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68929. /**
  68930. * Gets the postprocess render pipeline manager
  68931. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68932. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68933. */
  68934. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68935. }
  68936. /**
  68937. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68938. */
  68939. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68940. /**
  68941. * The component name helpfull to identify the component in the list of scene components.
  68942. */
  68943. readonly name: string;
  68944. /**
  68945. * The scene the component belongs to.
  68946. */
  68947. scene: Scene;
  68948. /**
  68949. * Creates a new instance of the component for the given scene
  68950. * @param scene Defines the scene to register the component in
  68951. */
  68952. constructor(scene: Scene);
  68953. /**
  68954. * Registers the component in a given scene
  68955. */
  68956. register(): void;
  68957. /**
  68958. * Rebuilds the elements related to this component in case of
  68959. * context lost for instance.
  68960. */
  68961. rebuild(): void;
  68962. /**
  68963. * Disposes the component and the associated ressources
  68964. */
  68965. dispose(): void;
  68966. private _gatherRenderTargets;
  68967. }
  68968. }
  68969. declare module BABYLON {
  68970. /**
  68971. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68972. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68973. */
  68974. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68975. private _scene;
  68976. private _camerasToBeAttached;
  68977. /**
  68978. * ID of the sharpen post process,
  68979. */
  68980. private readonly SharpenPostProcessId;
  68981. /**
  68982. * @ignore
  68983. * ID of the image processing post process;
  68984. */
  68985. readonly ImageProcessingPostProcessId: string;
  68986. /**
  68987. * @ignore
  68988. * ID of the Fast Approximate Anti-Aliasing post process;
  68989. */
  68990. readonly FxaaPostProcessId: string;
  68991. /**
  68992. * ID of the chromatic aberration post process,
  68993. */
  68994. private readonly ChromaticAberrationPostProcessId;
  68995. /**
  68996. * ID of the grain post process
  68997. */
  68998. private readonly GrainPostProcessId;
  68999. /**
  69000. * Sharpen post process which will apply a sharpen convolution to enhance edges
  69001. */
  69002. sharpen: SharpenPostProcess;
  69003. private _sharpenEffect;
  69004. private bloom;
  69005. /**
  69006. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  69007. */
  69008. depthOfField: DepthOfFieldEffect;
  69009. /**
  69010. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69011. */
  69012. fxaa: FxaaPostProcess;
  69013. /**
  69014. * Image post processing pass used to perform operations such as tone mapping or color grading.
  69015. */
  69016. imageProcessing: ImageProcessingPostProcess;
  69017. /**
  69018. * Chromatic aberration post process which will shift rgb colors in the image
  69019. */
  69020. chromaticAberration: ChromaticAberrationPostProcess;
  69021. private _chromaticAberrationEffect;
  69022. /**
  69023. * Grain post process which add noise to the image
  69024. */
  69025. grain: GrainPostProcess;
  69026. private _grainEffect;
  69027. /**
  69028. * Glow post process which adds a glow to emissive areas of the image
  69029. */
  69030. private _glowLayer;
  69031. /**
  69032. * Animations which can be used to tweak settings over a period of time
  69033. */
  69034. animations: Animation[];
  69035. private _imageProcessingConfigurationObserver;
  69036. private _sharpenEnabled;
  69037. private _bloomEnabled;
  69038. private _depthOfFieldEnabled;
  69039. private _depthOfFieldBlurLevel;
  69040. private _fxaaEnabled;
  69041. private _imageProcessingEnabled;
  69042. private _defaultPipelineTextureType;
  69043. private _bloomScale;
  69044. private _chromaticAberrationEnabled;
  69045. private _grainEnabled;
  69046. private _buildAllowed;
  69047. /**
  69048. * Gets active scene
  69049. */
  69050. get scene(): Scene;
  69051. /**
  69052. * Enable or disable the sharpen process from the pipeline
  69053. */
  69054. set sharpenEnabled(enabled: boolean);
  69055. get sharpenEnabled(): boolean;
  69056. private _resizeObserver;
  69057. private _hardwareScaleLevel;
  69058. private _bloomKernel;
  69059. /**
  69060. * Specifies the size of the bloom blur kernel, relative to the final output size
  69061. */
  69062. get bloomKernel(): number;
  69063. set bloomKernel(value: number);
  69064. /**
  69065. * Specifies the weight of the bloom in the final rendering
  69066. */
  69067. private _bloomWeight;
  69068. /**
  69069. * Specifies the luma threshold for the area that will be blurred by the bloom
  69070. */
  69071. private _bloomThreshold;
  69072. private _hdr;
  69073. /**
  69074. * The strength of the bloom.
  69075. */
  69076. set bloomWeight(value: number);
  69077. get bloomWeight(): number;
  69078. /**
  69079. * The strength of the bloom.
  69080. */
  69081. set bloomThreshold(value: number);
  69082. get bloomThreshold(): number;
  69083. /**
  69084. * The scale of the bloom, lower value will provide better performance.
  69085. */
  69086. set bloomScale(value: number);
  69087. get bloomScale(): number;
  69088. /**
  69089. * Enable or disable the bloom from the pipeline
  69090. */
  69091. set bloomEnabled(enabled: boolean);
  69092. get bloomEnabled(): boolean;
  69093. private _rebuildBloom;
  69094. /**
  69095. * If the depth of field is enabled.
  69096. */
  69097. get depthOfFieldEnabled(): boolean;
  69098. set depthOfFieldEnabled(enabled: boolean);
  69099. /**
  69100. * Blur level of the depth of field effect. (Higher blur will effect performance)
  69101. */
  69102. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  69103. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  69104. /**
  69105. * If the anti aliasing is enabled.
  69106. */
  69107. set fxaaEnabled(enabled: boolean);
  69108. get fxaaEnabled(): boolean;
  69109. private _samples;
  69110. /**
  69111. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69112. */
  69113. set samples(sampleCount: number);
  69114. get samples(): number;
  69115. /**
  69116. * If image processing is enabled.
  69117. */
  69118. set imageProcessingEnabled(enabled: boolean);
  69119. get imageProcessingEnabled(): boolean;
  69120. /**
  69121. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  69122. */
  69123. set glowLayerEnabled(enabled: boolean);
  69124. get glowLayerEnabled(): boolean;
  69125. /**
  69126. * Gets the glow layer (or null if not defined)
  69127. */
  69128. get glowLayer(): Nullable<GlowLayer>;
  69129. /**
  69130. * Enable or disable the chromaticAberration process from the pipeline
  69131. */
  69132. set chromaticAberrationEnabled(enabled: boolean);
  69133. get chromaticAberrationEnabled(): boolean;
  69134. /**
  69135. * Enable or disable the grain process from the pipeline
  69136. */
  69137. set grainEnabled(enabled: boolean);
  69138. get grainEnabled(): boolean;
  69139. /**
  69140. * @constructor
  69141. * @param name - The rendering pipeline name (default: "")
  69142. * @param hdr - If high dynamic range textures should be used (default: true)
  69143. * @param scene - The scene linked to this pipeline (default: the last created scene)
  69144. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  69145. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  69146. */
  69147. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  69148. /**
  69149. * Get the class name
  69150. * @returns "DefaultRenderingPipeline"
  69151. */
  69152. getClassName(): string;
  69153. /**
  69154. * Force the compilation of the entire pipeline.
  69155. */
  69156. prepare(): void;
  69157. private _hasCleared;
  69158. private _prevPostProcess;
  69159. private _prevPrevPostProcess;
  69160. private _setAutoClearAndTextureSharing;
  69161. private _depthOfFieldSceneObserver;
  69162. private _buildPipeline;
  69163. private _disposePostProcesses;
  69164. /**
  69165. * Adds a camera to the pipeline
  69166. * @param camera the camera to be added
  69167. */
  69168. addCamera(camera: Camera): void;
  69169. /**
  69170. * Removes a camera from the pipeline
  69171. * @param camera the camera to remove
  69172. */
  69173. removeCamera(camera: Camera): void;
  69174. /**
  69175. * Dispose of the pipeline and stop all post processes
  69176. */
  69177. dispose(): void;
  69178. /**
  69179. * Serialize the rendering pipeline (Used when exporting)
  69180. * @returns the serialized object
  69181. */
  69182. serialize(): any;
  69183. /**
  69184. * Parse the serialized pipeline
  69185. * @param source Source pipeline.
  69186. * @param scene The scene to load the pipeline to.
  69187. * @param rootUrl The URL of the serialized pipeline.
  69188. * @returns An instantiated pipeline from the serialized object.
  69189. */
  69190. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  69191. }
  69192. }
  69193. declare module BABYLON {
  69194. /** @hidden */
  69195. export var lensHighlightsPixelShader: {
  69196. name: string;
  69197. shader: string;
  69198. };
  69199. }
  69200. declare module BABYLON {
  69201. /** @hidden */
  69202. export var depthOfFieldPixelShader: {
  69203. name: string;
  69204. shader: string;
  69205. };
  69206. }
  69207. declare module BABYLON {
  69208. /**
  69209. * BABYLON.JS Chromatic Aberration GLSL Shader
  69210. * Author: Olivier Guyot
  69211. * Separates very slightly R, G and B colors on the edges of the screen
  69212. * Inspired by Francois Tarlier & Martins Upitis
  69213. */
  69214. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  69215. /**
  69216. * @ignore
  69217. * The chromatic aberration PostProcess id in the pipeline
  69218. */
  69219. LensChromaticAberrationEffect: string;
  69220. /**
  69221. * @ignore
  69222. * The highlights enhancing PostProcess id in the pipeline
  69223. */
  69224. HighlightsEnhancingEffect: string;
  69225. /**
  69226. * @ignore
  69227. * The depth-of-field PostProcess id in the pipeline
  69228. */
  69229. LensDepthOfFieldEffect: string;
  69230. private _scene;
  69231. private _depthTexture;
  69232. private _grainTexture;
  69233. private _chromaticAberrationPostProcess;
  69234. private _highlightsPostProcess;
  69235. private _depthOfFieldPostProcess;
  69236. private _edgeBlur;
  69237. private _grainAmount;
  69238. private _chromaticAberration;
  69239. private _distortion;
  69240. private _highlightsGain;
  69241. private _highlightsThreshold;
  69242. private _dofDistance;
  69243. private _dofAperture;
  69244. private _dofDarken;
  69245. private _dofPentagon;
  69246. private _blurNoise;
  69247. /**
  69248. * @constructor
  69249. *
  69250. * Effect parameters are as follow:
  69251. * {
  69252. * chromatic_aberration: number; // from 0 to x (1 for realism)
  69253. * edge_blur: number; // from 0 to x (1 for realism)
  69254. * distortion: number; // from 0 to x (1 for realism)
  69255. * grain_amount: number; // from 0 to 1
  69256. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  69257. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  69258. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  69259. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  69260. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  69261. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  69262. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  69263. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  69264. * }
  69265. * Note: if an effect parameter is unset, effect is disabled
  69266. *
  69267. * @param name The rendering pipeline name
  69268. * @param parameters - An object containing all parameters (see above)
  69269. * @param scene The scene linked to this pipeline
  69270. * @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)
  69271. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69272. */
  69273. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  69274. /**
  69275. * Get the class name
  69276. * @returns "LensRenderingPipeline"
  69277. */
  69278. getClassName(): string;
  69279. /**
  69280. * Gets associated scene
  69281. */
  69282. get scene(): Scene;
  69283. /**
  69284. * Gets or sets the edge blur
  69285. */
  69286. get edgeBlur(): number;
  69287. set edgeBlur(value: number);
  69288. /**
  69289. * Gets or sets the grain amount
  69290. */
  69291. get grainAmount(): number;
  69292. set grainAmount(value: number);
  69293. /**
  69294. * Gets or sets the chromatic aberration amount
  69295. */
  69296. get chromaticAberration(): number;
  69297. set chromaticAberration(value: number);
  69298. /**
  69299. * Gets or sets the depth of field aperture
  69300. */
  69301. get dofAperture(): number;
  69302. set dofAperture(value: number);
  69303. /**
  69304. * Gets or sets the edge distortion
  69305. */
  69306. get edgeDistortion(): number;
  69307. set edgeDistortion(value: number);
  69308. /**
  69309. * Gets or sets the depth of field distortion
  69310. */
  69311. get dofDistortion(): number;
  69312. set dofDistortion(value: number);
  69313. /**
  69314. * Gets or sets the darken out of focus amount
  69315. */
  69316. get darkenOutOfFocus(): number;
  69317. set darkenOutOfFocus(value: number);
  69318. /**
  69319. * Gets or sets a boolean indicating if blur noise is enabled
  69320. */
  69321. get blurNoise(): boolean;
  69322. set blurNoise(value: boolean);
  69323. /**
  69324. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  69325. */
  69326. get pentagonBokeh(): boolean;
  69327. set pentagonBokeh(value: boolean);
  69328. /**
  69329. * Gets or sets the highlight grain amount
  69330. */
  69331. get highlightsGain(): number;
  69332. set highlightsGain(value: number);
  69333. /**
  69334. * Gets or sets the highlight threshold
  69335. */
  69336. get highlightsThreshold(): number;
  69337. set highlightsThreshold(value: number);
  69338. /**
  69339. * Sets the amount of blur at the edges
  69340. * @param amount blur amount
  69341. */
  69342. setEdgeBlur(amount: number): void;
  69343. /**
  69344. * Sets edge blur to 0
  69345. */
  69346. disableEdgeBlur(): void;
  69347. /**
  69348. * Sets the amout of grain
  69349. * @param amount Amount of grain
  69350. */
  69351. setGrainAmount(amount: number): void;
  69352. /**
  69353. * Set grain amount to 0
  69354. */
  69355. disableGrain(): void;
  69356. /**
  69357. * Sets the chromatic aberration amount
  69358. * @param amount amount of chromatic aberration
  69359. */
  69360. setChromaticAberration(amount: number): void;
  69361. /**
  69362. * Sets chromatic aberration amount to 0
  69363. */
  69364. disableChromaticAberration(): void;
  69365. /**
  69366. * Sets the EdgeDistortion amount
  69367. * @param amount amount of EdgeDistortion
  69368. */
  69369. setEdgeDistortion(amount: number): void;
  69370. /**
  69371. * Sets edge distortion to 0
  69372. */
  69373. disableEdgeDistortion(): void;
  69374. /**
  69375. * Sets the FocusDistance amount
  69376. * @param amount amount of FocusDistance
  69377. */
  69378. setFocusDistance(amount: number): void;
  69379. /**
  69380. * Disables depth of field
  69381. */
  69382. disableDepthOfField(): void;
  69383. /**
  69384. * Sets the Aperture amount
  69385. * @param amount amount of Aperture
  69386. */
  69387. setAperture(amount: number): void;
  69388. /**
  69389. * Sets the DarkenOutOfFocus amount
  69390. * @param amount amount of DarkenOutOfFocus
  69391. */
  69392. setDarkenOutOfFocus(amount: number): void;
  69393. private _pentagonBokehIsEnabled;
  69394. /**
  69395. * Creates a pentagon bokeh effect
  69396. */
  69397. enablePentagonBokeh(): void;
  69398. /**
  69399. * Disables the pentagon bokeh effect
  69400. */
  69401. disablePentagonBokeh(): void;
  69402. /**
  69403. * Enables noise blur
  69404. */
  69405. enableNoiseBlur(): void;
  69406. /**
  69407. * Disables noise blur
  69408. */
  69409. disableNoiseBlur(): void;
  69410. /**
  69411. * Sets the HighlightsGain amount
  69412. * @param amount amount of HighlightsGain
  69413. */
  69414. setHighlightsGain(amount: number): void;
  69415. /**
  69416. * Sets the HighlightsThreshold amount
  69417. * @param amount amount of HighlightsThreshold
  69418. */
  69419. setHighlightsThreshold(amount: number): void;
  69420. /**
  69421. * Disables highlights
  69422. */
  69423. disableHighlights(): void;
  69424. /**
  69425. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  69426. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  69427. */
  69428. dispose(disableDepthRender?: boolean): void;
  69429. private _createChromaticAberrationPostProcess;
  69430. private _createHighlightsPostProcess;
  69431. private _createDepthOfFieldPostProcess;
  69432. private _createGrainTexture;
  69433. }
  69434. }
  69435. declare module BABYLON {
  69436. /** @hidden */
  69437. export var ssao2PixelShader: {
  69438. name: string;
  69439. shader: string;
  69440. };
  69441. }
  69442. declare module BABYLON {
  69443. /** @hidden */
  69444. export var ssaoCombinePixelShader: {
  69445. name: string;
  69446. shader: string;
  69447. };
  69448. }
  69449. declare module BABYLON {
  69450. /**
  69451. * Render pipeline to produce ssao effect
  69452. */
  69453. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  69454. /**
  69455. * @ignore
  69456. * The PassPostProcess id in the pipeline that contains the original scene color
  69457. */
  69458. SSAOOriginalSceneColorEffect: string;
  69459. /**
  69460. * @ignore
  69461. * The SSAO PostProcess id in the pipeline
  69462. */
  69463. SSAORenderEffect: string;
  69464. /**
  69465. * @ignore
  69466. * The horizontal blur PostProcess id in the pipeline
  69467. */
  69468. SSAOBlurHRenderEffect: string;
  69469. /**
  69470. * @ignore
  69471. * The vertical blur PostProcess id in the pipeline
  69472. */
  69473. SSAOBlurVRenderEffect: string;
  69474. /**
  69475. * @ignore
  69476. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69477. */
  69478. SSAOCombineRenderEffect: string;
  69479. /**
  69480. * The output strength of the SSAO post-process. Default value is 1.0.
  69481. */
  69482. totalStrength: number;
  69483. /**
  69484. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69485. */
  69486. maxZ: number;
  69487. /**
  69488. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69489. */
  69490. minZAspect: number;
  69491. private _samples;
  69492. /**
  69493. * Number of samples used for the SSAO calculations. Default value is 8
  69494. */
  69495. set samples(n: number);
  69496. get samples(): number;
  69497. private _textureSamples;
  69498. /**
  69499. * Number of samples to use for antialiasing
  69500. */
  69501. set textureSamples(n: number);
  69502. get textureSamples(): number;
  69503. /**
  69504. * Ratio object used for SSAO ratio and blur ratio
  69505. */
  69506. private _ratio;
  69507. /**
  69508. * Dynamically generated sphere sampler.
  69509. */
  69510. private _sampleSphere;
  69511. /**
  69512. * Blur filter offsets
  69513. */
  69514. private _samplerOffsets;
  69515. private _expensiveBlur;
  69516. /**
  69517. * If bilateral blur should be used
  69518. */
  69519. set expensiveBlur(b: boolean);
  69520. get expensiveBlur(): boolean;
  69521. /**
  69522. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69523. */
  69524. radius: number;
  69525. /**
  69526. * The base color of the SSAO post-process
  69527. * The final result is "base + ssao" between [0, 1]
  69528. */
  69529. base: number;
  69530. /**
  69531. * Support test.
  69532. */
  69533. static get IsSupported(): boolean;
  69534. private _scene;
  69535. private _depthTexture;
  69536. private _normalTexture;
  69537. private _randomTexture;
  69538. private _originalColorPostProcess;
  69539. private _ssaoPostProcess;
  69540. private _blurHPostProcess;
  69541. private _blurVPostProcess;
  69542. private _ssaoCombinePostProcess;
  69543. /**
  69544. * Gets active scene
  69545. */
  69546. get scene(): Scene;
  69547. /**
  69548. * @constructor
  69549. * @param name The rendering pipeline name
  69550. * @param scene The scene linked to this pipeline
  69551. * @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 }
  69552. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69553. */
  69554. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69555. /**
  69556. * Get the class name
  69557. * @returns "SSAO2RenderingPipeline"
  69558. */
  69559. getClassName(): string;
  69560. /**
  69561. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69562. */
  69563. dispose(disableGeometryBufferRenderer?: boolean): void;
  69564. private _createBlurPostProcess;
  69565. /** @hidden */
  69566. _rebuild(): void;
  69567. private _bits;
  69568. private _radicalInverse_VdC;
  69569. private _hammersley;
  69570. private _hemisphereSample_uniform;
  69571. private _generateHemisphere;
  69572. private _createSSAOPostProcess;
  69573. private _createSSAOCombinePostProcess;
  69574. private _createRandomTexture;
  69575. /**
  69576. * Serialize the rendering pipeline (Used when exporting)
  69577. * @returns the serialized object
  69578. */
  69579. serialize(): any;
  69580. /**
  69581. * Parse the serialized pipeline
  69582. * @param source Source pipeline.
  69583. * @param scene The scene to load the pipeline to.
  69584. * @param rootUrl The URL of the serialized pipeline.
  69585. * @returns An instantiated pipeline from the serialized object.
  69586. */
  69587. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69588. }
  69589. }
  69590. declare module BABYLON {
  69591. /** @hidden */
  69592. export var ssaoPixelShader: {
  69593. name: string;
  69594. shader: string;
  69595. };
  69596. }
  69597. declare module BABYLON {
  69598. /**
  69599. * Render pipeline to produce ssao effect
  69600. */
  69601. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  69602. /**
  69603. * @ignore
  69604. * The PassPostProcess id in the pipeline that contains the original scene color
  69605. */
  69606. SSAOOriginalSceneColorEffect: string;
  69607. /**
  69608. * @ignore
  69609. * The SSAO PostProcess id in the pipeline
  69610. */
  69611. SSAORenderEffect: string;
  69612. /**
  69613. * @ignore
  69614. * The horizontal blur PostProcess id in the pipeline
  69615. */
  69616. SSAOBlurHRenderEffect: string;
  69617. /**
  69618. * @ignore
  69619. * The vertical blur PostProcess id in the pipeline
  69620. */
  69621. SSAOBlurVRenderEffect: string;
  69622. /**
  69623. * @ignore
  69624. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69625. */
  69626. SSAOCombineRenderEffect: string;
  69627. /**
  69628. * The output strength of the SSAO post-process. Default value is 1.0.
  69629. */
  69630. totalStrength: number;
  69631. /**
  69632. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  69633. */
  69634. radius: number;
  69635. /**
  69636. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  69637. * Must not be equal to fallOff and superior to fallOff.
  69638. * Default value is 0.0075
  69639. */
  69640. area: number;
  69641. /**
  69642. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  69643. * Must not be equal to area and inferior to area.
  69644. * Default value is 0.000001
  69645. */
  69646. fallOff: number;
  69647. /**
  69648. * The base color of the SSAO post-process
  69649. * The final result is "base + ssao" between [0, 1]
  69650. */
  69651. base: number;
  69652. private _scene;
  69653. private _depthTexture;
  69654. private _randomTexture;
  69655. private _originalColorPostProcess;
  69656. private _ssaoPostProcess;
  69657. private _blurHPostProcess;
  69658. private _blurVPostProcess;
  69659. private _ssaoCombinePostProcess;
  69660. private _firstUpdate;
  69661. /**
  69662. * Gets active scene
  69663. */
  69664. get scene(): Scene;
  69665. /**
  69666. * @constructor
  69667. * @param name - The rendering pipeline name
  69668. * @param scene - The scene linked to this pipeline
  69669. * @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 }
  69670. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69671. */
  69672. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69673. /**
  69674. * Get the class name
  69675. * @returns "SSAORenderingPipeline"
  69676. */
  69677. getClassName(): string;
  69678. /**
  69679. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69680. */
  69681. dispose(disableDepthRender?: boolean): void;
  69682. private _createBlurPostProcess;
  69683. /** @hidden */
  69684. _rebuild(): void;
  69685. private _createSSAOPostProcess;
  69686. private _createSSAOCombinePostProcess;
  69687. private _createRandomTexture;
  69688. }
  69689. }
  69690. declare module BABYLON {
  69691. /** @hidden */
  69692. export var screenSpaceReflectionPixelShader: {
  69693. name: string;
  69694. shader: string;
  69695. };
  69696. }
  69697. declare module BABYLON {
  69698. /**
  69699. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69700. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69701. */
  69702. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69703. /**
  69704. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69705. */
  69706. threshold: number;
  69707. /**
  69708. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69709. */
  69710. strength: number;
  69711. /**
  69712. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69713. */
  69714. reflectionSpecularFalloffExponent: number;
  69715. /**
  69716. * 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]
  69717. */
  69718. step: number;
  69719. /**
  69720. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69721. */
  69722. roughnessFactor: number;
  69723. private _geometryBufferRenderer;
  69724. private _enableSmoothReflections;
  69725. private _reflectionSamples;
  69726. private _smoothSteps;
  69727. /**
  69728. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69729. * @param name The name of the effect.
  69730. * @param scene The scene containing the objects to calculate reflections.
  69731. * @param options The required width/height ratio to downsize to before computing the render pass.
  69732. * @param camera The camera to apply the render pass to.
  69733. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69734. * @param engine The engine which the post process will be applied. (default: current engine)
  69735. * @param reusable If the post process can be reused on the same frame. (default: false)
  69736. * @param textureType Type of textures used when performing the post process. (default: 0)
  69737. * @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)
  69738. */
  69739. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69740. /**
  69741. * Gets wether or not smoothing reflections is enabled.
  69742. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69743. */
  69744. get enableSmoothReflections(): boolean;
  69745. /**
  69746. * Sets wether or not smoothing reflections is enabled.
  69747. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69748. */
  69749. set enableSmoothReflections(enabled: boolean);
  69750. /**
  69751. * Gets the number of samples taken while computing reflections. More samples count is high,
  69752. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69753. */
  69754. get reflectionSamples(): number;
  69755. /**
  69756. * Sets the number of samples taken while computing reflections. More samples count is high,
  69757. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69758. */
  69759. set reflectionSamples(samples: number);
  69760. /**
  69761. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69762. * more the post-process will require GPU power and can generate a drop in FPS.
  69763. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69764. */
  69765. get smoothSteps(): number;
  69766. set smoothSteps(steps: number);
  69767. private _updateEffectDefines;
  69768. }
  69769. }
  69770. declare module BABYLON {
  69771. /** @hidden */
  69772. export var standardPixelShader: {
  69773. name: string;
  69774. shader: string;
  69775. };
  69776. }
  69777. declare module BABYLON {
  69778. /**
  69779. * Standard rendering pipeline
  69780. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69781. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69782. */
  69783. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69784. /**
  69785. * Public members
  69786. */
  69787. /**
  69788. * Post-process which contains the original scene color before the pipeline applies all the effects
  69789. */
  69790. originalPostProcess: Nullable<PostProcess>;
  69791. /**
  69792. * Post-process used to down scale an image x4
  69793. */
  69794. downSampleX4PostProcess: Nullable<PostProcess>;
  69795. /**
  69796. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69797. */
  69798. brightPassPostProcess: Nullable<PostProcess>;
  69799. /**
  69800. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69801. */
  69802. blurHPostProcesses: PostProcess[];
  69803. /**
  69804. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69805. */
  69806. blurVPostProcesses: PostProcess[];
  69807. /**
  69808. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69809. */
  69810. textureAdderPostProcess: Nullable<PostProcess>;
  69811. /**
  69812. * Post-process used to create volumetric lighting effect
  69813. */
  69814. volumetricLightPostProcess: Nullable<PostProcess>;
  69815. /**
  69816. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69817. */
  69818. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69819. /**
  69820. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69821. */
  69822. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69823. /**
  69824. * Post-process used to merge the volumetric light effect and the real scene color
  69825. */
  69826. volumetricLightMergePostProces: Nullable<PostProcess>;
  69827. /**
  69828. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69829. */
  69830. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69831. /**
  69832. * Base post-process used to calculate the average luminance of the final image for HDR
  69833. */
  69834. luminancePostProcess: Nullable<PostProcess>;
  69835. /**
  69836. * Post-processes used to create down sample post-processes in order to get
  69837. * the average luminance of the final image for HDR
  69838. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69839. */
  69840. luminanceDownSamplePostProcesses: PostProcess[];
  69841. /**
  69842. * Post-process used to create a HDR effect (light adaptation)
  69843. */
  69844. hdrPostProcess: Nullable<PostProcess>;
  69845. /**
  69846. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69847. */
  69848. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69849. /**
  69850. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69851. */
  69852. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69853. /**
  69854. * Post-process used to merge the final HDR post-process and the real scene color
  69855. */
  69856. hdrFinalPostProcess: Nullable<PostProcess>;
  69857. /**
  69858. * Post-process used to create a lens flare effect
  69859. */
  69860. lensFlarePostProcess: Nullable<PostProcess>;
  69861. /**
  69862. * Post-process that merges the result of the lens flare post-process and the real scene color
  69863. */
  69864. lensFlareComposePostProcess: Nullable<PostProcess>;
  69865. /**
  69866. * Post-process used to create a motion blur effect
  69867. */
  69868. motionBlurPostProcess: Nullable<PostProcess>;
  69869. /**
  69870. * Post-process used to create a depth of field effect
  69871. */
  69872. depthOfFieldPostProcess: Nullable<PostProcess>;
  69873. /**
  69874. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69875. */
  69876. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69877. /**
  69878. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  69879. */
  69880. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  69881. /**
  69882. * Represents the brightness threshold in order to configure the illuminated surfaces
  69883. */
  69884. brightThreshold: number;
  69885. /**
  69886. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69887. */
  69888. blurWidth: number;
  69889. /**
  69890. * Sets if the blur for highlighted surfaces must be only horizontal
  69891. */
  69892. horizontalBlur: boolean;
  69893. /**
  69894. * Gets the overall exposure used by the pipeline
  69895. */
  69896. get exposure(): number;
  69897. /**
  69898. * Sets the overall exposure used by the pipeline
  69899. */
  69900. set exposure(value: number);
  69901. /**
  69902. * Texture used typically to simulate "dirty" on camera lens
  69903. */
  69904. lensTexture: Nullable<Texture>;
  69905. /**
  69906. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69907. */
  69908. volumetricLightCoefficient: number;
  69909. /**
  69910. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69911. */
  69912. volumetricLightPower: number;
  69913. /**
  69914. * Used the set the blur intensity to smooth the volumetric lights
  69915. */
  69916. volumetricLightBlurScale: number;
  69917. /**
  69918. * Light (spot or directional) used to generate the volumetric lights rays
  69919. * The source light must have a shadow generate so the pipeline can get its
  69920. * depth map
  69921. */
  69922. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69923. /**
  69924. * For eye adaptation, represents the minimum luminance the eye can see
  69925. */
  69926. hdrMinimumLuminance: number;
  69927. /**
  69928. * For eye adaptation, represents the decrease luminance speed
  69929. */
  69930. hdrDecreaseRate: number;
  69931. /**
  69932. * For eye adaptation, represents the increase luminance speed
  69933. */
  69934. hdrIncreaseRate: number;
  69935. /**
  69936. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69937. */
  69938. get hdrAutoExposure(): boolean;
  69939. /**
  69940. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69941. */
  69942. set hdrAutoExposure(value: boolean);
  69943. /**
  69944. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69945. */
  69946. lensColorTexture: Nullable<Texture>;
  69947. /**
  69948. * The overall strengh for the lens flare effect
  69949. */
  69950. lensFlareStrength: number;
  69951. /**
  69952. * Dispersion coefficient for lens flare ghosts
  69953. */
  69954. lensFlareGhostDispersal: number;
  69955. /**
  69956. * Main lens flare halo width
  69957. */
  69958. lensFlareHaloWidth: number;
  69959. /**
  69960. * Based on the lens distortion effect, defines how much the lens flare result
  69961. * is distorted
  69962. */
  69963. lensFlareDistortionStrength: number;
  69964. /**
  69965. * Configures the blur intensity used for for lens flare (halo)
  69966. */
  69967. lensFlareBlurWidth: number;
  69968. /**
  69969. * Lens star texture must be used to simulate rays on the flares and is available
  69970. * in the documentation
  69971. */
  69972. lensStarTexture: Nullable<Texture>;
  69973. /**
  69974. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69975. * flare effect by taking account of the dirt texture
  69976. */
  69977. lensFlareDirtTexture: Nullable<Texture>;
  69978. /**
  69979. * Represents the focal length for the depth of field effect
  69980. */
  69981. depthOfFieldDistance: number;
  69982. /**
  69983. * Represents the blur intensity for the blurred part of the depth of field effect
  69984. */
  69985. depthOfFieldBlurWidth: number;
  69986. /**
  69987. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69988. */
  69989. get motionStrength(): number;
  69990. /**
  69991. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69992. */
  69993. set motionStrength(strength: number);
  69994. /**
  69995. * Gets wether or not the motion blur post-process is object based or screen based.
  69996. */
  69997. get objectBasedMotionBlur(): boolean;
  69998. /**
  69999. * Sets wether or not the motion blur post-process should be object based or screen based
  70000. */
  70001. set objectBasedMotionBlur(value: boolean);
  70002. /**
  70003. * List of animations for the pipeline (IAnimatable implementation)
  70004. */
  70005. animations: Animation[];
  70006. /**
  70007. * Private members
  70008. */
  70009. private _scene;
  70010. private _currentDepthOfFieldSource;
  70011. private _basePostProcess;
  70012. private _fixedExposure;
  70013. private _currentExposure;
  70014. private _hdrAutoExposure;
  70015. private _hdrCurrentLuminance;
  70016. private _motionStrength;
  70017. private _isObjectBasedMotionBlur;
  70018. private _floatTextureType;
  70019. private _camerasToBeAttached;
  70020. private _ratio;
  70021. private _bloomEnabled;
  70022. private _depthOfFieldEnabled;
  70023. private _vlsEnabled;
  70024. private _lensFlareEnabled;
  70025. private _hdrEnabled;
  70026. private _motionBlurEnabled;
  70027. private _fxaaEnabled;
  70028. private _screenSpaceReflectionsEnabled;
  70029. private _motionBlurSamples;
  70030. private _volumetricLightStepsCount;
  70031. private _samples;
  70032. /**
  70033. * @ignore
  70034. * Specifies if the bloom pipeline is enabled
  70035. */
  70036. get BloomEnabled(): boolean;
  70037. set BloomEnabled(enabled: boolean);
  70038. /**
  70039. * @ignore
  70040. * Specifies if the depth of field pipeline is enabed
  70041. */
  70042. get DepthOfFieldEnabled(): boolean;
  70043. set DepthOfFieldEnabled(enabled: boolean);
  70044. /**
  70045. * @ignore
  70046. * Specifies if the lens flare pipeline is enabed
  70047. */
  70048. get LensFlareEnabled(): boolean;
  70049. set LensFlareEnabled(enabled: boolean);
  70050. /**
  70051. * @ignore
  70052. * Specifies if the HDR pipeline is enabled
  70053. */
  70054. get HDREnabled(): boolean;
  70055. set HDREnabled(enabled: boolean);
  70056. /**
  70057. * @ignore
  70058. * Specifies if the volumetric lights scattering effect is enabled
  70059. */
  70060. get VLSEnabled(): boolean;
  70061. set VLSEnabled(enabled: boolean);
  70062. /**
  70063. * @ignore
  70064. * Specifies if the motion blur effect is enabled
  70065. */
  70066. get MotionBlurEnabled(): boolean;
  70067. set MotionBlurEnabled(enabled: boolean);
  70068. /**
  70069. * Specifies if anti-aliasing is enabled
  70070. */
  70071. get fxaaEnabled(): boolean;
  70072. set fxaaEnabled(enabled: boolean);
  70073. /**
  70074. * Specifies if screen space reflections are enabled.
  70075. */
  70076. get screenSpaceReflectionsEnabled(): boolean;
  70077. set screenSpaceReflectionsEnabled(enabled: boolean);
  70078. /**
  70079. * Specifies the number of steps used to calculate the volumetric lights
  70080. * Typically in interval [50, 200]
  70081. */
  70082. get volumetricLightStepsCount(): number;
  70083. set volumetricLightStepsCount(count: number);
  70084. /**
  70085. * Specifies the number of samples used for the motion blur effect
  70086. * Typically in interval [16, 64]
  70087. */
  70088. get motionBlurSamples(): number;
  70089. set motionBlurSamples(samples: number);
  70090. /**
  70091. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70092. */
  70093. get samples(): number;
  70094. set samples(sampleCount: number);
  70095. /**
  70096. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70097. * @constructor
  70098. * @param name The rendering pipeline name
  70099. * @param scene The scene linked to this pipeline
  70100. * @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)
  70101. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  70102. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70103. */
  70104. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  70105. private _buildPipeline;
  70106. private _createDownSampleX4PostProcess;
  70107. private _createBrightPassPostProcess;
  70108. private _createBlurPostProcesses;
  70109. private _createTextureAdderPostProcess;
  70110. private _createVolumetricLightPostProcess;
  70111. private _createLuminancePostProcesses;
  70112. private _createHdrPostProcess;
  70113. private _createLensFlarePostProcess;
  70114. private _createDepthOfFieldPostProcess;
  70115. private _createMotionBlurPostProcess;
  70116. private _getDepthTexture;
  70117. private _disposePostProcesses;
  70118. /**
  70119. * Dispose of the pipeline and stop all post processes
  70120. */
  70121. dispose(): void;
  70122. /**
  70123. * Serialize the rendering pipeline (Used when exporting)
  70124. * @returns the serialized object
  70125. */
  70126. serialize(): any;
  70127. /**
  70128. * Parse the serialized pipeline
  70129. * @param source Source pipeline.
  70130. * @param scene The scene to load the pipeline to.
  70131. * @param rootUrl The URL of the serialized pipeline.
  70132. * @returns An instantiated pipeline from the serialized object.
  70133. */
  70134. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  70135. /**
  70136. * Luminance steps
  70137. */
  70138. static LuminanceSteps: number;
  70139. }
  70140. }
  70141. declare module BABYLON {
  70142. /** @hidden */
  70143. export var stereoscopicInterlacePixelShader: {
  70144. name: string;
  70145. shader: string;
  70146. };
  70147. }
  70148. declare module BABYLON {
  70149. /**
  70150. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  70151. */
  70152. export class StereoscopicInterlacePostProcessI extends PostProcess {
  70153. private _stepSize;
  70154. private _passedProcess;
  70155. /**
  70156. * Initializes a StereoscopicInterlacePostProcessI
  70157. * @param name The name of the effect.
  70158. * @param rigCameras The rig cameras to be appled to the post process
  70159. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  70160. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  70161. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70162. * @param engine The engine which the post process will be applied. (default: current engine)
  70163. * @param reusable If the post process can be reused on the same frame. (default: false)
  70164. */
  70165. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70166. }
  70167. /**
  70168. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  70169. */
  70170. export class StereoscopicInterlacePostProcess extends PostProcess {
  70171. private _stepSize;
  70172. private _passedProcess;
  70173. /**
  70174. * Initializes a StereoscopicInterlacePostProcess
  70175. * @param name The name of the effect.
  70176. * @param rigCameras The rig cameras to be appled to the post process
  70177. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  70178. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70179. * @param engine The engine which the post process will be applied. (default: current engine)
  70180. * @param reusable If the post process can be reused on the same frame. (default: false)
  70181. */
  70182. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70183. }
  70184. }
  70185. declare module BABYLON {
  70186. /** @hidden */
  70187. export var tonemapPixelShader: {
  70188. name: string;
  70189. shader: string;
  70190. };
  70191. }
  70192. declare module BABYLON {
  70193. /** Defines operator used for tonemapping */
  70194. export enum TonemappingOperator {
  70195. /** Hable */
  70196. Hable = 0,
  70197. /** Reinhard */
  70198. Reinhard = 1,
  70199. /** HejiDawson */
  70200. HejiDawson = 2,
  70201. /** Photographic */
  70202. Photographic = 3
  70203. }
  70204. /**
  70205. * Defines a post process to apply tone mapping
  70206. */
  70207. export class TonemapPostProcess extends PostProcess {
  70208. private _operator;
  70209. /** Defines the required exposure adjustement */
  70210. exposureAdjustment: number;
  70211. /**
  70212. * Creates a new TonemapPostProcess
  70213. * @param name defines the name of the postprocess
  70214. * @param _operator defines the operator to use
  70215. * @param exposureAdjustment defines the required exposure adjustement
  70216. * @param camera defines the camera to use (can be null)
  70217. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  70218. * @param engine defines the hosting engine (can be ignore if camera is set)
  70219. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  70220. */
  70221. constructor(name: string, _operator: TonemappingOperator,
  70222. /** Defines the required exposure adjustement */
  70223. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  70224. }
  70225. }
  70226. declare module BABYLON {
  70227. /** @hidden */
  70228. export var volumetricLightScatteringPixelShader: {
  70229. name: string;
  70230. shader: string;
  70231. };
  70232. }
  70233. declare module BABYLON {
  70234. /** @hidden */
  70235. export var volumetricLightScatteringPassVertexShader: {
  70236. name: string;
  70237. shader: string;
  70238. };
  70239. }
  70240. declare module BABYLON {
  70241. /** @hidden */
  70242. export var volumetricLightScatteringPassPixelShader: {
  70243. name: string;
  70244. shader: string;
  70245. };
  70246. }
  70247. declare module BABYLON {
  70248. /**
  70249. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  70250. */
  70251. export class VolumetricLightScatteringPostProcess extends PostProcess {
  70252. private _volumetricLightScatteringPass;
  70253. private _volumetricLightScatteringRTT;
  70254. private _viewPort;
  70255. private _screenCoordinates;
  70256. private _cachedDefines;
  70257. /**
  70258. * If not undefined, the mesh position is computed from the attached node position
  70259. */
  70260. attachedNode: {
  70261. position: Vector3;
  70262. };
  70263. /**
  70264. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  70265. */
  70266. customMeshPosition: Vector3;
  70267. /**
  70268. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  70269. */
  70270. useCustomMeshPosition: boolean;
  70271. /**
  70272. * If the post-process should inverse the light scattering direction
  70273. */
  70274. invert: boolean;
  70275. /**
  70276. * The internal mesh used by the post-process
  70277. */
  70278. mesh: Mesh;
  70279. /**
  70280. * @hidden
  70281. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  70282. */
  70283. get useDiffuseColor(): boolean;
  70284. set useDiffuseColor(useDiffuseColor: boolean);
  70285. /**
  70286. * Array containing the excluded meshes not rendered in the internal pass
  70287. */
  70288. excludedMeshes: AbstractMesh[];
  70289. /**
  70290. * Controls the overall intensity of the post-process
  70291. */
  70292. exposure: number;
  70293. /**
  70294. * Dissipates each sample's contribution in range [0, 1]
  70295. */
  70296. decay: number;
  70297. /**
  70298. * Controls the overall intensity of each sample
  70299. */
  70300. weight: number;
  70301. /**
  70302. * Controls the density of each sample
  70303. */
  70304. density: number;
  70305. /**
  70306. * @constructor
  70307. * @param name The post-process name
  70308. * @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)
  70309. * @param camera The camera that the post-process will be attached to
  70310. * @param mesh The mesh used to create the light scattering
  70311. * @param samples The post-process quality, default 100
  70312. * @param samplingModeThe post-process filtering mode
  70313. * @param engine The babylon engine
  70314. * @param reusable If the post-process is reusable
  70315. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  70316. */
  70317. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  70318. /**
  70319. * Returns the string "VolumetricLightScatteringPostProcess"
  70320. * @returns "VolumetricLightScatteringPostProcess"
  70321. */
  70322. getClassName(): string;
  70323. private _isReady;
  70324. /**
  70325. * Sets the new light position for light scattering effect
  70326. * @param position The new custom light position
  70327. */
  70328. setCustomMeshPosition(position: Vector3): void;
  70329. /**
  70330. * Returns the light position for light scattering effect
  70331. * @return Vector3 The custom light position
  70332. */
  70333. getCustomMeshPosition(): Vector3;
  70334. /**
  70335. * Disposes the internal assets and detaches the post-process from the camera
  70336. */
  70337. dispose(camera: Camera): void;
  70338. /**
  70339. * Returns the render target texture used by the post-process
  70340. * @return the render target texture used by the post-process
  70341. */
  70342. getPass(): RenderTargetTexture;
  70343. private _meshExcluded;
  70344. private _createPass;
  70345. private _updateMeshScreenCoordinates;
  70346. /**
  70347. * Creates a default mesh for the Volumeric Light Scattering post-process
  70348. * @param name The mesh name
  70349. * @param scene The scene where to create the mesh
  70350. * @return the default mesh
  70351. */
  70352. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  70353. }
  70354. }
  70355. declare module BABYLON {
  70356. interface Scene {
  70357. /** @hidden (Backing field) */
  70358. _boundingBoxRenderer: BoundingBoxRenderer;
  70359. /** @hidden (Backing field) */
  70360. _forceShowBoundingBoxes: boolean;
  70361. /**
  70362. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  70363. */
  70364. forceShowBoundingBoxes: boolean;
  70365. /**
  70366. * Gets the bounding box renderer associated with the scene
  70367. * @returns a BoundingBoxRenderer
  70368. */
  70369. getBoundingBoxRenderer(): BoundingBoxRenderer;
  70370. }
  70371. interface AbstractMesh {
  70372. /** @hidden (Backing field) */
  70373. _showBoundingBox: boolean;
  70374. /**
  70375. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  70376. */
  70377. showBoundingBox: boolean;
  70378. }
  70379. /**
  70380. * Component responsible of rendering the bounding box of the meshes in a scene.
  70381. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  70382. */
  70383. export class BoundingBoxRenderer implements ISceneComponent {
  70384. /**
  70385. * The component name helpfull to identify the component in the list of scene components.
  70386. */
  70387. readonly name: string;
  70388. /**
  70389. * The scene the component belongs to.
  70390. */
  70391. scene: Scene;
  70392. /**
  70393. * Color of the bounding box lines placed in front of an object
  70394. */
  70395. frontColor: Color3;
  70396. /**
  70397. * Color of the bounding box lines placed behind an object
  70398. */
  70399. backColor: Color3;
  70400. /**
  70401. * Defines if the renderer should show the back lines or not
  70402. */
  70403. showBackLines: boolean;
  70404. /**
  70405. * Observable raised before rendering a bounding box
  70406. */
  70407. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  70408. /**
  70409. * Observable raised after rendering a bounding box
  70410. */
  70411. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  70412. /**
  70413. * @hidden
  70414. */
  70415. renderList: SmartArray<BoundingBox>;
  70416. private _colorShader;
  70417. private _vertexBuffers;
  70418. private _indexBuffer;
  70419. private _fillIndexBuffer;
  70420. private _fillIndexData;
  70421. /**
  70422. * Instantiates a new bounding box renderer in a scene.
  70423. * @param scene the scene the renderer renders in
  70424. */
  70425. constructor(scene: Scene);
  70426. /**
  70427. * Registers the component in a given scene
  70428. */
  70429. register(): void;
  70430. private _evaluateSubMesh;
  70431. private _activeMesh;
  70432. private _prepareRessources;
  70433. private _createIndexBuffer;
  70434. /**
  70435. * Rebuilds the elements related to this component in case of
  70436. * context lost for instance.
  70437. */
  70438. rebuild(): void;
  70439. /**
  70440. * @hidden
  70441. */
  70442. reset(): void;
  70443. /**
  70444. * Render the bounding boxes of a specific rendering group
  70445. * @param renderingGroupId defines the rendering group to render
  70446. */
  70447. render(renderingGroupId: number): void;
  70448. /**
  70449. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70450. * @param mesh Define the mesh to render the occlusion bounding box for
  70451. */
  70452. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70453. /**
  70454. * Dispose and release the resources attached to this renderer.
  70455. */
  70456. dispose(): void;
  70457. }
  70458. }
  70459. declare module BABYLON {
  70460. interface Scene {
  70461. /** @hidden (Backing field) */
  70462. _depthRenderer: {
  70463. [id: string]: DepthRenderer;
  70464. };
  70465. /**
  70466. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70467. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70468. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70469. * @returns the created depth renderer
  70470. */
  70471. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70472. /**
  70473. * Disables a depth renderer for a given camera
  70474. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70475. */
  70476. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70477. }
  70478. /**
  70479. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70480. * in several rendering techniques.
  70481. */
  70482. export class DepthRendererSceneComponent implements ISceneComponent {
  70483. /**
  70484. * The component name helpfull to identify the component in the list of scene components.
  70485. */
  70486. readonly name: string;
  70487. /**
  70488. * The scene the component belongs to.
  70489. */
  70490. scene: Scene;
  70491. /**
  70492. * Creates a new instance of the component for the given scene
  70493. * @param scene Defines the scene to register the component in
  70494. */
  70495. constructor(scene: Scene);
  70496. /**
  70497. * Registers the component in a given scene
  70498. */
  70499. register(): void;
  70500. /**
  70501. * Rebuilds the elements related to this component in case of
  70502. * context lost for instance.
  70503. */
  70504. rebuild(): void;
  70505. /**
  70506. * Disposes the component and the associated ressources
  70507. */
  70508. dispose(): void;
  70509. private _gatherRenderTargets;
  70510. private _gatherActiveCameraRenderTargets;
  70511. }
  70512. }
  70513. declare module BABYLON {
  70514. /** @hidden */
  70515. export var outlinePixelShader: {
  70516. name: string;
  70517. shader: string;
  70518. };
  70519. }
  70520. declare module BABYLON {
  70521. /** @hidden */
  70522. export var outlineVertexShader: {
  70523. name: string;
  70524. shader: string;
  70525. };
  70526. }
  70527. declare module BABYLON {
  70528. interface Scene {
  70529. /** @hidden */
  70530. _outlineRenderer: OutlineRenderer;
  70531. /**
  70532. * Gets the outline renderer associated with the scene
  70533. * @returns a OutlineRenderer
  70534. */
  70535. getOutlineRenderer(): OutlineRenderer;
  70536. }
  70537. interface AbstractMesh {
  70538. /** @hidden (Backing field) */
  70539. _renderOutline: boolean;
  70540. /**
  70541. * Gets or sets a boolean indicating if the outline must be rendered as well
  70542. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  70543. */
  70544. renderOutline: boolean;
  70545. /** @hidden (Backing field) */
  70546. _renderOverlay: boolean;
  70547. /**
  70548. * Gets or sets a boolean indicating if the overlay must be rendered as well
  70549. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  70550. */
  70551. renderOverlay: boolean;
  70552. }
  70553. /**
  70554. * This class is responsible to draw bothe outline/overlay of meshes.
  70555. * It should not be used directly but through the available method on mesh.
  70556. */
  70557. export class OutlineRenderer implements ISceneComponent {
  70558. /**
  70559. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  70560. */
  70561. private static _StencilReference;
  70562. /**
  70563. * The name of the component. Each component must have a unique name.
  70564. */
  70565. name: string;
  70566. /**
  70567. * The scene the component belongs to.
  70568. */
  70569. scene: Scene;
  70570. /**
  70571. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  70572. */
  70573. zOffset: number;
  70574. private _engine;
  70575. private _effect;
  70576. private _cachedDefines;
  70577. private _savedDepthWrite;
  70578. /**
  70579. * Instantiates a new outline renderer. (There could be only one per scene).
  70580. * @param scene Defines the scene it belongs to
  70581. */
  70582. constructor(scene: Scene);
  70583. /**
  70584. * Register the component to one instance of a scene.
  70585. */
  70586. register(): void;
  70587. /**
  70588. * Rebuilds the elements related to this component in case of
  70589. * context lost for instance.
  70590. */
  70591. rebuild(): void;
  70592. /**
  70593. * Disposes the component and the associated ressources.
  70594. */
  70595. dispose(): void;
  70596. /**
  70597. * Renders the outline in the canvas.
  70598. * @param subMesh Defines the sumesh to render
  70599. * @param batch Defines the batch of meshes in case of instances
  70600. * @param useOverlay Defines if the rendering is for the overlay or the outline
  70601. */
  70602. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  70603. /**
  70604. * Returns whether or not the outline renderer is ready for a given submesh.
  70605. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  70606. * @param subMesh Defines the submesh to check readyness for
  70607. * @param useInstances Defines wheter wee are trying to render instances or not
  70608. * @returns true if ready otherwise false
  70609. */
  70610. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70611. private _beforeRenderingMesh;
  70612. private _afterRenderingMesh;
  70613. }
  70614. }
  70615. declare module BABYLON {
  70616. /**
  70617. * Defines the basic options interface of a Sprite Frame Source Size.
  70618. */
  70619. export interface ISpriteJSONSpriteSourceSize {
  70620. /**
  70621. * number of the original width of the Frame
  70622. */
  70623. w: number;
  70624. /**
  70625. * number of the original height of the Frame
  70626. */
  70627. h: number;
  70628. }
  70629. /**
  70630. * Defines the basic options interface of a Sprite Frame Data.
  70631. */
  70632. export interface ISpriteJSONSpriteFrameData {
  70633. /**
  70634. * number of the x offset of the Frame
  70635. */
  70636. x: number;
  70637. /**
  70638. * number of the y offset of the Frame
  70639. */
  70640. y: number;
  70641. /**
  70642. * number of the width of the Frame
  70643. */
  70644. w: number;
  70645. /**
  70646. * number of the height of the Frame
  70647. */
  70648. h: number;
  70649. }
  70650. /**
  70651. * Defines the basic options interface of a JSON Sprite.
  70652. */
  70653. export interface ISpriteJSONSprite {
  70654. /**
  70655. * string name of the Frame
  70656. */
  70657. filename: string;
  70658. /**
  70659. * ISpriteJSONSpriteFrame basic object of the frame data
  70660. */
  70661. frame: ISpriteJSONSpriteFrameData;
  70662. /**
  70663. * boolean to flag is the frame was rotated.
  70664. */
  70665. rotated: boolean;
  70666. /**
  70667. * boolean to flag is the frame was trimmed.
  70668. */
  70669. trimmed: boolean;
  70670. /**
  70671. * ISpriteJSONSpriteFrame basic object of the source data
  70672. */
  70673. spriteSourceSize: ISpriteJSONSpriteFrameData;
  70674. /**
  70675. * ISpriteJSONSpriteFrame basic object of the source data
  70676. */
  70677. sourceSize: ISpriteJSONSpriteSourceSize;
  70678. }
  70679. /**
  70680. * Defines the basic options interface of a JSON atlas.
  70681. */
  70682. export interface ISpriteJSONAtlas {
  70683. /**
  70684. * Array of objects that contain the frame data.
  70685. */
  70686. frames: Array<ISpriteJSONSprite>;
  70687. /**
  70688. * object basic object containing the sprite meta data.
  70689. */
  70690. meta?: object;
  70691. }
  70692. }
  70693. declare module BABYLON {
  70694. /** @hidden */
  70695. export var spriteMapPixelShader: {
  70696. name: string;
  70697. shader: string;
  70698. };
  70699. }
  70700. declare module BABYLON {
  70701. /** @hidden */
  70702. export var spriteMapVertexShader: {
  70703. name: string;
  70704. shader: string;
  70705. };
  70706. }
  70707. declare module BABYLON {
  70708. /**
  70709. * Defines the basic options interface of a SpriteMap
  70710. */
  70711. export interface ISpriteMapOptions {
  70712. /**
  70713. * Vector2 of the number of cells in the grid.
  70714. */
  70715. stageSize?: Vector2;
  70716. /**
  70717. * Vector2 of the size of the output plane in World Units.
  70718. */
  70719. outputSize?: Vector2;
  70720. /**
  70721. * Vector3 of the position of the output plane in World Units.
  70722. */
  70723. outputPosition?: Vector3;
  70724. /**
  70725. * Vector3 of the rotation of the output plane.
  70726. */
  70727. outputRotation?: Vector3;
  70728. /**
  70729. * number of layers that the system will reserve in resources.
  70730. */
  70731. layerCount?: number;
  70732. /**
  70733. * number of max animation frames a single cell will reserve in resources.
  70734. */
  70735. maxAnimationFrames?: number;
  70736. /**
  70737. * number cell index of the base tile when the system compiles.
  70738. */
  70739. baseTile?: number;
  70740. /**
  70741. * boolean flip the sprite after its been repositioned by the framing data.
  70742. */
  70743. flipU?: boolean;
  70744. /**
  70745. * Vector3 scalar of the global RGB values of the SpriteMap.
  70746. */
  70747. colorMultiply?: Vector3;
  70748. }
  70749. /**
  70750. * Defines the IDisposable interface in order to be cleanable from resources.
  70751. */
  70752. export interface ISpriteMap extends IDisposable {
  70753. /**
  70754. * String name of the SpriteMap.
  70755. */
  70756. name: string;
  70757. /**
  70758. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70759. */
  70760. atlasJSON: ISpriteJSONAtlas;
  70761. /**
  70762. * Texture of the SpriteMap.
  70763. */
  70764. spriteSheet: Texture;
  70765. /**
  70766. * The parameters to initialize the SpriteMap with.
  70767. */
  70768. options: ISpriteMapOptions;
  70769. }
  70770. /**
  70771. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70772. */
  70773. export class SpriteMap implements ISpriteMap {
  70774. /** The Name of the spriteMap */
  70775. name: string;
  70776. /** The JSON file with the frame and meta data */
  70777. atlasJSON: ISpriteJSONAtlas;
  70778. /** The systems Sprite Sheet Texture */
  70779. spriteSheet: Texture;
  70780. /** Arguments passed with the Constructor */
  70781. options: ISpriteMapOptions;
  70782. /** Public Sprite Storage array, parsed from atlasJSON */
  70783. sprites: Array<ISpriteJSONSprite>;
  70784. /** Returns the Number of Sprites in the System */
  70785. get spriteCount(): number;
  70786. /** Returns the Position of Output Plane*/
  70787. get position(): Vector3;
  70788. /** Returns the Position of Output Plane*/
  70789. set position(v: Vector3);
  70790. /** Returns the Rotation of Output Plane*/
  70791. get rotation(): Vector3;
  70792. /** Returns the Rotation of Output Plane*/
  70793. set rotation(v: Vector3);
  70794. /** Sets the AnimationMap*/
  70795. get animationMap(): RawTexture;
  70796. /** Sets the AnimationMap*/
  70797. set animationMap(v: RawTexture);
  70798. /** Scene that the SpriteMap was created in */
  70799. private _scene;
  70800. /** Texture Buffer of Float32 that holds tile frame data*/
  70801. private _frameMap;
  70802. /** Texture Buffers of Float32 that holds tileMap data*/
  70803. private _tileMaps;
  70804. /** Texture Buffer of Float32 that holds Animation Data*/
  70805. private _animationMap;
  70806. /** Custom ShaderMaterial Central to the System*/
  70807. private _material;
  70808. /** Custom ShaderMaterial Central to the System*/
  70809. private _output;
  70810. /** Systems Time Ticker*/
  70811. private _time;
  70812. /**
  70813. * Creates a new SpriteMap
  70814. * @param name defines the SpriteMaps Name
  70815. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70816. * @param spriteSheet is the Texture that the Sprites are on.
  70817. * @param options a basic deployment configuration
  70818. * @param scene The Scene that the map is deployed on
  70819. */
  70820. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70821. /**
  70822. * Returns tileID location
  70823. * @returns Vector2 the cell position ID
  70824. */
  70825. getTileID(): Vector2;
  70826. /**
  70827. * Gets the UV location of the mouse over the SpriteMap.
  70828. * @returns Vector2 the UV position of the mouse interaction
  70829. */
  70830. getMousePosition(): Vector2;
  70831. /**
  70832. * Creates the "frame" texture Buffer
  70833. * -------------------------------------
  70834. * Structure of frames
  70835. * "filename": "Falling-Water-2.png",
  70836. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70837. * "rotated": true,
  70838. * "trimmed": true,
  70839. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70840. * "sourceSize": {"w":32,"h":32}
  70841. * @returns RawTexture of the frameMap
  70842. */
  70843. private _createFrameBuffer;
  70844. /**
  70845. * Creates the tileMap texture Buffer
  70846. * @param buffer normally and array of numbers, or a false to generate from scratch
  70847. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70848. * @returns RawTexture of the tileMap
  70849. */
  70850. private _createTileBuffer;
  70851. /**
  70852. * Modifies the data of the tileMaps
  70853. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70854. * @param pos is the iVector2 Coordinates of the Tile
  70855. * @param tile The SpriteIndex of the new Tile
  70856. */
  70857. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70858. /**
  70859. * Creates the animationMap texture Buffer
  70860. * @param buffer normally and array of numbers, or a false to generate from scratch
  70861. * @returns RawTexture of the animationMap
  70862. */
  70863. private _createTileAnimationBuffer;
  70864. /**
  70865. * Modifies the data of the animationMap
  70866. * @param cellID is the Index of the Sprite
  70867. * @param _frame is the target Animation frame
  70868. * @param toCell is the Target Index of the next frame of the animation
  70869. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70870. * @param speed is a global scalar of the time variable on the map.
  70871. */
  70872. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70873. /**
  70874. * Exports the .tilemaps file
  70875. */
  70876. saveTileMaps(): void;
  70877. /**
  70878. * Imports the .tilemaps file
  70879. * @param url of the .tilemaps file
  70880. */
  70881. loadTileMaps(url: string): void;
  70882. /**
  70883. * Release associated resources
  70884. */
  70885. dispose(): void;
  70886. }
  70887. }
  70888. declare module BABYLON {
  70889. /**
  70890. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70891. * @see http://doc.babylonjs.com/babylon101/sprites
  70892. */
  70893. export class SpritePackedManager extends SpriteManager {
  70894. /** defines the packed manager's name */
  70895. name: string;
  70896. /**
  70897. * Creates a new sprite manager from a packed sprite sheet
  70898. * @param name defines the manager's name
  70899. * @param imgUrl defines the sprite sheet url
  70900. * @param capacity defines the maximum allowed number of sprites
  70901. * @param scene defines the hosting scene
  70902. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70903. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70904. * @param samplingMode defines the smapling mode to use with spritesheet
  70905. * @param fromPacked set to true; do not alter
  70906. */
  70907. constructor(
  70908. /** defines the packed manager's name */
  70909. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70910. }
  70911. }
  70912. declare module BABYLON {
  70913. /**
  70914. * Defines the list of states available for a task inside a AssetsManager
  70915. */
  70916. export enum AssetTaskState {
  70917. /**
  70918. * Initialization
  70919. */
  70920. INIT = 0,
  70921. /**
  70922. * Running
  70923. */
  70924. RUNNING = 1,
  70925. /**
  70926. * Done
  70927. */
  70928. DONE = 2,
  70929. /**
  70930. * Error
  70931. */
  70932. ERROR = 3
  70933. }
  70934. /**
  70935. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  70936. */
  70937. export abstract class AbstractAssetTask {
  70938. /**
  70939. * Task name
  70940. */ name: string;
  70941. /**
  70942. * Callback called when the task is successful
  70943. */
  70944. onSuccess: (task: any) => void;
  70945. /**
  70946. * Callback called when the task is not successful
  70947. */
  70948. onError: (task: any, message?: string, exception?: any) => void;
  70949. /**
  70950. * Creates a new AssetsManager
  70951. * @param name defines the name of the task
  70952. */
  70953. constructor(
  70954. /**
  70955. * Task name
  70956. */ name: string);
  70957. private _isCompleted;
  70958. private _taskState;
  70959. private _errorObject;
  70960. /**
  70961. * Get if the task is completed
  70962. */
  70963. get isCompleted(): boolean;
  70964. /**
  70965. * Gets the current state of the task
  70966. */
  70967. get taskState(): AssetTaskState;
  70968. /**
  70969. * Gets the current error object (if task is in error)
  70970. */
  70971. get errorObject(): {
  70972. message?: string;
  70973. exception?: any;
  70974. };
  70975. /**
  70976. * Internal only
  70977. * @hidden
  70978. */
  70979. _setErrorObject(message?: string, exception?: any): void;
  70980. /**
  70981. * Execute the current task
  70982. * @param scene defines the scene where you want your assets to be loaded
  70983. * @param onSuccess is a callback called when the task is successfully executed
  70984. * @param onError is a callback called if an error occurs
  70985. */
  70986. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70987. /**
  70988. * Execute the current task
  70989. * @param scene defines the scene where you want your assets to be loaded
  70990. * @param onSuccess is a callback called when the task is successfully executed
  70991. * @param onError is a callback called if an error occurs
  70992. */
  70993. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70994. /**
  70995. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  70996. * This can be used with failed tasks that have the reason for failure fixed.
  70997. */
  70998. reset(): void;
  70999. private onErrorCallback;
  71000. private onDoneCallback;
  71001. }
  71002. /**
  71003. * Define the interface used by progress events raised during assets loading
  71004. */
  71005. export interface IAssetsProgressEvent {
  71006. /**
  71007. * Defines the number of remaining tasks to process
  71008. */
  71009. remainingCount: number;
  71010. /**
  71011. * Defines the total number of tasks
  71012. */
  71013. totalCount: number;
  71014. /**
  71015. * Defines the task that was just processed
  71016. */
  71017. task: AbstractAssetTask;
  71018. }
  71019. /**
  71020. * Class used to share progress information about assets loading
  71021. */
  71022. export class AssetsProgressEvent implements IAssetsProgressEvent {
  71023. /**
  71024. * Defines the number of remaining tasks to process
  71025. */
  71026. remainingCount: number;
  71027. /**
  71028. * Defines the total number of tasks
  71029. */
  71030. totalCount: number;
  71031. /**
  71032. * Defines the task that was just processed
  71033. */
  71034. task: AbstractAssetTask;
  71035. /**
  71036. * Creates a AssetsProgressEvent
  71037. * @param remainingCount defines the number of remaining tasks to process
  71038. * @param totalCount defines the total number of tasks
  71039. * @param task defines the task that was just processed
  71040. */
  71041. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  71042. }
  71043. /**
  71044. * Define a task used by AssetsManager to load meshes
  71045. */
  71046. export class MeshAssetTask extends AbstractAssetTask {
  71047. /**
  71048. * Defines the name of the task
  71049. */
  71050. name: string;
  71051. /**
  71052. * Defines the list of mesh's names you want to load
  71053. */
  71054. meshesNames: any;
  71055. /**
  71056. * Defines the root url to use as a base to load your meshes and associated resources
  71057. */
  71058. rootUrl: string;
  71059. /**
  71060. * Defines the filename or File of the scene to load from
  71061. */
  71062. sceneFilename: string | File;
  71063. /**
  71064. * Gets the list of loaded meshes
  71065. */
  71066. loadedMeshes: Array<AbstractMesh>;
  71067. /**
  71068. * Gets the list of loaded particle systems
  71069. */
  71070. loadedParticleSystems: Array<IParticleSystem>;
  71071. /**
  71072. * Gets the list of loaded skeletons
  71073. */
  71074. loadedSkeletons: Array<Skeleton>;
  71075. /**
  71076. * Gets the list of loaded animation groups
  71077. */
  71078. loadedAnimationGroups: Array<AnimationGroup>;
  71079. /**
  71080. * Callback called when the task is successful
  71081. */
  71082. onSuccess: (task: MeshAssetTask) => void;
  71083. /**
  71084. * Callback called when the task is successful
  71085. */
  71086. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  71087. /**
  71088. * Creates a new MeshAssetTask
  71089. * @param name defines the name of the task
  71090. * @param meshesNames defines the list of mesh's names you want to load
  71091. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  71092. * @param sceneFilename defines the filename or File of the scene to load from
  71093. */
  71094. constructor(
  71095. /**
  71096. * Defines the name of the task
  71097. */
  71098. name: string,
  71099. /**
  71100. * Defines the list of mesh's names you want to load
  71101. */
  71102. meshesNames: any,
  71103. /**
  71104. * Defines the root url to use as a base to load your meshes and associated resources
  71105. */
  71106. rootUrl: string,
  71107. /**
  71108. * Defines the filename or File of the scene to load from
  71109. */
  71110. sceneFilename: string | File);
  71111. /**
  71112. * Execute the current task
  71113. * @param scene defines the scene where you want your assets to be loaded
  71114. * @param onSuccess is a callback called when the task is successfully executed
  71115. * @param onError is a callback called if an error occurs
  71116. */
  71117. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71118. }
  71119. /**
  71120. * Define a task used by AssetsManager to load text content
  71121. */
  71122. export class TextFileAssetTask extends AbstractAssetTask {
  71123. /**
  71124. * Defines the name of the task
  71125. */
  71126. name: string;
  71127. /**
  71128. * Defines the location of the file to load
  71129. */
  71130. url: string;
  71131. /**
  71132. * Gets the loaded text string
  71133. */
  71134. text: string;
  71135. /**
  71136. * Callback called when the task is successful
  71137. */
  71138. onSuccess: (task: TextFileAssetTask) => void;
  71139. /**
  71140. * Callback called when the task is successful
  71141. */
  71142. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  71143. /**
  71144. * Creates a new TextFileAssetTask object
  71145. * @param name defines the name of the task
  71146. * @param url defines the location of the file to load
  71147. */
  71148. constructor(
  71149. /**
  71150. * Defines the name of the task
  71151. */
  71152. name: string,
  71153. /**
  71154. * Defines the location of the file to load
  71155. */
  71156. url: string);
  71157. /**
  71158. * Execute the current task
  71159. * @param scene defines the scene where you want your assets to be loaded
  71160. * @param onSuccess is a callback called when the task is successfully executed
  71161. * @param onError is a callback called if an error occurs
  71162. */
  71163. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71164. }
  71165. /**
  71166. * Define a task used by AssetsManager to load binary data
  71167. */
  71168. export class BinaryFileAssetTask extends AbstractAssetTask {
  71169. /**
  71170. * Defines the name of the task
  71171. */
  71172. name: string;
  71173. /**
  71174. * Defines the location of the file to load
  71175. */
  71176. url: string;
  71177. /**
  71178. * Gets the lodaded data (as an array buffer)
  71179. */
  71180. data: ArrayBuffer;
  71181. /**
  71182. * Callback called when the task is successful
  71183. */
  71184. onSuccess: (task: BinaryFileAssetTask) => void;
  71185. /**
  71186. * Callback called when the task is successful
  71187. */
  71188. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  71189. /**
  71190. * Creates a new BinaryFileAssetTask object
  71191. * @param name defines the name of the new task
  71192. * @param url defines the location of the file to load
  71193. */
  71194. constructor(
  71195. /**
  71196. * Defines the name of the task
  71197. */
  71198. name: string,
  71199. /**
  71200. * Defines the location of the file to load
  71201. */
  71202. url: string);
  71203. /**
  71204. * Execute the current task
  71205. * @param scene defines the scene where you want your assets to be loaded
  71206. * @param onSuccess is a callback called when the task is successfully executed
  71207. * @param onError is a callback called if an error occurs
  71208. */
  71209. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71210. }
  71211. /**
  71212. * Define a task used by AssetsManager to load images
  71213. */
  71214. export class ImageAssetTask extends AbstractAssetTask {
  71215. /**
  71216. * Defines the name of the task
  71217. */
  71218. name: string;
  71219. /**
  71220. * Defines the location of the image to load
  71221. */
  71222. url: string;
  71223. /**
  71224. * Gets the loaded images
  71225. */
  71226. image: HTMLImageElement;
  71227. /**
  71228. * Callback called when the task is successful
  71229. */
  71230. onSuccess: (task: ImageAssetTask) => void;
  71231. /**
  71232. * Callback called when the task is successful
  71233. */
  71234. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  71235. /**
  71236. * Creates a new ImageAssetTask
  71237. * @param name defines the name of the task
  71238. * @param url defines the location of the image to load
  71239. */
  71240. constructor(
  71241. /**
  71242. * Defines the name of the task
  71243. */
  71244. name: string,
  71245. /**
  71246. * Defines the location of the image to load
  71247. */
  71248. url: string);
  71249. /**
  71250. * Execute the current task
  71251. * @param scene defines the scene where you want your assets to be loaded
  71252. * @param onSuccess is a callback called when the task is successfully executed
  71253. * @param onError is a callback called if an error occurs
  71254. */
  71255. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71256. }
  71257. /**
  71258. * Defines the interface used by texture loading tasks
  71259. */
  71260. export interface ITextureAssetTask<TEX extends BaseTexture> {
  71261. /**
  71262. * Gets the loaded texture
  71263. */
  71264. texture: TEX;
  71265. }
  71266. /**
  71267. * Define a task used by AssetsManager to load 2D textures
  71268. */
  71269. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  71270. /**
  71271. * Defines the name of the task
  71272. */
  71273. name: string;
  71274. /**
  71275. * Defines the location of the file to load
  71276. */
  71277. url: string;
  71278. /**
  71279. * Defines if mipmap should not be generated (default is false)
  71280. */
  71281. noMipmap?: boolean | undefined;
  71282. /**
  71283. * Defines if texture must be inverted on Y axis (default is true)
  71284. */
  71285. invertY: boolean;
  71286. /**
  71287. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71288. */
  71289. samplingMode: number;
  71290. /**
  71291. * Gets the loaded texture
  71292. */
  71293. texture: Texture;
  71294. /**
  71295. * Callback called when the task is successful
  71296. */
  71297. onSuccess: (task: TextureAssetTask) => void;
  71298. /**
  71299. * Callback called when the task is successful
  71300. */
  71301. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  71302. /**
  71303. * Creates a new TextureAssetTask object
  71304. * @param name defines the name of the task
  71305. * @param url defines the location of the file to load
  71306. * @param noMipmap defines if mipmap should not be generated (default is false)
  71307. * @param invertY defines if texture must be inverted on Y axis (default is true)
  71308. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71309. */
  71310. constructor(
  71311. /**
  71312. * Defines the name of the task
  71313. */
  71314. name: string,
  71315. /**
  71316. * Defines the location of the file to load
  71317. */
  71318. url: string,
  71319. /**
  71320. * Defines if mipmap should not be generated (default is false)
  71321. */
  71322. noMipmap?: boolean | undefined,
  71323. /**
  71324. * Defines if texture must be inverted on Y axis (default is true)
  71325. */
  71326. invertY?: boolean,
  71327. /**
  71328. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71329. */
  71330. samplingMode?: number);
  71331. /**
  71332. * Execute the current task
  71333. * @param scene defines the scene where you want your assets to be loaded
  71334. * @param onSuccess is a callback called when the task is successfully executed
  71335. * @param onError is a callback called if an error occurs
  71336. */
  71337. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71338. }
  71339. /**
  71340. * Define a task used by AssetsManager to load cube textures
  71341. */
  71342. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71343. /**
  71344. * Defines the name of the task
  71345. */
  71346. name: string;
  71347. /**
  71348. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71349. */
  71350. url: string;
  71351. /**
  71352. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71353. */
  71354. extensions?: string[] | undefined;
  71355. /**
  71356. * Defines if mipmaps should not be generated (default is false)
  71357. */
  71358. noMipmap?: boolean | undefined;
  71359. /**
  71360. * Defines the explicit list of files (undefined by default)
  71361. */
  71362. files?: string[] | undefined;
  71363. /**
  71364. * Gets the loaded texture
  71365. */
  71366. texture: CubeTexture;
  71367. /**
  71368. * Callback called when the task is successful
  71369. */
  71370. onSuccess: (task: CubeTextureAssetTask) => void;
  71371. /**
  71372. * Callback called when the task is successful
  71373. */
  71374. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71375. /**
  71376. * Creates a new CubeTextureAssetTask
  71377. * @param name defines the name of the task
  71378. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71379. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71380. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71381. * @param files defines the explicit list of files (undefined by default)
  71382. */
  71383. constructor(
  71384. /**
  71385. * Defines the name of the task
  71386. */
  71387. name: string,
  71388. /**
  71389. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71390. */
  71391. url: string,
  71392. /**
  71393. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71394. */
  71395. extensions?: string[] | undefined,
  71396. /**
  71397. * Defines if mipmaps should not be generated (default is false)
  71398. */
  71399. noMipmap?: boolean | undefined,
  71400. /**
  71401. * Defines the explicit list of files (undefined by default)
  71402. */
  71403. files?: string[] | undefined);
  71404. /**
  71405. * Execute the current task
  71406. * @param scene defines the scene where you want your assets to be loaded
  71407. * @param onSuccess is a callback called when the task is successfully executed
  71408. * @param onError is a callback called if an error occurs
  71409. */
  71410. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71411. }
  71412. /**
  71413. * Define a task used by AssetsManager to load HDR cube textures
  71414. */
  71415. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71416. /**
  71417. * Defines the name of the task
  71418. */
  71419. name: string;
  71420. /**
  71421. * Defines the location of the file to load
  71422. */
  71423. url: string;
  71424. /**
  71425. * Defines the desired size (the more it increases the longer the generation will be)
  71426. */
  71427. size: number;
  71428. /**
  71429. * Defines if mipmaps should not be generated (default is false)
  71430. */
  71431. noMipmap: boolean;
  71432. /**
  71433. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71434. */
  71435. generateHarmonics: boolean;
  71436. /**
  71437. * 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)
  71438. */
  71439. gammaSpace: boolean;
  71440. /**
  71441. * Internal Use Only
  71442. */
  71443. reserved: boolean;
  71444. /**
  71445. * Gets the loaded texture
  71446. */
  71447. texture: HDRCubeTexture;
  71448. /**
  71449. * Callback called when the task is successful
  71450. */
  71451. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  71452. /**
  71453. * Callback called when the task is successful
  71454. */
  71455. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  71456. /**
  71457. * Creates a new HDRCubeTextureAssetTask object
  71458. * @param name defines the name of the task
  71459. * @param url defines the location of the file to load
  71460. * @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.
  71461. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71462. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71463. * @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)
  71464. * @param reserved Internal use only
  71465. */
  71466. constructor(
  71467. /**
  71468. * Defines the name of the task
  71469. */
  71470. name: string,
  71471. /**
  71472. * Defines the location of the file to load
  71473. */
  71474. url: string,
  71475. /**
  71476. * Defines the desired size (the more it increases the longer the generation will be)
  71477. */
  71478. size: number,
  71479. /**
  71480. * Defines if mipmaps should not be generated (default is false)
  71481. */
  71482. noMipmap?: boolean,
  71483. /**
  71484. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71485. */
  71486. generateHarmonics?: boolean,
  71487. /**
  71488. * 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)
  71489. */
  71490. gammaSpace?: boolean,
  71491. /**
  71492. * Internal Use Only
  71493. */
  71494. reserved?: boolean);
  71495. /**
  71496. * Execute the current task
  71497. * @param scene defines the scene where you want your assets to be loaded
  71498. * @param onSuccess is a callback called when the task is successfully executed
  71499. * @param onError is a callback called if an error occurs
  71500. */
  71501. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71502. }
  71503. /**
  71504. * Define a task used by AssetsManager to load Equirectangular cube textures
  71505. */
  71506. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  71507. /**
  71508. * Defines the name of the task
  71509. */
  71510. name: string;
  71511. /**
  71512. * Defines the location of the file to load
  71513. */
  71514. url: string;
  71515. /**
  71516. * Defines the desired size (the more it increases the longer the generation will be)
  71517. */
  71518. size: number;
  71519. /**
  71520. * Defines if mipmaps should not be generated (default is false)
  71521. */
  71522. noMipmap: boolean;
  71523. /**
  71524. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71525. * but the standard material would require them in Gamma space) (default is true)
  71526. */
  71527. gammaSpace: boolean;
  71528. /**
  71529. * Gets the loaded texture
  71530. */
  71531. texture: EquiRectangularCubeTexture;
  71532. /**
  71533. * Callback called when the task is successful
  71534. */
  71535. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  71536. /**
  71537. * Callback called when the task is successful
  71538. */
  71539. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  71540. /**
  71541. * Creates a new EquiRectangularCubeTextureAssetTask object
  71542. * @param name defines the name of the task
  71543. * @param url defines the location of the file to load
  71544. * @param size defines the desired size (the more it increases the longer the generation will be)
  71545. * If the size is omitted this implies you are using a preprocessed cubemap.
  71546. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71547. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  71548. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  71549. * (default is true)
  71550. */
  71551. constructor(
  71552. /**
  71553. * Defines the name of the task
  71554. */
  71555. name: string,
  71556. /**
  71557. * Defines the location of the file to load
  71558. */
  71559. url: string,
  71560. /**
  71561. * Defines the desired size (the more it increases the longer the generation will be)
  71562. */
  71563. size: number,
  71564. /**
  71565. * Defines if mipmaps should not be generated (default is false)
  71566. */
  71567. noMipmap?: boolean,
  71568. /**
  71569. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71570. * but the standard material would require them in Gamma space) (default is true)
  71571. */
  71572. gammaSpace?: boolean);
  71573. /**
  71574. * Execute the current task
  71575. * @param scene defines the scene where you want your assets to be loaded
  71576. * @param onSuccess is a callback called when the task is successfully executed
  71577. * @param onError is a callback called if an error occurs
  71578. */
  71579. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71580. }
  71581. /**
  71582. * This class can be used to easily import assets into a scene
  71583. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  71584. */
  71585. export class AssetsManager {
  71586. private _scene;
  71587. private _isLoading;
  71588. protected _tasks: AbstractAssetTask[];
  71589. protected _waitingTasksCount: number;
  71590. protected _totalTasksCount: number;
  71591. /**
  71592. * Callback called when all tasks are processed
  71593. */
  71594. onFinish: (tasks: AbstractAssetTask[]) => void;
  71595. /**
  71596. * Callback called when a task is successful
  71597. */
  71598. onTaskSuccess: (task: AbstractAssetTask) => void;
  71599. /**
  71600. * Callback called when a task had an error
  71601. */
  71602. onTaskError: (task: AbstractAssetTask) => void;
  71603. /**
  71604. * Callback called when a task is done (whatever the result is)
  71605. */
  71606. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  71607. /**
  71608. * Observable called when all tasks are processed
  71609. */
  71610. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  71611. /**
  71612. * Observable called when a task had an error
  71613. */
  71614. onTaskErrorObservable: Observable<AbstractAssetTask>;
  71615. /**
  71616. * Observable called when all tasks were executed
  71617. */
  71618. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  71619. /**
  71620. * Observable called when a task is done (whatever the result is)
  71621. */
  71622. onProgressObservable: Observable<IAssetsProgressEvent>;
  71623. /**
  71624. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  71625. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  71626. */
  71627. useDefaultLoadingScreen: boolean;
  71628. /**
  71629. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  71630. * when all assets have been downloaded.
  71631. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  71632. */
  71633. autoHideLoadingUI: boolean;
  71634. /**
  71635. * Creates a new AssetsManager
  71636. * @param scene defines the scene to work on
  71637. */
  71638. constructor(scene: Scene);
  71639. /**
  71640. * Add a MeshAssetTask to the list of active tasks
  71641. * @param taskName defines the name of the new task
  71642. * @param meshesNames defines the name of meshes to load
  71643. * @param rootUrl defines the root url to use to locate files
  71644. * @param sceneFilename defines the filename of the scene file
  71645. * @returns a new MeshAssetTask object
  71646. */
  71647. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  71648. /**
  71649. * Add a TextFileAssetTask to the list of active tasks
  71650. * @param taskName defines the name of the new task
  71651. * @param url defines the url of the file to load
  71652. * @returns a new TextFileAssetTask object
  71653. */
  71654. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  71655. /**
  71656. * Add a BinaryFileAssetTask to the list of active tasks
  71657. * @param taskName defines the name of the new task
  71658. * @param url defines the url of the file to load
  71659. * @returns a new BinaryFileAssetTask object
  71660. */
  71661. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  71662. /**
  71663. * Add a ImageAssetTask to the list of active tasks
  71664. * @param taskName defines the name of the new task
  71665. * @param url defines the url of the file to load
  71666. * @returns a new ImageAssetTask object
  71667. */
  71668. addImageTask(taskName: string, url: string): ImageAssetTask;
  71669. /**
  71670. * Add a TextureAssetTask to the list of active tasks
  71671. * @param taskName defines the name of the new task
  71672. * @param url defines the url of the file to load
  71673. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71674. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  71675. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  71676. * @returns a new TextureAssetTask object
  71677. */
  71678. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  71679. /**
  71680. * Add a CubeTextureAssetTask to the list of active tasks
  71681. * @param taskName defines the name of the new task
  71682. * @param url defines the url of the file to load
  71683. * @param extensions defines the extension to use to load the cube map (can be null)
  71684. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71685. * @param files defines the list of files to load (can be null)
  71686. * @returns a new CubeTextureAssetTask object
  71687. */
  71688. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  71689. /**
  71690. *
  71691. * Add a HDRCubeTextureAssetTask to the list of active tasks
  71692. * @param taskName defines the name of the new task
  71693. * @param url defines the url of the file to load
  71694. * @param size defines the size you want for the cubemap (can be null)
  71695. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71696. * @param generateHarmonics defines if you want to automatically generate (true by default)
  71697. * @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)
  71698. * @param reserved Internal use only
  71699. * @returns a new HDRCubeTextureAssetTask object
  71700. */
  71701. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  71702. /**
  71703. *
  71704. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  71705. * @param taskName defines the name of the new task
  71706. * @param url defines the url of the file to load
  71707. * @param size defines the size you want for the cubemap (can be null)
  71708. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71709. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  71710. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  71711. * @returns a new EquiRectangularCubeTextureAssetTask object
  71712. */
  71713. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  71714. /**
  71715. * Remove a task from the assets manager.
  71716. * @param task the task to remove
  71717. */
  71718. removeTask(task: AbstractAssetTask): void;
  71719. private _decreaseWaitingTasksCount;
  71720. private _runTask;
  71721. /**
  71722. * Reset the AssetsManager and remove all tasks
  71723. * @return the current instance of the AssetsManager
  71724. */
  71725. reset(): AssetsManager;
  71726. /**
  71727. * Start the loading process
  71728. * @return the current instance of the AssetsManager
  71729. */
  71730. load(): AssetsManager;
  71731. /**
  71732. * Start the loading process as an async operation
  71733. * @return a promise returning the list of failed tasks
  71734. */
  71735. loadAsync(): Promise<void>;
  71736. }
  71737. }
  71738. declare module BABYLON {
  71739. /**
  71740. * Wrapper class for promise with external resolve and reject.
  71741. */
  71742. export class Deferred<T> {
  71743. /**
  71744. * The promise associated with this deferred object.
  71745. */
  71746. readonly promise: Promise<T>;
  71747. private _resolve;
  71748. private _reject;
  71749. /**
  71750. * The resolve method of the promise associated with this deferred object.
  71751. */
  71752. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71753. /**
  71754. * The reject method of the promise associated with this deferred object.
  71755. */
  71756. get reject(): (reason?: any) => void;
  71757. /**
  71758. * Constructor for this deferred object.
  71759. */
  71760. constructor();
  71761. }
  71762. }
  71763. declare module BABYLON {
  71764. /**
  71765. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71766. */
  71767. export class MeshExploder {
  71768. private _centerMesh;
  71769. private _meshes;
  71770. private _meshesOrigins;
  71771. private _toCenterVectors;
  71772. private _scaledDirection;
  71773. private _newPosition;
  71774. private _centerPosition;
  71775. /**
  71776. * Explodes meshes from a center mesh.
  71777. * @param meshes The meshes to explode.
  71778. * @param centerMesh The mesh to be center of explosion.
  71779. */
  71780. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71781. private _setCenterMesh;
  71782. /**
  71783. * Get class name
  71784. * @returns "MeshExploder"
  71785. */
  71786. getClassName(): string;
  71787. /**
  71788. * "Exploded meshes"
  71789. * @returns Array of meshes with the centerMesh at index 0.
  71790. */
  71791. getMeshes(): Array<Mesh>;
  71792. /**
  71793. * Explodes meshes giving a specific direction
  71794. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71795. */
  71796. explode(direction?: number): void;
  71797. }
  71798. }
  71799. declare module BABYLON {
  71800. /**
  71801. * Class used to help managing file picking and drag'n'drop
  71802. */
  71803. export class FilesInput {
  71804. /**
  71805. * List of files ready to be loaded
  71806. */
  71807. static get FilesToLoad(): {
  71808. [key: string]: File;
  71809. };
  71810. /**
  71811. * Callback called when a file is processed
  71812. */
  71813. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71814. private _engine;
  71815. private _currentScene;
  71816. private _sceneLoadedCallback;
  71817. private _progressCallback;
  71818. private _additionalRenderLoopLogicCallback;
  71819. private _textureLoadingCallback;
  71820. private _startingProcessingFilesCallback;
  71821. private _onReloadCallback;
  71822. private _errorCallback;
  71823. private _elementToMonitor;
  71824. private _sceneFileToLoad;
  71825. private _filesToLoad;
  71826. /**
  71827. * Creates a new FilesInput
  71828. * @param engine defines the rendering engine
  71829. * @param scene defines the hosting scene
  71830. * @param sceneLoadedCallback callback called when scene is loaded
  71831. * @param progressCallback callback called to track progress
  71832. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71833. * @param textureLoadingCallback callback called when a texture is loading
  71834. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71835. * @param onReloadCallback callback called when a reload is requested
  71836. * @param errorCallback callback call if an error occurs
  71837. */
  71838. constructor(engine: Engine, scene: Scene, sceneLoadedCallback: (sceneFile: File, scene: Scene) => void, progressCallback: (progress: ISceneLoaderProgressEvent) => void, additionalRenderLoopLogicCallback: () => void, textureLoadingCallback: (remaining: number) => void, startingProcessingFilesCallback: (files?: File[]) => void, onReloadCallback: (sceneFile: File) => void, errorCallback: (sceneFile: File, scene: Scene, message: string) => void);
  71839. private _dragEnterHandler;
  71840. private _dragOverHandler;
  71841. private _dropHandler;
  71842. /**
  71843. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71844. * @param elementToMonitor defines the DOM element to track
  71845. */
  71846. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71847. /**
  71848. * Release all associated resources
  71849. */
  71850. dispose(): void;
  71851. private renderFunction;
  71852. private drag;
  71853. private drop;
  71854. private _traverseFolder;
  71855. private _processFiles;
  71856. /**
  71857. * Load files from a drop event
  71858. * @param event defines the drop event to use as source
  71859. */
  71860. loadFiles(event: any): void;
  71861. private _processReload;
  71862. /**
  71863. * Reload the current scene from the loaded files
  71864. */
  71865. reload(): void;
  71866. }
  71867. }
  71868. declare module BABYLON {
  71869. /**
  71870. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71871. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71872. */
  71873. export class SceneOptimization {
  71874. /**
  71875. * Defines the priority of this optimization (0 by default which means first in the list)
  71876. */
  71877. priority: number;
  71878. /**
  71879. * Gets a string describing the action executed by the current optimization
  71880. * @returns description string
  71881. */
  71882. getDescription(): string;
  71883. /**
  71884. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71885. * @param scene defines the current scene where to apply this optimization
  71886. * @param optimizer defines the current optimizer
  71887. * @returns true if everything that can be done was applied
  71888. */
  71889. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71890. /**
  71891. * Creates the SceneOptimization object
  71892. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71893. * @param desc defines the description associated with the optimization
  71894. */
  71895. constructor(
  71896. /**
  71897. * Defines the priority of this optimization (0 by default which means first in the list)
  71898. */
  71899. priority?: number);
  71900. }
  71901. /**
  71902. * Defines an optimization used to reduce the size of render target textures
  71903. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71904. */
  71905. export class TextureOptimization extends SceneOptimization {
  71906. /**
  71907. * Defines the priority of this optimization (0 by default which means first in the list)
  71908. */
  71909. priority: number;
  71910. /**
  71911. * 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
  71912. */
  71913. maximumSize: number;
  71914. /**
  71915. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71916. */
  71917. step: number;
  71918. /**
  71919. * Gets a string describing the action executed by the current optimization
  71920. * @returns description string
  71921. */
  71922. getDescription(): string;
  71923. /**
  71924. * Creates the TextureOptimization object
  71925. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71926. * @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
  71927. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71928. */
  71929. constructor(
  71930. /**
  71931. * Defines the priority of this optimization (0 by default which means first in the list)
  71932. */
  71933. priority?: number,
  71934. /**
  71935. * 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
  71936. */
  71937. maximumSize?: number,
  71938. /**
  71939. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71940. */
  71941. step?: number);
  71942. /**
  71943. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71944. * @param scene defines the current scene where to apply this optimization
  71945. * @param optimizer defines the current optimizer
  71946. * @returns true if everything that can be done was applied
  71947. */
  71948. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71949. }
  71950. /**
  71951. * Defines an optimization used to increase or decrease the rendering resolution
  71952. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71953. */
  71954. export class HardwareScalingOptimization extends SceneOptimization {
  71955. /**
  71956. * Defines the priority of this optimization (0 by default which means first in the list)
  71957. */
  71958. priority: number;
  71959. /**
  71960. * Defines the maximum scale to use (2 by default)
  71961. */
  71962. maximumScale: number;
  71963. /**
  71964. * Defines the step to use between two passes (0.5 by default)
  71965. */
  71966. step: number;
  71967. private _currentScale;
  71968. private _directionOffset;
  71969. /**
  71970. * Gets a string describing the action executed by the current optimization
  71971. * @return description string
  71972. */
  71973. getDescription(): string;
  71974. /**
  71975. * Creates the HardwareScalingOptimization object
  71976. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71977. * @param maximumScale defines the maximum scale to use (2 by default)
  71978. * @param step defines the step to use between two passes (0.5 by default)
  71979. */
  71980. constructor(
  71981. /**
  71982. * Defines the priority of this optimization (0 by default which means first in the list)
  71983. */
  71984. priority?: number,
  71985. /**
  71986. * Defines the maximum scale to use (2 by default)
  71987. */
  71988. maximumScale?: number,
  71989. /**
  71990. * Defines the step to use between two passes (0.5 by default)
  71991. */
  71992. step?: number);
  71993. /**
  71994. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71995. * @param scene defines the current scene where to apply this optimization
  71996. * @param optimizer defines the current optimizer
  71997. * @returns true if everything that can be done was applied
  71998. */
  71999. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72000. }
  72001. /**
  72002. * Defines an optimization used to remove shadows
  72003. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72004. */
  72005. export class ShadowsOptimization extends SceneOptimization {
  72006. /**
  72007. * Gets a string describing the action executed by the current optimization
  72008. * @return description string
  72009. */
  72010. getDescription(): string;
  72011. /**
  72012. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72013. * @param scene defines the current scene where to apply this optimization
  72014. * @param optimizer defines the current optimizer
  72015. * @returns true if everything that can be done was applied
  72016. */
  72017. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72018. }
  72019. /**
  72020. * Defines an optimization used to turn post-processes off
  72021. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72022. */
  72023. export class PostProcessesOptimization extends SceneOptimization {
  72024. /**
  72025. * Gets a string describing the action executed by the current optimization
  72026. * @return description string
  72027. */
  72028. getDescription(): string;
  72029. /**
  72030. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72031. * @param scene defines the current scene where to apply this optimization
  72032. * @param optimizer defines the current optimizer
  72033. * @returns true if everything that can be done was applied
  72034. */
  72035. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72036. }
  72037. /**
  72038. * Defines an optimization used to turn lens flares off
  72039. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72040. */
  72041. export class LensFlaresOptimization extends SceneOptimization {
  72042. /**
  72043. * Gets a string describing the action executed by the current optimization
  72044. * @return description string
  72045. */
  72046. getDescription(): string;
  72047. /**
  72048. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72049. * @param scene defines the current scene where to apply this optimization
  72050. * @param optimizer defines the current optimizer
  72051. * @returns true if everything that can be done was applied
  72052. */
  72053. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72054. }
  72055. /**
  72056. * Defines an optimization based on user defined callback.
  72057. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72058. */
  72059. export class CustomOptimization extends SceneOptimization {
  72060. /**
  72061. * Callback called to apply the custom optimization.
  72062. */
  72063. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  72064. /**
  72065. * Callback called to get custom description
  72066. */
  72067. onGetDescription: () => string;
  72068. /**
  72069. * Gets a string describing the action executed by the current optimization
  72070. * @returns description string
  72071. */
  72072. getDescription(): string;
  72073. /**
  72074. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72075. * @param scene defines the current scene where to apply this optimization
  72076. * @param optimizer defines the current optimizer
  72077. * @returns true if everything that can be done was applied
  72078. */
  72079. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72080. }
  72081. /**
  72082. * Defines an optimization used to turn particles off
  72083. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72084. */
  72085. export class ParticlesOptimization extends SceneOptimization {
  72086. /**
  72087. * Gets a string describing the action executed by the current optimization
  72088. * @return description string
  72089. */
  72090. getDescription(): string;
  72091. /**
  72092. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72093. * @param scene defines the current scene where to apply this optimization
  72094. * @param optimizer defines the current optimizer
  72095. * @returns true if everything that can be done was applied
  72096. */
  72097. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72098. }
  72099. /**
  72100. * Defines an optimization used to turn render targets off
  72101. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72102. */
  72103. export class RenderTargetsOptimization extends SceneOptimization {
  72104. /**
  72105. * Gets a string describing the action executed by the current optimization
  72106. * @return description string
  72107. */
  72108. getDescription(): string;
  72109. /**
  72110. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72111. * @param scene defines the current scene where to apply this optimization
  72112. * @param optimizer defines the current optimizer
  72113. * @returns true if everything that can be done was applied
  72114. */
  72115. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72116. }
  72117. /**
  72118. * Defines an optimization used to merge meshes with compatible materials
  72119. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72120. */
  72121. export class MergeMeshesOptimization extends SceneOptimization {
  72122. private static _UpdateSelectionTree;
  72123. /**
  72124. * Gets or sets a boolean which defines if optimization octree has to be updated
  72125. */
  72126. static get UpdateSelectionTree(): boolean;
  72127. /**
  72128. * Gets or sets a boolean which defines if optimization octree has to be updated
  72129. */
  72130. static set UpdateSelectionTree(value: boolean);
  72131. /**
  72132. * Gets a string describing the action executed by the current optimization
  72133. * @return description string
  72134. */
  72135. getDescription(): string;
  72136. private _canBeMerged;
  72137. /**
  72138. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72139. * @param scene defines the current scene where to apply this optimization
  72140. * @param optimizer defines the current optimizer
  72141. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  72142. * @returns true if everything that can be done was applied
  72143. */
  72144. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  72145. }
  72146. /**
  72147. * Defines a list of options used by SceneOptimizer
  72148. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72149. */
  72150. export class SceneOptimizerOptions {
  72151. /**
  72152. * Defines the target frame rate to reach (60 by default)
  72153. */
  72154. targetFrameRate: number;
  72155. /**
  72156. * Defines the interval between two checkes (2000ms by default)
  72157. */
  72158. trackerDuration: number;
  72159. /**
  72160. * Gets the list of optimizations to apply
  72161. */
  72162. optimizations: SceneOptimization[];
  72163. /**
  72164. * Creates a new list of options used by SceneOptimizer
  72165. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  72166. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  72167. */
  72168. constructor(
  72169. /**
  72170. * Defines the target frame rate to reach (60 by default)
  72171. */
  72172. targetFrameRate?: number,
  72173. /**
  72174. * Defines the interval between two checkes (2000ms by default)
  72175. */
  72176. trackerDuration?: number);
  72177. /**
  72178. * Add a new optimization
  72179. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  72180. * @returns the current SceneOptimizerOptions
  72181. */
  72182. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  72183. /**
  72184. * Add a new custom optimization
  72185. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  72186. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  72187. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72188. * @returns the current SceneOptimizerOptions
  72189. */
  72190. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  72191. /**
  72192. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  72193. * @param targetFrameRate defines the target frame rate (60 by default)
  72194. * @returns a SceneOptimizerOptions object
  72195. */
  72196. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72197. /**
  72198. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  72199. * @param targetFrameRate defines the target frame rate (60 by default)
  72200. * @returns a SceneOptimizerOptions object
  72201. */
  72202. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72203. /**
  72204. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  72205. * @param targetFrameRate defines the target frame rate (60 by default)
  72206. * @returns a SceneOptimizerOptions object
  72207. */
  72208. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72209. }
  72210. /**
  72211. * Class used to run optimizations in order to reach a target frame rate
  72212. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72213. */
  72214. export class SceneOptimizer implements IDisposable {
  72215. private _isRunning;
  72216. private _options;
  72217. private _scene;
  72218. private _currentPriorityLevel;
  72219. private _targetFrameRate;
  72220. private _trackerDuration;
  72221. private _currentFrameRate;
  72222. private _sceneDisposeObserver;
  72223. private _improvementMode;
  72224. /**
  72225. * Defines an observable called when the optimizer reaches the target frame rate
  72226. */
  72227. onSuccessObservable: Observable<SceneOptimizer>;
  72228. /**
  72229. * Defines an observable called when the optimizer enables an optimization
  72230. */
  72231. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  72232. /**
  72233. * Defines an observable called when the optimizer is not able to reach the target frame rate
  72234. */
  72235. onFailureObservable: Observable<SceneOptimizer>;
  72236. /**
  72237. * Gets a boolean indicating if the optimizer is in improvement mode
  72238. */
  72239. get isInImprovementMode(): boolean;
  72240. /**
  72241. * Gets the current priority level (0 at start)
  72242. */
  72243. get currentPriorityLevel(): number;
  72244. /**
  72245. * Gets the current frame rate checked by the SceneOptimizer
  72246. */
  72247. get currentFrameRate(): number;
  72248. /**
  72249. * Gets or sets the current target frame rate (60 by default)
  72250. */
  72251. get targetFrameRate(): number;
  72252. /**
  72253. * Gets or sets the current target frame rate (60 by default)
  72254. */
  72255. set targetFrameRate(value: number);
  72256. /**
  72257. * Gets or sets the current interval between two checks (every 2000ms by default)
  72258. */
  72259. get trackerDuration(): number;
  72260. /**
  72261. * Gets or sets the current interval between two checks (every 2000ms by default)
  72262. */
  72263. set trackerDuration(value: number);
  72264. /**
  72265. * Gets the list of active optimizations
  72266. */
  72267. get optimizations(): SceneOptimization[];
  72268. /**
  72269. * Creates a new SceneOptimizer
  72270. * @param scene defines the scene to work on
  72271. * @param options defines the options to use with the SceneOptimizer
  72272. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  72273. * @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)
  72274. */
  72275. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  72276. /**
  72277. * Stops the current optimizer
  72278. */
  72279. stop(): void;
  72280. /**
  72281. * Reset the optimizer to initial step (current priority level = 0)
  72282. */
  72283. reset(): void;
  72284. /**
  72285. * Start the optimizer. By default it will try to reach a specific framerate
  72286. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  72287. */
  72288. start(): void;
  72289. private _checkCurrentState;
  72290. /**
  72291. * Release all resources
  72292. */
  72293. dispose(): void;
  72294. /**
  72295. * Helper function to create a SceneOptimizer with one single line of code
  72296. * @param scene defines the scene to work on
  72297. * @param options defines the options to use with the SceneOptimizer
  72298. * @param onSuccess defines a callback to call on success
  72299. * @param onFailure defines a callback to call on failure
  72300. * @returns the new SceneOptimizer object
  72301. */
  72302. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  72303. }
  72304. }
  72305. declare module BABYLON {
  72306. /**
  72307. * Class used to serialize a scene into a string
  72308. */
  72309. export class SceneSerializer {
  72310. /**
  72311. * Clear cache used by a previous serialization
  72312. */
  72313. static ClearCache(): void;
  72314. /**
  72315. * Serialize a scene into a JSON compatible object
  72316. * @param scene defines the scene to serialize
  72317. * @returns a JSON compatible object
  72318. */
  72319. static Serialize(scene: Scene): any;
  72320. /**
  72321. * Serialize a mesh into a JSON compatible object
  72322. * @param toSerialize defines the mesh to serialize
  72323. * @param withParents defines if parents must be serialized as well
  72324. * @param withChildren defines if children must be serialized as well
  72325. * @returns a JSON compatible object
  72326. */
  72327. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72328. }
  72329. }
  72330. declare module BABYLON {
  72331. /**
  72332. * Class used to host texture specific utilities
  72333. */
  72334. export class TextureTools {
  72335. /**
  72336. * Uses the GPU to create a copy texture rescaled at a given size
  72337. * @param texture Texture to copy from
  72338. * @param width defines the desired width
  72339. * @param height defines the desired height
  72340. * @param useBilinearMode defines if bilinear mode has to be used
  72341. * @return the generated texture
  72342. */
  72343. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72344. }
  72345. }
  72346. declare module BABYLON {
  72347. /**
  72348. * This represents the different options available for the video capture.
  72349. */
  72350. export interface VideoRecorderOptions {
  72351. /** Defines the mime type of the video. */
  72352. mimeType: string;
  72353. /** Defines the FPS the video should be recorded at. */
  72354. fps: number;
  72355. /** Defines the chunk size for the recording data. */
  72356. recordChunckSize: number;
  72357. /** The audio tracks to attach to the recording. */
  72358. audioTracks?: MediaStreamTrack[];
  72359. }
  72360. /**
  72361. * This can help with recording videos from BabylonJS.
  72362. * This is based on the available WebRTC functionalities of the browser.
  72363. *
  72364. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  72365. */
  72366. export class VideoRecorder {
  72367. private static readonly _defaultOptions;
  72368. /**
  72369. * Returns whether or not the VideoRecorder is available in your browser.
  72370. * @param engine Defines the Babylon Engine.
  72371. * @returns true if supported otherwise false.
  72372. */
  72373. static IsSupported(engine: Engine): boolean;
  72374. private readonly _options;
  72375. private _canvas;
  72376. private _mediaRecorder;
  72377. private _recordedChunks;
  72378. private _fileName;
  72379. private _resolve;
  72380. private _reject;
  72381. /**
  72382. * True when a recording is already in progress.
  72383. */
  72384. get isRecording(): boolean;
  72385. /**
  72386. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72387. * @param engine Defines the BabylonJS Engine you wish to record.
  72388. * @param options Defines options that can be used to customize the capture.
  72389. */
  72390. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72391. /**
  72392. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72393. */
  72394. stopRecording(): void;
  72395. /**
  72396. * Starts recording the canvas for a max duration specified in parameters.
  72397. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72398. * If null no automatic download will start and you can rely on the promise to get the data back.
  72399. * @param maxDuration Defines the maximum recording time in seconds.
  72400. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72401. * @return A promise callback at the end of the recording with the video data in Blob.
  72402. */
  72403. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72404. /**
  72405. * Releases internal resources used during the recording.
  72406. */
  72407. dispose(): void;
  72408. private _handleDataAvailable;
  72409. private _handleError;
  72410. private _handleStop;
  72411. }
  72412. }
  72413. declare module BABYLON {
  72414. /**
  72415. * Class containing a set of static utilities functions for screenshots
  72416. */
  72417. export class ScreenshotTools {
  72418. /**
  72419. * Captures a screenshot of the current rendering
  72420. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72421. * @param engine defines the rendering engine
  72422. * @param camera defines the source camera
  72423. * @param size This parameter can be set to a single number or to an object with the
  72424. * following (optional) properties: precision, width, height. If a single number is passed,
  72425. * it will be used for both width and height. If an object is passed, the screenshot size
  72426. * will be derived from the parameters. The precision property is a multiplier allowing
  72427. * rendering at a higher or lower resolution
  72428. * @param successCallback defines the callback receives a single parameter which contains the
  72429. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72430. * src parameter of an <img> to display it
  72431. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72432. * Check your browser for supported MIME types
  72433. */
  72434. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72435. /**
  72436. * Captures a screenshot of the current rendering
  72437. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72438. * @param engine defines the rendering engine
  72439. * @param camera defines the source camera
  72440. * @param size This parameter can be set to a single number or to an object with the
  72441. * following (optional) properties: precision, width, height. If a single number is passed,
  72442. * it will be used for both width and height. If an object is passed, the screenshot size
  72443. * will be derived from the parameters. The precision property is a multiplier allowing
  72444. * rendering at a higher or lower resolution
  72445. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72446. * Check your browser for supported MIME types
  72447. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72448. * to the src parameter of an <img> to display it
  72449. */
  72450. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  72451. /**
  72452. * Generates an image screenshot from the specified camera.
  72453. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72454. * @param engine The engine to use for rendering
  72455. * @param camera The camera to use for rendering
  72456. * @param size This parameter can be set to a single number or to an object with the
  72457. * following (optional) properties: precision, width, height. If a single number is passed,
  72458. * it will be used for both width and height. If an object is passed, the screenshot size
  72459. * will be derived from the parameters. The precision property is a multiplier allowing
  72460. * rendering at a higher or lower resolution
  72461. * @param successCallback The callback receives a single parameter which contains the
  72462. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72463. * src parameter of an <img> to display it
  72464. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72465. * Check your browser for supported MIME types
  72466. * @param samples Texture samples (default: 1)
  72467. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72468. * @param fileName A name for for the downloaded file.
  72469. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72470. */
  72471. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  72472. /**
  72473. * Generates an image screenshot from the specified camera.
  72474. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72475. * @param engine The engine to use for rendering
  72476. * @param camera The camera to use for rendering
  72477. * @param size This parameter can be set to a single number or to an object with the
  72478. * following (optional) properties: precision, width, height. If a single number is passed,
  72479. * it will be used for both width and height. If an object is passed, the screenshot size
  72480. * will be derived from the parameters. The precision property is a multiplier allowing
  72481. * rendering at a higher or lower resolution
  72482. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72483. * Check your browser for supported MIME types
  72484. * @param samples Texture samples (default: 1)
  72485. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72486. * @param fileName A name for for the downloaded file.
  72487. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72488. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72489. * to the src parameter of an <img> to display it
  72490. */
  72491. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  72492. /**
  72493. * Gets height and width for screenshot size
  72494. * @private
  72495. */
  72496. private static _getScreenshotSize;
  72497. }
  72498. }
  72499. declare module BABYLON {
  72500. /**
  72501. * Interface for a data buffer
  72502. */
  72503. export interface IDataBuffer {
  72504. /**
  72505. * Reads bytes from the data buffer.
  72506. * @param byteOffset The byte offset to read
  72507. * @param byteLength The byte length to read
  72508. * @returns A promise that resolves when the bytes are read
  72509. */
  72510. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  72511. /**
  72512. * The byte length of the buffer.
  72513. */
  72514. readonly byteLength: number;
  72515. }
  72516. /**
  72517. * Utility class for reading from a data buffer
  72518. */
  72519. export class DataReader {
  72520. /**
  72521. * The data buffer associated with this data reader.
  72522. */
  72523. readonly buffer: IDataBuffer;
  72524. /**
  72525. * The current byte offset from the beginning of the data buffer.
  72526. */
  72527. byteOffset: number;
  72528. private _dataView;
  72529. private _dataByteOffset;
  72530. /**
  72531. * Constructor
  72532. * @param buffer The buffer to read
  72533. */
  72534. constructor(buffer: IDataBuffer);
  72535. /**
  72536. * Loads the given byte length.
  72537. * @param byteLength The byte length to load
  72538. * @returns A promise that resolves when the load is complete
  72539. */
  72540. loadAsync(byteLength: number): Promise<void>;
  72541. /**
  72542. * Read a unsigned 32-bit integer from the currently loaded data range.
  72543. * @returns The 32-bit integer read
  72544. */
  72545. readUint32(): number;
  72546. /**
  72547. * Read a byte array from the currently loaded data range.
  72548. * @param byteLength The byte length to read
  72549. * @returns The byte array read
  72550. */
  72551. readUint8Array(byteLength: number): Uint8Array;
  72552. /**
  72553. * Read a string from the currently loaded data range.
  72554. * @param byteLength The byte length to read
  72555. * @returns The string read
  72556. */
  72557. readString(byteLength: number): string;
  72558. /**
  72559. * Skips the given byte length the currently loaded data range.
  72560. * @param byteLength The byte length to skip
  72561. */
  72562. skipBytes(byteLength: number): void;
  72563. }
  72564. }
  72565. declare module BABYLON {
  72566. /**
  72567. * Class for storing data to local storage if available or in-memory storage otherwise
  72568. */
  72569. export class DataStorage {
  72570. private static _Storage;
  72571. private static _GetStorage;
  72572. /**
  72573. * Reads a string from the data storage
  72574. * @param key The key to read
  72575. * @param defaultValue The value if the key doesn't exist
  72576. * @returns The string value
  72577. */
  72578. static ReadString(key: string, defaultValue: string): string;
  72579. /**
  72580. * Writes a string to the data storage
  72581. * @param key The key to write
  72582. * @param value The value to write
  72583. */
  72584. static WriteString(key: string, value: string): void;
  72585. /**
  72586. * Reads a boolean from the data storage
  72587. * @param key The key to read
  72588. * @param defaultValue The value if the key doesn't exist
  72589. * @returns The boolean value
  72590. */
  72591. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  72592. /**
  72593. * Writes a boolean to the data storage
  72594. * @param key The key to write
  72595. * @param value The value to write
  72596. */
  72597. static WriteBoolean(key: string, value: boolean): void;
  72598. /**
  72599. * Reads a number from the data storage
  72600. * @param key The key to read
  72601. * @param defaultValue The value if the key doesn't exist
  72602. * @returns The number value
  72603. */
  72604. static ReadNumber(key: string, defaultValue: number): number;
  72605. /**
  72606. * Writes a number to the data storage
  72607. * @param key The key to write
  72608. * @param value The value to write
  72609. */
  72610. static WriteNumber(key: string, value: number): void;
  72611. }
  72612. }
  72613. declare module BABYLON {
  72614. /**
  72615. * An interface for all Hit test features
  72616. */
  72617. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  72618. /**
  72619. * Triggered when new babylon (transformed) hit test results are available
  72620. */
  72621. onHitTestResultObservable: Observable<T[]>;
  72622. }
  72623. /**
  72624. * Options used for hit testing
  72625. */
  72626. export interface IWebXRLegacyHitTestOptions {
  72627. /**
  72628. * Only test when user interacted with the scene. Default - hit test every frame
  72629. */
  72630. testOnPointerDownOnly?: boolean;
  72631. /**
  72632. * The node to use to transform the local results to world coordinates
  72633. */
  72634. worldParentNode?: TransformNode;
  72635. }
  72636. /**
  72637. * Interface defining the babylon result of raycasting/hit-test
  72638. */
  72639. export interface IWebXRLegacyHitResult {
  72640. /**
  72641. * Transformation matrix that can be applied to a node that will put it in the hit point location
  72642. */
  72643. transformationMatrix: Matrix;
  72644. /**
  72645. * The native hit test result
  72646. */
  72647. xrHitResult: XRHitResult | XRHitTestResult;
  72648. }
  72649. /**
  72650. * The currently-working hit-test module.
  72651. * Hit test (or Ray-casting) is used to interact with the real world.
  72652. * For further information read here - https://github.com/immersive-web/hit-test
  72653. */
  72654. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  72655. /**
  72656. * options to use when constructing this feature
  72657. */
  72658. readonly options: IWebXRLegacyHitTestOptions;
  72659. private _direction;
  72660. private _mat;
  72661. private _onSelectEnabled;
  72662. private _origin;
  72663. /**
  72664. * The module's name
  72665. */
  72666. static readonly Name: string;
  72667. /**
  72668. * The (Babylon) version of this module.
  72669. * This is an integer representing the implementation version.
  72670. * This number does not correspond to the WebXR specs version
  72671. */
  72672. static readonly Version: number;
  72673. /**
  72674. * Populated with the last native XR Hit Results
  72675. */
  72676. lastNativeXRHitResults: XRHitResult[];
  72677. /**
  72678. * Triggered when new babylon (transformed) hit test results are available
  72679. */
  72680. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  72681. /**
  72682. * Creates a new instance of the (legacy version) hit test feature
  72683. * @param _xrSessionManager an instance of WebXRSessionManager
  72684. * @param options options to use when constructing this feature
  72685. */
  72686. constructor(_xrSessionManager: WebXRSessionManager,
  72687. /**
  72688. * options to use when constructing this feature
  72689. */
  72690. options?: IWebXRLegacyHitTestOptions);
  72691. /**
  72692. * execute a hit test with an XR Ray
  72693. *
  72694. * @param xrSession a native xrSession that will execute this hit test
  72695. * @param xrRay the ray (position and direction) to use for ray-casting
  72696. * @param referenceSpace native XR reference space to use for the hit-test
  72697. * @param filter filter function that will filter the results
  72698. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72699. */
  72700. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  72701. /**
  72702. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  72703. * @param event the (select) event to use to select with
  72704. * @param referenceSpace the reference space to use for this hit test
  72705. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72706. */
  72707. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72708. /**
  72709. * attach this feature
  72710. * Will usually be called by the features manager
  72711. *
  72712. * @returns true if successful.
  72713. */
  72714. attach(): boolean;
  72715. /**
  72716. * detach this feature.
  72717. * Will usually be called by the features manager
  72718. *
  72719. * @returns true if successful.
  72720. */
  72721. detach(): boolean;
  72722. /**
  72723. * Dispose this feature and all of the resources attached
  72724. */
  72725. dispose(): void;
  72726. protected _onXRFrame(frame: XRFrame): void;
  72727. private _onHitTestResults;
  72728. private _onSelect;
  72729. }
  72730. }
  72731. declare module BABYLON {
  72732. /**
  72733. * Options used for hit testing (version 2)
  72734. */
  72735. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  72736. /**
  72737. * Do not create a permanent hit test. Will usually be used when only
  72738. * transient inputs are needed.
  72739. */
  72740. disablePermanentHitTest?: boolean;
  72741. /**
  72742. * Enable transient (for example touch-based) hit test inspections
  72743. */
  72744. enableTransientHitTest?: boolean;
  72745. /**
  72746. * Offset ray for the permanent hit test
  72747. */
  72748. offsetRay?: Vector3;
  72749. /**
  72750. * Offset ray for the transient hit test
  72751. */
  72752. transientOffsetRay?: Vector3;
  72753. /**
  72754. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  72755. */
  72756. useReferenceSpace?: boolean;
  72757. }
  72758. /**
  72759. * Interface defining the babylon result of hit-test
  72760. */
  72761. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  72762. /**
  72763. * The input source that generated this hit test (if transient)
  72764. */
  72765. inputSource?: XRInputSource;
  72766. /**
  72767. * Is this a transient hit test
  72768. */
  72769. isTransient?: boolean;
  72770. /**
  72771. * Position of the hit test result
  72772. */
  72773. position: Vector3;
  72774. /**
  72775. * Rotation of the hit test result
  72776. */
  72777. rotationQuaternion: Quaternion;
  72778. /**
  72779. * The native hit test result
  72780. */
  72781. xrHitResult: XRHitTestResult;
  72782. }
  72783. /**
  72784. * The currently-working hit-test module.
  72785. * Hit test (or Ray-casting) is used to interact with the real world.
  72786. * For further information read here - https://github.com/immersive-web/hit-test
  72787. *
  72788. * Tested on chrome (mobile) 80.
  72789. */
  72790. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  72791. /**
  72792. * options to use when constructing this feature
  72793. */
  72794. readonly options: IWebXRHitTestOptions;
  72795. private _tmpMat;
  72796. private _tmpPos;
  72797. private _tmpQuat;
  72798. private _transientXrHitTestSource;
  72799. private _xrHitTestSource;
  72800. private initHitTestSource;
  72801. /**
  72802. * The module's name
  72803. */
  72804. static readonly Name: string;
  72805. /**
  72806. * The (Babylon) version of this module.
  72807. * This is an integer representing the implementation version.
  72808. * This number does not correspond to the WebXR specs version
  72809. */
  72810. static readonly Version: number;
  72811. /**
  72812. * When set to true, each hit test will have its own position/rotation objects
  72813. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  72814. * the developers will clone them or copy them as they see fit.
  72815. */
  72816. autoCloneTransformation: boolean;
  72817. /**
  72818. * Triggered when new babylon (transformed) hit test results are available
  72819. */
  72820. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  72821. /**
  72822. * Use this to temporarily pause hit test checks.
  72823. */
  72824. paused: boolean;
  72825. /**
  72826. * Creates a new instance of the hit test feature
  72827. * @param _xrSessionManager an instance of WebXRSessionManager
  72828. * @param options options to use when constructing this feature
  72829. */
  72830. constructor(_xrSessionManager: WebXRSessionManager,
  72831. /**
  72832. * options to use when constructing this feature
  72833. */
  72834. options?: IWebXRHitTestOptions);
  72835. /**
  72836. * attach this feature
  72837. * Will usually be called by the features manager
  72838. *
  72839. * @returns true if successful.
  72840. */
  72841. attach(): boolean;
  72842. /**
  72843. * detach this feature.
  72844. * Will usually be called by the features manager
  72845. *
  72846. * @returns true if successful.
  72847. */
  72848. detach(): boolean;
  72849. /**
  72850. * Dispose this feature and all of the resources attached
  72851. */
  72852. dispose(): void;
  72853. protected _onXRFrame(frame: XRFrame): void;
  72854. private _processWebXRHitTestResult;
  72855. }
  72856. }
  72857. declare module BABYLON {
  72858. /**
  72859. * Configuration options of the anchor system
  72860. */
  72861. export interface IWebXRAnchorSystemOptions {
  72862. /**
  72863. * a node that will be used to convert local to world coordinates
  72864. */
  72865. worldParentNode?: TransformNode;
  72866. /**
  72867. * If set to true a reference of the created anchors will be kept until the next session starts
  72868. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  72869. */
  72870. doNotRemoveAnchorsOnSessionEnded?: boolean;
  72871. }
  72872. /**
  72873. * A babylon container for an XR Anchor
  72874. */
  72875. export interface IWebXRAnchor {
  72876. /**
  72877. * A babylon-assigned ID for this anchor
  72878. */
  72879. id: number;
  72880. /**
  72881. * Transformation matrix to apply to an object attached to this anchor
  72882. */
  72883. transformationMatrix: Matrix;
  72884. /**
  72885. * The native anchor object
  72886. */
  72887. xrAnchor: XRAnchor;
  72888. /**
  72889. * if defined, this object will be constantly updated by the anchor's position and rotation
  72890. */
  72891. attachedNode?: TransformNode;
  72892. }
  72893. /**
  72894. * An implementation of the anchor system for WebXR.
  72895. * For further information see https://github.com/immersive-web/anchors/
  72896. */
  72897. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  72898. private _options;
  72899. private _lastFrameDetected;
  72900. private _trackedAnchors;
  72901. private _referenceSpaceForFrameAnchors;
  72902. private _futureAnchors;
  72903. /**
  72904. * The module's name
  72905. */
  72906. static readonly Name: string;
  72907. /**
  72908. * The (Babylon) version of this module.
  72909. * This is an integer representing the implementation version.
  72910. * This number does not correspond to the WebXR specs version
  72911. */
  72912. static readonly Version: number;
  72913. /**
  72914. * Observers registered here will be executed when a new anchor was added to the session
  72915. */
  72916. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  72917. /**
  72918. * Observers registered here will be executed when an anchor was removed from the session
  72919. */
  72920. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  72921. /**
  72922. * Observers registered here will be executed when an existing anchor updates
  72923. * This can execute N times every frame
  72924. */
  72925. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  72926. /**
  72927. * Set the reference space to use for anchor creation, when not using a hit test.
  72928. * Will default to the session's reference space if not defined
  72929. */
  72930. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  72931. /**
  72932. * constructs a new anchor system
  72933. * @param _xrSessionManager an instance of WebXRSessionManager
  72934. * @param _options configuration object for this feature
  72935. */
  72936. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  72937. private _tmpVector;
  72938. private _tmpQuaternion;
  72939. private _populateTmpTransformation;
  72940. /**
  72941. * Create a new anchor point using a hit test result at a specific point in the scene
  72942. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  72943. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  72944. *
  72945. * @param hitTestResult The hit test result to use for this anchor creation
  72946. * @param position an optional position offset for this anchor
  72947. * @param rotationQuaternion an optional rotation offset for this anchor
  72948. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  72949. */
  72950. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  72951. /**
  72952. * Add a new anchor at a specific position and rotation
  72953. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  72954. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  72955. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  72956. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  72957. *
  72958. * @param position the position in which to add an anchor
  72959. * @param rotationQuaternion an optional rotation for the anchor transformation
  72960. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  72961. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  72962. */
  72963. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  72964. /**
  72965. * detach this feature.
  72966. * Will usually be called by the features manager
  72967. *
  72968. * @returns true if successful.
  72969. */
  72970. detach(): boolean;
  72971. /**
  72972. * Dispose this feature and all of the resources attached
  72973. */
  72974. dispose(): void;
  72975. protected _onXRFrame(frame: XRFrame): void;
  72976. /**
  72977. * avoiding using Array.find for global support.
  72978. * @param xrAnchor the plane to find in the array
  72979. */
  72980. private _findIndexInAnchorArray;
  72981. private _updateAnchorWithXRFrame;
  72982. private _createAnchorAtTransformation;
  72983. }
  72984. }
  72985. declare module BABYLON {
  72986. /**
  72987. * Options used in the plane detector module
  72988. */
  72989. export interface IWebXRPlaneDetectorOptions {
  72990. /**
  72991. * The node to use to transform the local results to world coordinates
  72992. */
  72993. worldParentNode?: TransformNode;
  72994. /**
  72995. * If set to true a reference of the created planes will be kept until the next session starts
  72996. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  72997. */
  72998. doNotRemovePlanesOnSessionEnded?: boolean;
  72999. }
  73000. /**
  73001. * A babylon interface for a WebXR plane.
  73002. * A Plane is actually a polygon, built from N points in space
  73003. *
  73004. * Supported in chrome 79, not supported in canary 81 ATM
  73005. */
  73006. export interface IWebXRPlane {
  73007. /**
  73008. * a babylon-assigned ID for this polygon
  73009. */
  73010. id: number;
  73011. /**
  73012. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  73013. */
  73014. polygonDefinition: Array<Vector3>;
  73015. /**
  73016. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  73017. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  73018. */
  73019. transformationMatrix: Matrix;
  73020. /**
  73021. * the native xr-plane object
  73022. */
  73023. xrPlane: XRPlane;
  73024. }
  73025. /**
  73026. * The plane detector is used to detect planes in the real world when in AR
  73027. * For more information see https://github.com/immersive-web/real-world-geometry/
  73028. */
  73029. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  73030. private _options;
  73031. private _detectedPlanes;
  73032. private _enabled;
  73033. private _lastFrameDetected;
  73034. /**
  73035. * The module's name
  73036. */
  73037. static readonly Name: string;
  73038. /**
  73039. * The (Babylon) version of this module.
  73040. * This is an integer representing the implementation version.
  73041. * This number does not correspond to the WebXR specs version
  73042. */
  73043. static readonly Version: number;
  73044. /**
  73045. * Observers registered here will be executed when a new plane was added to the session
  73046. */
  73047. onPlaneAddedObservable: Observable<IWebXRPlane>;
  73048. /**
  73049. * Observers registered here will be executed when a plane is no longer detected in the session
  73050. */
  73051. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  73052. /**
  73053. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  73054. * This can execute N times every frame
  73055. */
  73056. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  73057. /**
  73058. * construct a new Plane Detector
  73059. * @param _xrSessionManager an instance of xr Session manager
  73060. * @param _options configuration to use when constructing this feature
  73061. */
  73062. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  73063. /**
  73064. * detach this feature.
  73065. * Will usually be called by the features manager
  73066. *
  73067. * @returns true if successful.
  73068. */
  73069. detach(): boolean;
  73070. /**
  73071. * Dispose this feature and all of the resources attached
  73072. */
  73073. dispose(): void;
  73074. protected _onXRFrame(frame: XRFrame): void;
  73075. private _init;
  73076. private _updatePlaneWithXRPlane;
  73077. /**
  73078. * avoiding using Array.find for global support.
  73079. * @param xrPlane the plane to find in the array
  73080. */
  73081. private findIndexInPlaneArray;
  73082. }
  73083. }
  73084. declare module BABYLON {
  73085. /**
  73086. * Options interface for the background remover plugin
  73087. */
  73088. export interface IWebXRBackgroundRemoverOptions {
  73089. /**
  73090. * Further background meshes to disable when entering AR
  73091. */
  73092. backgroundMeshes?: AbstractMesh[];
  73093. /**
  73094. * flags to configure the removal of the environment helper.
  73095. * If not set, the entire background will be removed. If set, flags should be set as well.
  73096. */
  73097. environmentHelperRemovalFlags?: {
  73098. /**
  73099. * Should the skybox be removed (default false)
  73100. */
  73101. skyBox?: boolean;
  73102. /**
  73103. * Should the ground be removed (default false)
  73104. */
  73105. ground?: boolean;
  73106. };
  73107. /**
  73108. * don't disable the environment helper
  73109. */
  73110. ignoreEnvironmentHelper?: boolean;
  73111. }
  73112. /**
  73113. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  73114. */
  73115. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  73116. /**
  73117. * read-only options to be used in this module
  73118. */
  73119. readonly options: IWebXRBackgroundRemoverOptions;
  73120. /**
  73121. * The module's name
  73122. */
  73123. static readonly Name: string;
  73124. /**
  73125. * The (Babylon) version of this module.
  73126. * This is an integer representing the implementation version.
  73127. * This number does not correspond to the WebXR specs version
  73128. */
  73129. static readonly Version: number;
  73130. /**
  73131. * registered observers will be triggered when the background state changes
  73132. */
  73133. onBackgroundStateChangedObservable: Observable<boolean>;
  73134. /**
  73135. * constructs a new background remover module
  73136. * @param _xrSessionManager the session manager for this module
  73137. * @param options read-only options to be used in this module
  73138. */
  73139. constructor(_xrSessionManager: WebXRSessionManager,
  73140. /**
  73141. * read-only options to be used in this module
  73142. */
  73143. options?: IWebXRBackgroundRemoverOptions);
  73144. /**
  73145. * attach this feature
  73146. * Will usually be called by the features manager
  73147. *
  73148. * @returns true if successful.
  73149. */
  73150. attach(): boolean;
  73151. /**
  73152. * detach this feature.
  73153. * Will usually be called by the features manager
  73154. *
  73155. * @returns true if successful.
  73156. */
  73157. detach(): boolean;
  73158. /**
  73159. * Dispose this feature and all of the resources attached
  73160. */
  73161. dispose(): void;
  73162. protected _onXRFrame(_xrFrame: XRFrame): void;
  73163. private _setBackgroundState;
  73164. }
  73165. }
  73166. declare module BABYLON {
  73167. /**
  73168. * Options for the controller physics feature
  73169. */
  73170. export class IWebXRControllerPhysicsOptions {
  73171. /**
  73172. * Should the headset get its own impostor
  73173. */
  73174. enableHeadsetImpostor?: boolean;
  73175. /**
  73176. * Optional parameters for the headset impostor
  73177. */
  73178. headsetImpostorParams?: {
  73179. /**
  73180. * The type of impostor to create. Default is sphere
  73181. */
  73182. impostorType: number;
  73183. /**
  73184. * the size of the impostor. Defaults to 10cm
  73185. */
  73186. impostorSize?: number | {
  73187. width: number;
  73188. height: number;
  73189. depth: number;
  73190. };
  73191. /**
  73192. * Friction definitions
  73193. */
  73194. friction?: number;
  73195. /**
  73196. * Restitution
  73197. */
  73198. restitution?: number;
  73199. };
  73200. /**
  73201. * The physics properties of the future impostors
  73202. */
  73203. physicsProperties?: {
  73204. /**
  73205. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  73206. * Note that this requires a physics engine that supports mesh impostors!
  73207. */
  73208. useControllerMesh?: boolean;
  73209. /**
  73210. * The type of impostor to create. Default is sphere
  73211. */
  73212. impostorType?: number;
  73213. /**
  73214. * the size of the impostor. Defaults to 10cm
  73215. */
  73216. impostorSize?: number | {
  73217. width: number;
  73218. height: number;
  73219. depth: number;
  73220. };
  73221. /**
  73222. * Friction definitions
  73223. */
  73224. friction?: number;
  73225. /**
  73226. * Restitution
  73227. */
  73228. restitution?: number;
  73229. };
  73230. /**
  73231. * the xr input to use with this pointer selection
  73232. */
  73233. xrInput: WebXRInput;
  73234. }
  73235. /**
  73236. * Add physics impostor to your webxr controllers,
  73237. * including naive calculation of their linear and angular velocity
  73238. */
  73239. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  73240. private readonly _options;
  73241. private _attachController;
  73242. private _controllers;
  73243. private _debugMode;
  73244. private _delta;
  73245. private _headsetImpostor?;
  73246. private _headsetMesh?;
  73247. private _lastTimestamp;
  73248. private _tmpQuaternion;
  73249. private _tmpVector;
  73250. /**
  73251. * The module's name
  73252. */
  73253. static readonly Name: string;
  73254. /**
  73255. * The (Babylon) version of this module.
  73256. * This is an integer representing the implementation version.
  73257. * This number does not correspond to the webxr specs version
  73258. */
  73259. static readonly Version: number;
  73260. /**
  73261. * Construct a new Controller Physics Feature
  73262. * @param _xrSessionManager the corresponding xr session manager
  73263. * @param _options options to create this feature with
  73264. */
  73265. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  73266. /**
  73267. * @hidden
  73268. * enable debugging - will show console outputs and the impostor mesh
  73269. */
  73270. _enablePhysicsDebug(): void;
  73271. /**
  73272. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  73273. * @param xrController the controller to add
  73274. */
  73275. addController(xrController: WebXRInputSource): void;
  73276. /**
  73277. * attach this feature
  73278. * Will usually be called by the features manager
  73279. *
  73280. * @returns true if successful.
  73281. */
  73282. attach(): boolean;
  73283. /**
  73284. * detach this feature.
  73285. * Will usually be called by the features manager
  73286. *
  73287. * @returns true if successful.
  73288. */
  73289. detach(): boolean;
  73290. /**
  73291. * Get the headset impostor, if enabled
  73292. * @returns the impostor
  73293. */
  73294. getHeadsetImpostor(): PhysicsImpostor | undefined;
  73295. /**
  73296. * Get the physics impostor of a specific controller.
  73297. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  73298. * @param controller the controller or the controller id of which to get the impostor
  73299. * @returns the impostor or null
  73300. */
  73301. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  73302. /**
  73303. * Update the physics properties provided in the constructor
  73304. * @param newProperties the new properties object
  73305. */
  73306. setPhysicsProperties(newProperties: {
  73307. impostorType?: number;
  73308. impostorSize?: number | {
  73309. width: number;
  73310. height: number;
  73311. depth: number;
  73312. };
  73313. friction?: number;
  73314. restitution?: number;
  73315. }): void;
  73316. protected _onXRFrame(_xrFrame: any): void;
  73317. private _detachController;
  73318. }
  73319. }
  73320. declare module BABYLON {
  73321. /**
  73322. * The motion controller class for all microsoft mixed reality controllers
  73323. */
  73324. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  73325. protected readonly _mapping: {
  73326. defaultButton: {
  73327. valueNodeName: string;
  73328. unpressedNodeName: string;
  73329. pressedNodeName: string;
  73330. };
  73331. defaultAxis: {
  73332. valueNodeName: string;
  73333. minNodeName: string;
  73334. maxNodeName: string;
  73335. };
  73336. buttons: {
  73337. "xr-standard-trigger": {
  73338. rootNodeName: string;
  73339. componentProperty: string;
  73340. states: string[];
  73341. };
  73342. "xr-standard-squeeze": {
  73343. rootNodeName: string;
  73344. componentProperty: string;
  73345. states: string[];
  73346. };
  73347. "xr-standard-touchpad": {
  73348. rootNodeName: string;
  73349. labelAnchorNodeName: string;
  73350. touchPointNodeName: string;
  73351. };
  73352. "xr-standard-thumbstick": {
  73353. rootNodeName: string;
  73354. componentProperty: string;
  73355. states: string[];
  73356. };
  73357. };
  73358. axes: {
  73359. "xr-standard-touchpad": {
  73360. "x-axis": {
  73361. rootNodeName: string;
  73362. };
  73363. "y-axis": {
  73364. rootNodeName: string;
  73365. };
  73366. };
  73367. "xr-standard-thumbstick": {
  73368. "x-axis": {
  73369. rootNodeName: string;
  73370. };
  73371. "y-axis": {
  73372. rootNodeName: string;
  73373. };
  73374. };
  73375. };
  73376. };
  73377. /**
  73378. * The base url used to load the left and right controller models
  73379. */
  73380. static MODEL_BASE_URL: string;
  73381. /**
  73382. * The name of the left controller model file
  73383. */
  73384. static MODEL_LEFT_FILENAME: string;
  73385. /**
  73386. * The name of the right controller model file
  73387. */
  73388. static MODEL_RIGHT_FILENAME: string;
  73389. profileId: string;
  73390. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  73391. protected _getFilenameAndPath(): {
  73392. filename: string;
  73393. path: string;
  73394. };
  73395. protected _getModelLoadingConstraints(): boolean;
  73396. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73397. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73398. protected _updateModel(): void;
  73399. }
  73400. }
  73401. declare module BABYLON {
  73402. /**
  73403. * The motion controller class for oculus touch (quest, rift).
  73404. * This class supports legacy mapping as well the standard xr mapping
  73405. */
  73406. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  73407. private _forceLegacyControllers;
  73408. private _modelRootNode;
  73409. /**
  73410. * The base url used to load the left and right controller models
  73411. */
  73412. static MODEL_BASE_URL: string;
  73413. /**
  73414. * The name of the left controller model file
  73415. */
  73416. static MODEL_LEFT_FILENAME: string;
  73417. /**
  73418. * The name of the right controller model file
  73419. */
  73420. static MODEL_RIGHT_FILENAME: string;
  73421. /**
  73422. * Base Url for the Quest controller model.
  73423. */
  73424. static QUEST_MODEL_BASE_URL: string;
  73425. profileId: string;
  73426. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  73427. protected _getFilenameAndPath(): {
  73428. filename: string;
  73429. path: string;
  73430. };
  73431. protected _getModelLoadingConstraints(): boolean;
  73432. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73433. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73434. protected _updateModel(): void;
  73435. /**
  73436. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  73437. * between the touch and touch 2.
  73438. */
  73439. private _isQuest;
  73440. }
  73441. }
  73442. declare module BABYLON {
  73443. /**
  73444. * The motion controller class for the standard HTC-Vive controllers
  73445. */
  73446. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  73447. private _modelRootNode;
  73448. /**
  73449. * The base url used to load the left and right controller models
  73450. */
  73451. static MODEL_BASE_URL: string;
  73452. /**
  73453. * File name for the controller model.
  73454. */
  73455. static MODEL_FILENAME: string;
  73456. profileId: string;
  73457. /**
  73458. * Create a new Vive motion controller object
  73459. * @param scene the scene to use to create this controller
  73460. * @param gamepadObject the corresponding gamepad object
  73461. * @param handedness the handedness of the controller
  73462. */
  73463. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  73464. protected _getFilenameAndPath(): {
  73465. filename: string;
  73466. path: string;
  73467. };
  73468. protected _getModelLoadingConstraints(): boolean;
  73469. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73470. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73471. protected _updateModel(): void;
  73472. }
  73473. }
  73474. declare module BABYLON {
  73475. /**
  73476. * A cursor which tracks a point on a path
  73477. */
  73478. export class PathCursor {
  73479. private path;
  73480. /**
  73481. * Stores path cursor callbacks for when an onchange event is triggered
  73482. */
  73483. private _onchange;
  73484. /**
  73485. * The value of the path cursor
  73486. */
  73487. value: number;
  73488. /**
  73489. * The animation array of the path cursor
  73490. */
  73491. animations: Animation[];
  73492. /**
  73493. * Initializes the path cursor
  73494. * @param path The path to track
  73495. */
  73496. constructor(path: Path2);
  73497. /**
  73498. * Gets the cursor point on the path
  73499. * @returns A point on the path cursor at the cursor location
  73500. */
  73501. getPoint(): Vector3;
  73502. /**
  73503. * Moves the cursor ahead by the step amount
  73504. * @param step The amount to move the cursor forward
  73505. * @returns This path cursor
  73506. */
  73507. moveAhead(step?: number): PathCursor;
  73508. /**
  73509. * Moves the cursor behind by the step amount
  73510. * @param step The amount to move the cursor back
  73511. * @returns This path cursor
  73512. */
  73513. moveBack(step?: number): PathCursor;
  73514. /**
  73515. * Moves the cursor by the step amount
  73516. * If the step amount is greater than one, an exception is thrown
  73517. * @param step The amount to move the cursor
  73518. * @returns This path cursor
  73519. */
  73520. move(step: number): PathCursor;
  73521. /**
  73522. * Ensures that the value is limited between zero and one
  73523. * @returns This path cursor
  73524. */
  73525. private ensureLimits;
  73526. /**
  73527. * Runs onchange callbacks on change (used by the animation engine)
  73528. * @returns This path cursor
  73529. */
  73530. private raiseOnChange;
  73531. /**
  73532. * Executes a function on change
  73533. * @param f A path cursor onchange callback
  73534. * @returns This path cursor
  73535. */
  73536. onchange(f: (cursor: PathCursor) => void): PathCursor;
  73537. }
  73538. }
  73539. declare module BABYLON {
  73540. /** @hidden */
  73541. export var blurPixelShader: {
  73542. name: string;
  73543. shader: string;
  73544. };
  73545. }
  73546. declare module BABYLON {
  73547. /** @hidden */
  73548. export var pointCloudVertexDeclaration: {
  73549. name: string;
  73550. shader: string;
  73551. };
  73552. }
  73553. // Mixins
  73554. interface Window {
  73555. mozIndexedDB: IDBFactory;
  73556. webkitIndexedDB: IDBFactory;
  73557. msIndexedDB: IDBFactory;
  73558. webkitURL: typeof URL;
  73559. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  73560. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  73561. WebGLRenderingContext: WebGLRenderingContext;
  73562. MSGesture: MSGesture;
  73563. CANNON: any;
  73564. AudioContext: AudioContext;
  73565. webkitAudioContext: AudioContext;
  73566. PointerEvent: any;
  73567. Math: Math;
  73568. Uint8Array: Uint8ArrayConstructor;
  73569. Float32Array: Float32ArrayConstructor;
  73570. mozURL: typeof URL;
  73571. msURL: typeof URL;
  73572. VRFrameData: any; // WebVR, from specs 1.1
  73573. DracoDecoderModule: any;
  73574. setImmediate(handler: (...args: any[]) => void): number;
  73575. }
  73576. interface HTMLCanvasElement {
  73577. requestPointerLock(): void;
  73578. msRequestPointerLock?(): void;
  73579. mozRequestPointerLock?(): void;
  73580. webkitRequestPointerLock?(): void;
  73581. /** Track wether a record is in progress */
  73582. isRecording: boolean;
  73583. /** Capture Stream method defined by some browsers */
  73584. captureStream(fps?: number): MediaStream;
  73585. }
  73586. interface CanvasRenderingContext2D {
  73587. msImageSmoothingEnabled: boolean;
  73588. }
  73589. interface MouseEvent {
  73590. mozMovementX: number;
  73591. mozMovementY: number;
  73592. webkitMovementX: number;
  73593. webkitMovementY: number;
  73594. msMovementX: number;
  73595. msMovementY: number;
  73596. }
  73597. interface Navigator {
  73598. mozGetVRDevices: (any: any) => any;
  73599. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  73600. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  73601. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  73602. webkitGetGamepads(): Gamepad[];
  73603. msGetGamepads(): Gamepad[];
  73604. webkitGamepads(): Gamepad[];
  73605. }
  73606. interface HTMLVideoElement {
  73607. mozSrcObject: any;
  73608. }
  73609. interface Math {
  73610. fround(x: number): number;
  73611. imul(a: number, b: number): number;
  73612. }
  73613. interface WebGLRenderingContext {
  73614. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  73615. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  73616. vertexAttribDivisor(index: number, divisor: number): void;
  73617. createVertexArray(): any;
  73618. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  73619. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  73620. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  73621. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  73622. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  73623. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  73624. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  73625. // Queries
  73626. createQuery(): WebGLQuery;
  73627. deleteQuery(query: WebGLQuery): void;
  73628. beginQuery(target: number, query: WebGLQuery): void;
  73629. endQuery(target: number): void;
  73630. getQueryParameter(query: WebGLQuery, pname: number): any;
  73631. getQuery(target: number, pname: number): any;
  73632. MAX_SAMPLES: number;
  73633. RGBA8: number;
  73634. READ_FRAMEBUFFER: number;
  73635. DRAW_FRAMEBUFFER: number;
  73636. UNIFORM_BUFFER: number;
  73637. HALF_FLOAT_OES: number;
  73638. RGBA16F: number;
  73639. RGBA32F: number;
  73640. R32F: number;
  73641. RG32F: number;
  73642. RGB32F: number;
  73643. R16F: number;
  73644. RG16F: number;
  73645. RGB16F: number;
  73646. RED: number;
  73647. RG: number;
  73648. R8: number;
  73649. RG8: number;
  73650. UNSIGNED_INT_24_8: number;
  73651. DEPTH24_STENCIL8: number;
  73652. MIN: number;
  73653. MAX: number;
  73654. /* Multiple Render Targets */
  73655. drawBuffers(buffers: number[]): void;
  73656. readBuffer(src: number): void;
  73657. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  73658. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  73659. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  73660. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  73661. // Occlusion Query
  73662. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  73663. ANY_SAMPLES_PASSED: number;
  73664. QUERY_RESULT_AVAILABLE: number;
  73665. QUERY_RESULT: number;
  73666. }
  73667. interface WebGLProgram {
  73668. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  73669. }
  73670. interface EXT_disjoint_timer_query {
  73671. QUERY_COUNTER_BITS_EXT: number;
  73672. TIME_ELAPSED_EXT: number;
  73673. TIMESTAMP_EXT: number;
  73674. GPU_DISJOINT_EXT: number;
  73675. QUERY_RESULT_EXT: number;
  73676. QUERY_RESULT_AVAILABLE_EXT: number;
  73677. queryCounterEXT(query: WebGLQuery, target: number): void;
  73678. createQueryEXT(): WebGLQuery;
  73679. beginQueryEXT(target: number, query: WebGLQuery): void;
  73680. endQueryEXT(target: number): void;
  73681. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  73682. deleteQueryEXT(query: WebGLQuery): void;
  73683. }
  73684. interface WebGLUniformLocation {
  73685. _currentState: any;
  73686. }
  73687. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  73688. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  73689. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  73690. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  73691. interface WebGLRenderingContext {
  73692. readonly RASTERIZER_DISCARD: number;
  73693. readonly DEPTH_COMPONENT24: number;
  73694. readonly TEXTURE_3D: number;
  73695. readonly TEXTURE_2D_ARRAY: number;
  73696. readonly TEXTURE_COMPARE_FUNC: number;
  73697. readonly TEXTURE_COMPARE_MODE: number;
  73698. readonly COMPARE_REF_TO_TEXTURE: number;
  73699. readonly TEXTURE_WRAP_R: number;
  73700. readonly HALF_FLOAT: number;
  73701. readonly RGB8: number;
  73702. readonly RED_INTEGER: number;
  73703. readonly RG_INTEGER: number;
  73704. readonly RGB_INTEGER: number;
  73705. readonly RGBA_INTEGER: number;
  73706. readonly R8_SNORM: number;
  73707. readonly RG8_SNORM: number;
  73708. readonly RGB8_SNORM: number;
  73709. readonly RGBA8_SNORM: number;
  73710. readonly R8I: number;
  73711. readonly RG8I: number;
  73712. readonly RGB8I: number;
  73713. readonly RGBA8I: number;
  73714. readonly R8UI: number;
  73715. readonly RG8UI: number;
  73716. readonly RGB8UI: number;
  73717. readonly RGBA8UI: number;
  73718. readonly R16I: number;
  73719. readonly RG16I: number;
  73720. readonly RGB16I: number;
  73721. readonly RGBA16I: number;
  73722. readonly R16UI: number;
  73723. readonly RG16UI: number;
  73724. readonly RGB16UI: number;
  73725. readonly RGBA16UI: number;
  73726. readonly R32I: number;
  73727. readonly RG32I: number;
  73728. readonly RGB32I: number;
  73729. readonly RGBA32I: number;
  73730. readonly R32UI: number;
  73731. readonly RG32UI: number;
  73732. readonly RGB32UI: number;
  73733. readonly RGBA32UI: number;
  73734. readonly RGB10_A2UI: number;
  73735. readonly R11F_G11F_B10F: number;
  73736. readonly RGB9_E5: number;
  73737. readonly RGB10_A2: number;
  73738. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  73739. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  73740. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  73741. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  73742. readonly DEPTH_COMPONENT32F: number;
  73743. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  73744. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  73745. 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;
  73746. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  73747. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  73748. readonly TRANSFORM_FEEDBACK: number;
  73749. readonly INTERLEAVED_ATTRIBS: number;
  73750. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  73751. createTransformFeedback(): WebGLTransformFeedback;
  73752. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  73753. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  73754. beginTransformFeedback(primitiveMode: number): void;
  73755. endTransformFeedback(): void;
  73756. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  73757. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73758. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73759. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73760. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  73761. }
  73762. interface ImageBitmap {
  73763. readonly width: number;
  73764. readonly height: number;
  73765. close(): void;
  73766. }
  73767. interface WebGLQuery extends WebGLObject {
  73768. }
  73769. declare var WebGLQuery: {
  73770. prototype: WebGLQuery;
  73771. new(): WebGLQuery;
  73772. };
  73773. interface WebGLSampler extends WebGLObject {
  73774. }
  73775. declare var WebGLSampler: {
  73776. prototype: WebGLSampler;
  73777. new(): WebGLSampler;
  73778. };
  73779. interface WebGLSync extends WebGLObject {
  73780. }
  73781. declare var WebGLSync: {
  73782. prototype: WebGLSync;
  73783. new(): WebGLSync;
  73784. };
  73785. interface WebGLTransformFeedback extends WebGLObject {
  73786. }
  73787. declare var WebGLTransformFeedback: {
  73788. prototype: WebGLTransformFeedback;
  73789. new(): WebGLTransformFeedback;
  73790. };
  73791. interface WebGLVertexArrayObject extends WebGLObject {
  73792. }
  73793. declare var WebGLVertexArrayObject: {
  73794. prototype: WebGLVertexArrayObject;
  73795. new(): WebGLVertexArrayObject;
  73796. };
  73797. // Type definitions for WebVR API
  73798. // Project: https://w3c.github.io/webvr/
  73799. // Definitions by: six a <https://github.com/lostfictions>
  73800. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  73801. interface VRDisplay extends EventTarget {
  73802. /**
  73803. * Dictionary of capabilities describing the VRDisplay.
  73804. */
  73805. readonly capabilities: VRDisplayCapabilities;
  73806. /**
  73807. * z-depth defining the far plane of the eye view frustum
  73808. * enables mapping of values in the render target depth
  73809. * attachment to scene coordinates. Initially set to 10000.0.
  73810. */
  73811. depthFar: number;
  73812. /**
  73813. * z-depth defining the near plane of the eye view frustum
  73814. * enables mapping of values in the render target depth
  73815. * attachment to scene coordinates. Initially set to 0.01.
  73816. */
  73817. depthNear: number;
  73818. /**
  73819. * An identifier for this distinct VRDisplay. Used as an
  73820. * association point in the Gamepad API.
  73821. */
  73822. readonly displayId: number;
  73823. /**
  73824. * A display name, a user-readable name identifying it.
  73825. */
  73826. readonly displayName: string;
  73827. readonly isConnected: boolean;
  73828. readonly isPresenting: boolean;
  73829. /**
  73830. * If this VRDisplay supports room-scale experiences, the optional
  73831. * stage attribute contains details on the room-scale parameters.
  73832. */
  73833. readonly stageParameters: VRStageParameters | null;
  73834. /**
  73835. * Passing the value returned by `requestAnimationFrame` to
  73836. * `cancelAnimationFrame` will unregister the callback.
  73837. * @param handle Define the hanle of the request to cancel
  73838. */
  73839. cancelAnimationFrame(handle: number): void;
  73840. /**
  73841. * Stops presenting to the VRDisplay.
  73842. * @returns a promise to know when it stopped
  73843. */
  73844. exitPresent(): Promise<void>;
  73845. /**
  73846. * Return the current VREyeParameters for the given eye.
  73847. * @param whichEye Define the eye we want the parameter for
  73848. * @returns the eye parameters
  73849. */
  73850. getEyeParameters(whichEye: string): VREyeParameters;
  73851. /**
  73852. * Populates the passed VRFrameData with the information required to render
  73853. * the current frame.
  73854. * @param frameData Define the data structure to populate
  73855. * @returns true if ok otherwise false
  73856. */
  73857. getFrameData(frameData: VRFrameData): boolean;
  73858. /**
  73859. * Get the layers currently being presented.
  73860. * @returns the list of VR layers
  73861. */
  73862. getLayers(): VRLayer[];
  73863. /**
  73864. * Return a VRPose containing the future predicted pose of the VRDisplay
  73865. * when the current frame will be presented. The value returned will not
  73866. * change until JavaScript has returned control to the browser.
  73867. *
  73868. * The VRPose will contain the position, orientation, velocity,
  73869. * and acceleration of each of these properties.
  73870. * @returns the pose object
  73871. */
  73872. getPose(): VRPose;
  73873. /**
  73874. * Return the current instantaneous pose of the VRDisplay, with no
  73875. * prediction applied.
  73876. * @returns the current instantaneous pose
  73877. */
  73878. getImmediatePose(): VRPose;
  73879. /**
  73880. * The callback passed to `requestAnimationFrame` will be called
  73881. * any time a new frame should be rendered. When the VRDisplay is
  73882. * presenting the callback will be called at the native refresh
  73883. * rate of the HMD. When not presenting this function acts
  73884. * identically to how window.requestAnimationFrame acts. Content should
  73885. * make no assumptions of frame rate or vsync behavior as the HMD runs
  73886. * asynchronously from other displays and at differing refresh rates.
  73887. * @param callback Define the eaction to run next frame
  73888. * @returns the request handle it
  73889. */
  73890. requestAnimationFrame(callback: FrameRequestCallback): number;
  73891. /**
  73892. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  73893. * Repeat calls while already presenting will update the VRLayers being displayed.
  73894. * @param layers Define the list of layer to present
  73895. * @returns a promise to know when the request has been fulfilled
  73896. */
  73897. requestPresent(layers: VRLayer[]): Promise<void>;
  73898. /**
  73899. * Reset the pose for this display, treating its current position and
  73900. * orientation as the "origin/zero" values. VRPose.position,
  73901. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  73902. * updated when calling resetPose(). This should be called in only
  73903. * sitting-space experiences.
  73904. */
  73905. resetPose(): void;
  73906. /**
  73907. * The VRLayer provided to the VRDisplay will be captured and presented
  73908. * in the HMD. Calling this function has the same effect on the source
  73909. * canvas as any other operation that uses its source image, and canvases
  73910. * created without preserveDrawingBuffer set to true will be cleared.
  73911. * @param pose Define the pose to submit
  73912. */
  73913. submitFrame(pose?: VRPose): void;
  73914. }
  73915. declare var VRDisplay: {
  73916. prototype: VRDisplay;
  73917. new(): VRDisplay;
  73918. };
  73919. interface VRLayer {
  73920. leftBounds?: number[] | Float32Array | null;
  73921. rightBounds?: number[] | Float32Array | null;
  73922. source?: HTMLCanvasElement | null;
  73923. }
  73924. interface VRDisplayCapabilities {
  73925. readonly canPresent: boolean;
  73926. readonly hasExternalDisplay: boolean;
  73927. readonly hasOrientation: boolean;
  73928. readonly hasPosition: boolean;
  73929. readonly maxLayers: number;
  73930. }
  73931. interface VREyeParameters {
  73932. /** @deprecated */
  73933. readonly fieldOfView: VRFieldOfView;
  73934. readonly offset: Float32Array;
  73935. readonly renderHeight: number;
  73936. readonly renderWidth: number;
  73937. }
  73938. interface VRFieldOfView {
  73939. readonly downDegrees: number;
  73940. readonly leftDegrees: number;
  73941. readonly rightDegrees: number;
  73942. readonly upDegrees: number;
  73943. }
  73944. interface VRFrameData {
  73945. readonly leftProjectionMatrix: Float32Array;
  73946. readonly leftViewMatrix: Float32Array;
  73947. readonly pose: VRPose;
  73948. readonly rightProjectionMatrix: Float32Array;
  73949. readonly rightViewMatrix: Float32Array;
  73950. readonly timestamp: number;
  73951. }
  73952. interface VRPose {
  73953. readonly angularAcceleration: Float32Array | null;
  73954. readonly angularVelocity: Float32Array | null;
  73955. readonly linearAcceleration: Float32Array | null;
  73956. readonly linearVelocity: Float32Array | null;
  73957. readonly orientation: Float32Array | null;
  73958. readonly position: Float32Array | null;
  73959. readonly timestamp: number;
  73960. }
  73961. interface VRStageParameters {
  73962. sittingToStandingTransform?: Float32Array;
  73963. sizeX?: number;
  73964. sizeY?: number;
  73965. }
  73966. interface Navigator {
  73967. getVRDisplays(): Promise<VRDisplay[]>;
  73968. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  73969. }
  73970. interface Window {
  73971. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  73972. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  73973. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  73974. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  73975. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  73976. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  73977. }
  73978. interface Gamepad {
  73979. readonly displayId: number;
  73980. }
  73981. type XRSessionMode =
  73982. | "inline"
  73983. | "immersive-vr"
  73984. | "immersive-ar";
  73985. type XRReferenceSpaceType =
  73986. | "viewer"
  73987. | "local"
  73988. | "local-floor"
  73989. | "bounded-floor"
  73990. | "unbounded";
  73991. type XREnvironmentBlendMode =
  73992. | "opaque"
  73993. | "additive"
  73994. | "alpha-blend";
  73995. type XRVisibilityState =
  73996. | "visible"
  73997. | "visible-blurred"
  73998. | "hidden";
  73999. type XRHandedness =
  74000. | "none"
  74001. | "left"
  74002. | "right";
  74003. type XRTargetRayMode =
  74004. | "gaze"
  74005. | "tracked-pointer"
  74006. | "screen";
  74007. type XREye =
  74008. | "none"
  74009. | "left"
  74010. | "right";
  74011. type XREventType =
  74012. | "devicechange"
  74013. | "visibilitychange"
  74014. | "end"
  74015. | "inputsourceschange"
  74016. | "select"
  74017. | "selectstart"
  74018. | "selectend"
  74019. | "squeeze"
  74020. | "squeezestart"
  74021. | "squeezeend"
  74022. | "reset";
  74023. interface XRSpace extends EventTarget {
  74024. }
  74025. interface XRRenderState {
  74026. depthNear?: number;
  74027. depthFar?: number;
  74028. inlineVerticalFieldOfView?: number;
  74029. baseLayer?: XRWebGLLayer;
  74030. }
  74031. interface XRInputSource {
  74032. handedness: XRHandedness;
  74033. targetRayMode: XRTargetRayMode;
  74034. targetRaySpace: XRSpace;
  74035. gripSpace: XRSpace | undefined;
  74036. gamepad: Gamepad | undefined;
  74037. profiles: Array<string>;
  74038. }
  74039. interface XRSessionInit {
  74040. optionalFeatures?: string[];
  74041. requiredFeatures?: string[];
  74042. }
  74043. interface XRSession {
  74044. addEventListener: Function;
  74045. removeEventListener: Function;
  74046. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  74047. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  74048. requestAnimationFrame: Function;
  74049. end(): Promise<void>;
  74050. renderState: XRRenderState;
  74051. inputSources: Array<XRInputSource>;
  74052. // hit test
  74053. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  74054. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  74055. // legacy AR hit test
  74056. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  74057. // legacy plane detection
  74058. updateWorldTrackingState(options: {
  74059. planeDetectionState?: { enabled: boolean; }
  74060. }): void;
  74061. }
  74062. interface XRReferenceSpace extends XRSpace {
  74063. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  74064. onreset: any;
  74065. }
  74066. type XRPlaneSet = Set<XRPlane>;
  74067. type XRAnchorSet = Set<XRAnchor>;
  74068. interface XRFrame {
  74069. session: XRSession;
  74070. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  74071. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  74072. // AR
  74073. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  74074. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  74075. // Anchors
  74076. trackedAnchors?: XRAnchorSet;
  74077. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  74078. // Planes
  74079. worldInformation: {
  74080. detectedPlanes?: XRPlaneSet;
  74081. };
  74082. }
  74083. interface XRViewerPose extends XRPose {
  74084. views: Array<XRView>;
  74085. }
  74086. interface XRPose {
  74087. transform: XRRigidTransform;
  74088. emulatedPosition: boolean;
  74089. }
  74090. interface XRWebGLLayerOptions {
  74091. antialias?: boolean;
  74092. depth?: boolean;
  74093. stencil?: boolean;
  74094. alpha?: boolean;
  74095. multiview?: boolean;
  74096. framebufferScaleFactor?: number;
  74097. }
  74098. declare var XRWebGLLayer: {
  74099. prototype: XRWebGLLayer;
  74100. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  74101. };
  74102. interface XRWebGLLayer {
  74103. framebuffer: WebGLFramebuffer;
  74104. framebufferWidth: number;
  74105. framebufferHeight: number;
  74106. getViewport: Function;
  74107. }
  74108. declare class XRRigidTransform {
  74109. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  74110. position: DOMPointReadOnly;
  74111. orientation: DOMPointReadOnly;
  74112. matrix: Float32Array;
  74113. inverse: XRRigidTransform;
  74114. }
  74115. interface XRView {
  74116. eye: XREye;
  74117. projectionMatrix: Float32Array;
  74118. transform: XRRigidTransform;
  74119. }
  74120. interface XRInputSourceChangeEvent {
  74121. session: XRSession;
  74122. removed: Array<XRInputSource>;
  74123. added: Array<XRInputSource>;
  74124. }
  74125. interface XRInputSourceEvent extends Event {
  74126. readonly frame: XRFrame;
  74127. readonly inputSource: XRInputSource;
  74128. }
  74129. // Experimental(er) features
  74130. declare class XRRay {
  74131. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  74132. origin: DOMPointReadOnly;
  74133. direction: DOMPointReadOnly;
  74134. matrix: Float32Array;
  74135. }
  74136. declare enum XRHitTestTrackableType {
  74137. "point",
  74138. "plane"
  74139. }
  74140. interface XRHitResult {
  74141. hitMatrix: Float32Array;
  74142. }
  74143. interface XRTransientInputHitTestResult {
  74144. readonly inputSource: XRInputSource;
  74145. readonly results: Array<XRHitTestResult>;
  74146. }
  74147. interface XRHitTestResult {
  74148. getPose(baseSpace: XRSpace): XRPose | undefined;
  74149. // When anchor system is enabled
  74150. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  74151. }
  74152. interface XRHitTestSource {
  74153. cancel(): void;
  74154. }
  74155. interface XRTransientInputHitTestSource {
  74156. cancel(): void;
  74157. }
  74158. interface XRHitTestOptionsInit {
  74159. space: XRSpace;
  74160. entityTypes?: Array<XRHitTestTrackableType>;
  74161. offsetRay?: XRRay;
  74162. }
  74163. interface XRTransientInputHitTestOptionsInit {
  74164. profile: string;
  74165. entityTypes?: Array<XRHitTestTrackableType>;
  74166. offsetRay?: XRRay;
  74167. }
  74168. interface XRAnchor {
  74169. anchorSpace: XRSpace;
  74170. delete(): void;
  74171. }
  74172. interface XRPlane {
  74173. orientation: "Horizontal" | "Vertical";
  74174. planeSpace: XRSpace;
  74175. polygon: Array<DOMPointReadOnly>;
  74176. lastChangedTime: number;
  74177. }
  74178. /**
  74179. * @ignore
  74180. */
  74181. declare module BABYLON.GLTF2.Exporter {
  74182. }
  74183. /**
  74184. * @ignore
  74185. */
  74186. declare module BABYLON.GLTF1 {
  74187. }
  74188. declare module BABYLON.GUI {
  74189. /**
  74190. * Class used to specific a value and its associated unit
  74191. */
  74192. export class ValueAndUnit {
  74193. /** defines the unit to store */
  74194. unit: number;
  74195. /** defines a boolean indicating if the value can be negative */
  74196. negativeValueAllowed: boolean;
  74197. private _value;
  74198. private _originalUnit;
  74199. /**
  74200. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  74201. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74202. */
  74203. ignoreAdaptiveScaling: boolean;
  74204. /**
  74205. * Creates a new ValueAndUnit
  74206. * @param value defines the value to store
  74207. * @param unit defines the unit to store
  74208. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  74209. */
  74210. constructor(value: number,
  74211. /** defines the unit to store */
  74212. unit?: number,
  74213. /** defines a boolean indicating if the value can be negative */
  74214. negativeValueAllowed?: boolean);
  74215. /** Gets a boolean indicating if the value is a percentage */
  74216. get isPercentage(): boolean;
  74217. /** Gets a boolean indicating if the value is store as pixel */
  74218. get isPixel(): boolean;
  74219. /** Gets direct internal value */
  74220. get internalValue(): number;
  74221. /**
  74222. * Gets value as pixel
  74223. * @param host defines the root host
  74224. * @param refValue defines the reference value for percentages
  74225. * @returns the value as pixel
  74226. */
  74227. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  74228. /**
  74229. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  74230. * @param value defines the value to store
  74231. * @param unit defines the unit to store
  74232. * @returns the current ValueAndUnit
  74233. */
  74234. updateInPlace(value: number, unit?: number): ValueAndUnit;
  74235. /**
  74236. * Gets the value accordingly to its unit
  74237. * @param host defines the root host
  74238. * @returns the value
  74239. */
  74240. getValue(host: AdvancedDynamicTexture): number;
  74241. /**
  74242. * Gets a string representation of the value
  74243. * @param host defines the root host
  74244. * @param decimals defines an optional number of decimals to display
  74245. * @returns a string
  74246. */
  74247. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  74248. /**
  74249. * Store a value parsed from a string
  74250. * @param source defines the source string
  74251. * @returns true if the value was successfully parsed
  74252. */
  74253. fromString(source: string | number): boolean;
  74254. private static _Regex;
  74255. private static _UNITMODE_PERCENTAGE;
  74256. private static _UNITMODE_PIXEL;
  74257. /** UNITMODE_PERCENTAGE */
  74258. static get UNITMODE_PERCENTAGE(): number;
  74259. /** UNITMODE_PIXEL */
  74260. static get UNITMODE_PIXEL(): number;
  74261. }
  74262. }
  74263. declare module BABYLON.GUI {
  74264. /**
  74265. * Define a style used by control to automatically setup properties based on a template.
  74266. * Only support font related properties so far
  74267. */
  74268. export class Style implements BABYLON.IDisposable {
  74269. private _fontFamily;
  74270. private _fontStyle;
  74271. private _fontWeight;
  74272. /** @hidden */
  74273. _host: AdvancedDynamicTexture;
  74274. /** @hidden */
  74275. _fontSize: ValueAndUnit;
  74276. /**
  74277. * BABYLON.Observable raised when the style values are changed
  74278. */
  74279. onChangedObservable: BABYLON.Observable<Style>;
  74280. /**
  74281. * Creates a new style object
  74282. * @param host defines the AdvancedDynamicTexture which hosts this style
  74283. */
  74284. constructor(host: AdvancedDynamicTexture);
  74285. /**
  74286. * Gets or sets the font size
  74287. */
  74288. get fontSize(): string | number;
  74289. set fontSize(value: string | number);
  74290. /**
  74291. * Gets or sets the font family
  74292. */
  74293. get fontFamily(): string;
  74294. set fontFamily(value: string);
  74295. /**
  74296. * Gets or sets the font style
  74297. */
  74298. get fontStyle(): string;
  74299. set fontStyle(value: string);
  74300. /** Gets or sets font weight */
  74301. get fontWeight(): string;
  74302. set fontWeight(value: string);
  74303. /** Dispose all associated resources */
  74304. dispose(): void;
  74305. }
  74306. }
  74307. declare module BABYLON.GUI {
  74308. /**
  74309. * Class used to transport BABYLON.Vector2 information for pointer events
  74310. */
  74311. export class Vector2WithInfo extends BABYLON.Vector2 {
  74312. /** defines the current mouse button index */
  74313. buttonIndex: number;
  74314. /**
  74315. * Creates a new Vector2WithInfo
  74316. * @param source defines the vector2 data to transport
  74317. * @param buttonIndex defines the current mouse button index
  74318. */
  74319. constructor(source: BABYLON.Vector2,
  74320. /** defines the current mouse button index */
  74321. buttonIndex?: number);
  74322. }
  74323. /** Class used to provide 2D matrix features */
  74324. export class Matrix2D {
  74325. /** Gets the internal array of 6 floats used to store matrix data */
  74326. m: Float32Array;
  74327. /**
  74328. * Creates a new matrix
  74329. * @param m00 defines value for (0, 0)
  74330. * @param m01 defines value for (0, 1)
  74331. * @param m10 defines value for (1, 0)
  74332. * @param m11 defines value for (1, 1)
  74333. * @param m20 defines value for (2, 0)
  74334. * @param m21 defines value for (2, 1)
  74335. */
  74336. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  74337. /**
  74338. * Fills the matrix from direct values
  74339. * @param m00 defines value for (0, 0)
  74340. * @param m01 defines value for (0, 1)
  74341. * @param m10 defines value for (1, 0)
  74342. * @param m11 defines value for (1, 1)
  74343. * @param m20 defines value for (2, 0)
  74344. * @param m21 defines value for (2, 1)
  74345. * @returns the current modified matrix
  74346. */
  74347. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  74348. /**
  74349. * Gets matrix determinant
  74350. * @returns the determinant
  74351. */
  74352. determinant(): number;
  74353. /**
  74354. * Inverses the matrix and stores it in a target matrix
  74355. * @param result defines the target matrix
  74356. * @returns the current matrix
  74357. */
  74358. invertToRef(result: Matrix2D): Matrix2D;
  74359. /**
  74360. * Multiplies the current matrix with another one
  74361. * @param other defines the second operand
  74362. * @param result defines the target matrix
  74363. * @returns the current matrix
  74364. */
  74365. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  74366. /**
  74367. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  74368. * @param x defines the x coordinate to transform
  74369. * @param y defines the x coordinate to transform
  74370. * @param result defines the target vector2
  74371. * @returns the current matrix
  74372. */
  74373. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  74374. /**
  74375. * Creates an identity matrix
  74376. * @returns a new matrix
  74377. */
  74378. static Identity(): Matrix2D;
  74379. /**
  74380. * Creates a translation matrix and stores it in a target matrix
  74381. * @param x defines the x coordinate of the translation
  74382. * @param y defines the y coordinate of the translation
  74383. * @param result defines the target matrix
  74384. */
  74385. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  74386. /**
  74387. * Creates a scaling matrix and stores it in a target matrix
  74388. * @param x defines the x coordinate of the scaling
  74389. * @param y defines the y coordinate of the scaling
  74390. * @param result defines the target matrix
  74391. */
  74392. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  74393. /**
  74394. * Creates a rotation matrix and stores it in a target matrix
  74395. * @param angle defines the rotation angle
  74396. * @param result defines the target matrix
  74397. */
  74398. static RotationToRef(angle: number, result: Matrix2D): void;
  74399. private static _TempPreTranslationMatrix;
  74400. private static _TempPostTranslationMatrix;
  74401. private static _TempRotationMatrix;
  74402. private static _TempScalingMatrix;
  74403. private static _TempCompose0;
  74404. private static _TempCompose1;
  74405. private static _TempCompose2;
  74406. /**
  74407. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  74408. * @param tx defines the x coordinate of the translation
  74409. * @param ty defines the y coordinate of the translation
  74410. * @param angle defines the rotation angle
  74411. * @param scaleX defines the x coordinate of the scaling
  74412. * @param scaleY defines the y coordinate of the scaling
  74413. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  74414. * @param result defines the target matrix
  74415. */
  74416. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  74417. }
  74418. }
  74419. declare module BABYLON.GUI {
  74420. /**
  74421. * Class used to store 2D control sizes
  74422. */
  74423. export class Measure {
  74424. /** defines left coordinate */
  74425. left: number;
  74426. /** defines top coordinate */
  74427. top: number;
  74428. /** defines width dimension */
  74429. width: number;
  74430. /** defines height dimension */
  74431. height: number;
  74432. /**
  74433. * Creates a new measure
  74434. * @param left defines left coordinate
  74435. * @param top defines top coordinate
  74436. * @param width defines width dimension
  74437. * @param height defines height dimension
  74438. */
  74439. constructor(
  74440. /** defines left coordinate */
  74441. left: number,
  74442. /** defines top coordinate */
  74443. top: number,
  74444. /** defines width dimension */
  74445. width: number,
  74446. /** defines height dimension */
  74447. height: number);
  74448. /**
  74449. * Copy from another measure
  74450. * @param other defines the other measure to copy from
  74451. */
  74452. copyFrom(other: Measure): void;
  74453. /**
  74454. * Copy from a group of 4 floats
  74455. * @param left defines left coordinate
  74456. * @param top defines top coordinate
  74457. * @param width defines width dimension
  74458. * @param height defines height dimension
  74459. */
  74460. copyFromFloats(left: number, top: number, width: number, height: number): void;
  74461. /**
  74462. * Computes the axis aligned bounding box measure for two given measures
  74463. * @param a Input measure
  74464. * @param b Input measure
  74465. * @param result the resulting bounding measure
  74466. */
  74467. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  74468. /**
  74469. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  74470. * @param transform the matrix to transform the measure before computing the AABB
  74471. * @param result the resulting AABB
  74472. */
  74473. transformToRef(transform: Matrix2D, result: Measure): void;
  74474. /**
  74475. * Check equality between this measure and another one
  74476. * @param other defines the other measures
  74477. * @returns true if both measures are equals
  74478. */
  74479. isEqualsTo(other: Measure): boolean;
  74480. /**
  74481. * Creates an empty measure
  74482. * @returns a new measure
  74483. */
  74484. static Empty(): Measure;
  74485. }
  74486. }
  74487. declare module BABYLON.GUI {
  74488. /**
  74489. * Interface used to define a control that can receive focus
  74490. */
  74491. export interface IFocusableControl {
  74492. /**
  74493. * Function called when the control receives the focus
  74494. */
  74495. onFocus(): void;
  74496. /**
  74497. * Function called when the control loses the focus
  74498. */
  74499. onBlur(): void;
  74500. /**
  74501. * Function called to let the control handle keyboard events
  74502. * @param evt defines the current keyboard event
  74503. */
  74504. processKeyboard(evt: KeyboardEvent): void;
  74505. /**
  74506. * Function called to get the list of controls that should not steal the focus from this control
  74507. * @returns an array of controls
  74508. */
  74509. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  74510. }
  74511. /**
  74512. * Class used to create texture to support 2D GUI elements
  74513. * @see http://doc.babylonjs.com/how_to/gui
  74514. */
  74515. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  74516. private _isDirty;
  74517. private _renderObserver;
  74518. private _resizeObserver;
  74519. private _preKeyboardObserver;
  74520. private _pointerMoveObserver;
  74521. private _pointerObserver;
  74522. private _canvasPointerOutObserver;
  74523. private _background;
  74524. /** @hidden */
  74525. _rootContainer: Container;
  74526. /** @hidden */
  74527. _lastPickedControl: Control;
  74528. /** @hidden */
  74529. _lastControlOver: {
  74530. [pointerId: number]: Control;
  74531. };
  74532. /** @hidden */
  74533. _lastControlDown: {
  74534. [pointerId: number]: Control;
  74535. };
  74536. /** @hidden */
  74537. _capturingControl: {
  74538. [pointerId: number]: Control;
  74539. };
  74540. /** @hidden */
  74541. _shouldBlockPointer: boolean;
  74542. /** @hidden */
  74543. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  74544. /** @hidden */
  74545. _linkedControls: Control[];
  74546. private _isFullscreen;
  74547. private _fullscreenViewport;
  74548. private _idealWidth;
  74549. private _idealHeight;
  74550. private _useSmallestIdeal;
  74551. private _renderAtIdealSize;
  74552. private _focusedControl;
  74553. private _blockNextFocusCheck;
  74554. private _renderScale;
  74555. private _rootElement;
  74556. private _cursorChanged;
  74557. private _defaultMousePointerId;
  74558. /** @hidden */
  74559. _numLayoutCalls: number;
  74560. /** Gets the number of layout calls made the last time the ADT has been rendered */
  74561. get numLayoutCalls(): number;
  74562. /** @hidden */
  74563. _numRenderCalls: number;
  74564. /** Gets the number of render calls made the last time the ADT has been rendered */
  74565. get numRenderCalls(): number;
  74566. /**
  74567. * Define type to string to ensure compatibility across browsers
  74568. * Safari doesn't support DataTransfer constructor
  74569. */
  74570. private _clipboardData;
  74571. /**
  74572. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  74573. */
  74574. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  74575. /**
  74576. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  74577. */
  74578. onControlPickedObservable: BABYLON.Observable<Control>;
  74579. /**
  74580. * BABYLON.Observable event triggered before layout is evaluated
  74581. */
  74582. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74583. /**
  74584. * BABYLON.Observable event triggered after the layout was evaluated
  74585. */
  74586. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74587. /**
  74588. * BABYLON.Observable event triggered before the texture is rendered
  74589. */
  74590. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74591. /**
  74592. * BABYLON.Observable event triggered after the texture was rendered
  74593. */
  74594. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74595. /**
  74596. * Gets or sets a boolean defining if alpha is stored as premultiplied
  74597. */
  74598. premulAlpha: boolean;
  74599. /**
  74600. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  74601. * Useful when you want more antialiasing
  74602. */
  74603. get renderScale(): number;
  74604. set renderScale(value: number);
  74605. /** Gets or sets the background color */
  74606. get background(): string;
  74607. set background(value: string);
  74608. /**
  74609. * Gets or sets the ideal width used to design controls.
  74610. * The GUI will then rescale everything accordingly
  74611. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74612. */
  74613. get idealWidth(): number;
  74614. set idealWidth(value: number);
  74615. /**
  74616. * Gets or sets the ideal height used to design controls.
  74617. * The GUI will then rescale everything accordingly
  74618. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74619. */
  74620. get idealHeight(): number;
  74621. set idealHeight(value: number);
  74622. /**
  74623. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  74624. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74625. */
  74626. get useSmallestIdeal(): boolean;
  74627. set useSmallestIdeal(value: boolean);
  74628. /**
  74629. * Gets or sets a boolean indicating if adaptive scaling must be used
  74630. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74631. */
  74632. get renderAtIdealSize(): boolean;
  74633. set renderAtIdealSize(value: boolean);
  74634. /**
  74635. * Gets the ratio used when in "ideal mode"
  74636. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74637. * */
  74638. get idealRatio(): number;
  74639. /**
  74640. * Gets the underlying layer used to render the texture when in fullscreen mode
  74641. */
  74642. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  74643. /**
  74644. * Gets the root container control
  74645. */
  74646. get rootContainer(): Container;
  74647. /**
  74648. * Returns an array containing the root container.
  74649. * This is mostly used to let the Inspector introspects the ADT
  74650. * @returns an array containing the rootContainer
  74651. */
  74652. getChildren(): Array<Container>;
  74653. /**
  74654. * Will return all controls that are inside this texture
  74655. * @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
  74656. * @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
  74657. * @return all child controls
  74658. */
  74659. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  74660. /**
  74661. * Gets or sets the current focused control
  74662. */
  74663. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  74664. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  74665. /**
  74666. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  74667. */
  74668. get isForeground(): boolean;
  74669. set isForeground(value: boolean);
  74670. /**
  74671. * Gets or set information about clipboardData
  74672. */
  74673. get clipboardData(): string;
  74674. set clipboardData(value: string);
  74675. /**
  74676. * Creates a new AdvancedDynamicTexture
  74677. * @param name defines the name of the texture
  74678. * @param width defines the width of the texture
  74679. * @param height defines the height of the texture
  74680. * @param scene defines the hosting scene
  74681. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  74682. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  74683. */
  74684. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  74685. /**
  74686. * Get the current class name of the texture useful for serialization or dynamic coding.
  74687. * @returns "AdvancedDynamicTexture"
  74688. */
  74689. getClassName(): string;
  74690. /**
  74691. * Function used to execute a function on all controls
  74692. * @param func defines the function to execute
  74693. * @param container defines the container where controls belong. If null the root container will be used
  74694. */
  74695. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  74696. private _useInvalidateRectOptimization;
  74697. /**
  74698. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  74699. */
  74700. get useInvalidateRectOptimization(): boolean;
  74701. set useInvalidateRectOptimization(value: boolean);
  74702. private _invalidatedRectangle;
  74703. /**
  74704. * Invalidates a rectangle area on the gui texture
  74705. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  74706. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  74707. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  74708. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  74709. */
  74710. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  74711. /**
  74712. * Marks the texture as dirty forcing a complete update
  74713. */
  74714. markAsDirty(): void;
  74715. /**
  74716. * Helper function used to create a new style
  74717. * @returns a new style
  74718. * @see http://doc.babylonjs.com/how_to/gui#styles
  74719. */
  74720. createStyle(): Style;
  74721. /**
  74722. * Adds a new control to the root container
  74723. * @param control defines the control to add
  74724. * @returns the current texture
  74725. */
  74726. addControl(control: Control): AdvancedDynamicTexture;
  74727. /**
  74728. * Removes a control from the root container
  74729. * @param control defines the control to remove
  74730. * @returns the current texture
  74731. */
  74732. removeControl(control: Control): AdvancedDynamicTexture;
  74733. /**
  74734. * Release all resources
  74735. */
  74736. dispose(): void;
  74737. private _onResize;
  74738. /** @hidden */
  74739. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  74740. /**
  74741. * Get screen coordinates for a vector3
  74742. * @param position defines the position to project
  74743. * @param worldMatrix defines the world matrix to use
  74744. * @returns the projected position
  74745. */
  74746. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  74747. private _checkUpdate;
  74748. private _clearMeasure;
  74749. private _render;
  74750. /** @hidden */
  74751. _changeCursor(cursor: string): void;
  74752. /** @hidden */
  74753. _registerLastControlDown(control: Control, pointerId: number): void;
  74754. private _doPicking;
  74755. /** @hidden */
  74756. _cleanControlAfterRemovalFromList(list: {
  74757. [pointerId: number]: Control;
  74758. }, control: Control): void;
  74759. /** @hidden */
  74760. _cleanControlAfterRemoval(control: Control): void;
  74761. /** Attach to all scene events required to support pointer events */
  74762. attach(): void;
  74763. /** @hidden */
  74764. private onClipboardCopy;
  74765. /** @hidden */
  74766. private onClipboardCut;
  74767. /** @hidden */
  74768. private onClipboardPaste;
  74769. /**
  74770. * Register the clipboard Events onto the canvas
  74771. */
  74772. registerClipboardEvents(): void;
  74773. /**
  74774. * Unregister the clipboard Events from the canvas
  74775. */
  74776. unRegisterClipboardEvents(): void;
  74777. /**
  74778. * Connect the texture to a hosting mesh to enable interactions
  74779. * @param mesh defines the mesh to attach to
  74780. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  74781. */
  74782. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  74783. /**
  74784. * Move the focus to a specific control
  74785. * @param control defines the control which will receive the focus
  74786. */
  74787. moveFocusToControl(control: IFocusableControl): void;
  74788. private _manageFocus;
  74789. private _attachToOnPointerOut;
  74790. /**
  74791. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  74792. * @param mesh defines the mesh which will receive the texture
  74793. * @param width defines the texture width (1024 by default)
  74794. * @param height defines the texture height (1024 by default)
  74795. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  74796. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  74797. * @returns a new AdvancedDynamicTexture
  74798. */
  74799. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  74800. /**
  74801. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  74802. * In this mode the texture will rely on a layer for its rendering.
  74803. * This allows it to be treated like any other layer.
  74804. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  74805. * LayerMask is set through advancedTexture.layer.layerMask
  74806. * @param name defines name for the texture
  74807. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  74808. * @param scene defines the hsoting scene
  74809. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  74810. * @returns a new AdvancedDynamicTexture
  74811. */
  74812. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  74813. }
  74814. }
  74815. declare module BABYLON.GUI {
  74816. /**
  74817. * Root class used for all 2D controls
  74818. * @see http://doc.babylonjs.com/how_to/gui#controls
  74819. */
  74820. export class Control {
  74821. /** defines the name of the control */
  74822. name?: string | undefined;
  74823. /**
  74824. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  74825. */
  74826. static AllowAlphaInheritance: boolean;
  74827. private _alpha;
  74828. private _alphaSet;
  74829. private _zIndex;
  74830. /** @hidden */
  74831. _host: AdvancedDynamicTexture;
  74832. /** Gets or sets the control parent */
  74833. parent: BABYLON.Nullable<Container>;
  74834. /** @hidden */
  74835. _currentMeasure: Measure;
  74836. private _fontFamily;
  74837. private _fontStyle;
  74838. private _fontWeight;
  74839. private _fontSize;
  74840. private _font;
  74841. /** @hidden */
  74842. _width: ValueAndUnit;
  74843. /** @hidden */
  74844. _height: ValueAndUnit;
  74845. /** @hidden */
  74846. protected _fontOffset: {
  74847. ascent: number;
  74848. height: number;
  74849. descent: number;
  74850. };
  74851. private _color;
  74852. private _style;
  74853. private _styleObserver;
  74854. /** @hidden */
  74855. protected _horizontalAlignment: number;
  74856. /** @hidden */
  74857. protected _verticalAlignment: number;
  74858. /** @hidden */
  74859. protected _isDirty: boolean;
  74860. /** @hidden */
  74861. protected _wasDirty: boolean;
  74862. /** @hidden */
  74863. _tempParentMeasure: Measure;
  74864. /** @hidden */
  74865. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  74866. /** @hidden */
  74867. protected _cachedParentMeasure: Measure;
  74868. private _paddingLeft;
  74869. private _paddingRight;
  74870. private _paddingTop;
  74871. private _paddingBottom;
  74872. /** @hidden */
  74873. _left: ValueAndUnit;
  74874. /** @hidden */
  74875. _top: ValueAndUnit;
  74876. private _scaleX;
  74877. private _scaleY;
  74878. private _rotation;
  74879. private _transformCenterX;
  74880. private _transformCenterY;
  74881. /** @hidden */
  74882. _transformMatrix: Matrix2D;
  74883. /** @hidden */
  74884. protected _invertTransformMatrix: Matrix2D;
  74885. /** @hidden */
  74886. protected _transformedPosition: BABYLON.Vector2;
  74887. private _isMatrixDirty;
  74888. private _cachedOffsetX;
  74889. private _cachedOffsetY;
  74890. private _isVisible;
  74891. private _isHighlighted;
  74892. /** @hidden */
  74893. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  74894. private _fontSet;
  74895. private _dummyVector2;
  74896. private _downCount;
  74897. private _enterCount;
  74898. private _doNotRender;
  74899. private _downPointerIds;
  74900. protected _isEnabled: boolean;
  74901. protected _disabledColor: string;
  74902. protected _disabledColorItem: string;
  74903. /** @hidden */
  74904. protected _rebuildLayout: boolean;
  74905. /** @hidden */
  74906. _customData: any;
  74907. /** @hidden */
  74908. _isClipped: boolean;
  74909. /** @hidden */
  74910. _automaticSize: boolean;
  74911. /** @hidden */
  74912. _tag: any;
  74913. /**
  74914. * 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
  74915. */
  74916. uniqueId: number;
  74917. /**
  74918. * Gets or sets an object used to store user defined information for the node
  74919. */
  74920. metadata: any;
  74921. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  74922. isHitTestVisible: boolean;
  74923. /** Gets or sets a boolean indicating if the control can block pointer events */
  74924. isPointerBlocker: boolean;
  74925. /** Gets or sets a boolean indicating if the control can be focusable */
  74926. isFocusInvisible: boolean;
  74927. /**
  74928. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  74929. * 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
  74930. */
  74931. clipChildren: boolean;
  74932. /**
  74933. * Gets or sets a boolean indicating that control content must be clipped
  74934. * 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
  74935. */
  74936. clipContent: boolean;
  74937. /**
  74938. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  74939. */
  74940. useBitmapCache: boolean;
  74941. private _cacheData;
  74942. private _shadowOffsetX;
  74943. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  74944. get shadowOffsetX(): number;
  74945. set shadowOffsetX(value: number);
  74946. private _shadowOffsetY;
  74947. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  74948. get shadowOffsetY(): number;
  74949. set shadowOffsetY(value: number);
  74950. private _shadowBlur;
  74951. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  74952. get shadowBlur(): number;
  74953. set shadowBlur(value: number);
  74954. private _shadowColor;
  74955. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  74956. get shadowColor(): string;
  74957. set shadowColor(value: string);
  74958. /** Gets or sets the cursor to use when the control is hovered */
  74959. hoverCursor: string;
  74960. /** @hidden */
  74961. protected _linkOffsetX: ValueAndUnit;
  74962. /** @hidden */
  74963. protected _linkOffsetY: ValueAndUnit;
  74964. /** Gets the control type name */
  74965. get typeName(): string;
  74966. /**
  74967. * Get the current class name of the control.
  74968. * @returns current class name
  74969. */
  74970. getClassName(): string;
  74971. /**
  74972. * An event triggered when pointer wheel is scrolled
  74973. */
  74974. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  74975. /**
  74976. * An event triggered when the pointer move over the control.
  74977. */
  74978. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  74979. /**
  74980. * An event triggered when the pointer move out of the control.
  74981. */
  74982. onPointerOutObservable: BABYLON.Observable<Control>;
  74983. /**
  74984. * An event triggered when the pointer taps the control
  74985. */
  74986. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  74987. /**
  74988. * An event triggered when pointer up
  74989. */
  74990. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  74991. /**
  74992. * An event triggered when a control is clicked on
  74993. */
  74994. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  74995. /**
  74996. * An event triggered when pointer enters the control
  74997. */
  74998. onPointerEnterObservable: BABYLON.Observable<Control>;
  74999. /**
  75000. * An event triggered when the control is marked as dirty
  75001. */
  75002. onDirtyObservable: BABYLON.Observable<Control>;
  75003. /**
  75004. * An event triggered before drawing the control
  75005. */
  75006. onBeforeDrawObservable: BABYLON.Observable<Control>;
  75007. /**
  75008. * An event triggered after the control was drawn
  75009. */
  75010. onAfterDrawObservable: BABYLON.Observable<Control>;
  75011. /**
  75012. * An event triggered when the control has been disposed
  75013. */
  75014. onDisposeObservable: BABYLON.Observable<Control>;
  75015. /**
  75016. * Get the hosting AdvancedDynamicTexture
  75017. */
  75018. get host(): AdvancedDynamicTexture;
  75019. /** Gets or set information about font offsets (used to render and align text) */
  75020. get fontOffset(): {
  75021. ascent: number;
  75022. height: number;
  75023. descent: number;
  75024. };
  75025. set fontOffset(offset: {
  75026. ascent: number;
  75027. height: number;
  75028. descent: number;
  75029. });
  75030. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  75031. get alpha(): number;
  75032. set alpha(value: number);
  75033. /**
  75034. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  75035. */
  75036. get isHighlighted(): boolean;
  75037. set isHighlighted(value: boolean);
  75038. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  75039. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75040. */
  75041. get scaleX(): number;
  75042. set scaleX(value: number);
  75043. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  75044. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75045. */
  75046. get scaleY(): number;
  75047. set scaleY(value: number);
  75048. /** Gets or sets the rotation angle (0 by default)
  75049. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75050. */
  75051. get rotation(): number;
  75052. set rotation(value: number);
  75053. /** Gets or sets the transformation center on Y axis (0 by default)
  75054. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75055. */
  75056. get transformCenterY(): number;
  75057. set transformCenterY(value: number);
  75058. /** Gets or sets the transformation center on X axis (0 by default)
  75059. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75060. */
  75061. get transformCenterX(): number;
  75062. set transformCenterX(value: number);
  75063. /**
  75064. * Gets or sets the horizontal alignment
  75065. * @see http://doc.babylonjs.com/how_to/gui#alignments
  75066. */
  75067. get horizontalAlignment(): number;
  75068. set horizontalAlignment(value: number);
  75069. /**
  75070. * Gets or sets the vertical alignment
  75071. * @see http://doc.babylonjs.com/how_to/gui#alignments
  75072. */
  75073. get verticalAlignment(): number;
  75074. set verticalAlignment(value: number);
  75075. /**
  75076. * Gets or sets control width
  75077. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75078. */
  75079. get width(): string | number;
  75080. set width(value: string | number);
  75081. /**
  75082. * Gets or sets the control width in pixel
  75083. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75084. */
  75085. get widthInPixels(): number;
  75086. set widthInPixels(value: number);
  75087. /**
  75088. * Gets or sets control height
  75089. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75090. */
  75091. get height(): string | number;
  75092. set height(value: string | number);
  75093. /**
  75094. * Gets or sets control height in pixel
  75095. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75096. */
  75097. get heightInPixels(): number;
  75098. set heightInPixels(value: number);
  75099. /** Gets or set font family */
  75100. get fontFamily(): string;
  75101. set fontFamily(value: string);
  75102. /** Gets or sets font style */
  75103. get fontStyle(): string;
  75104. set fontStyle(value: string);
  75105. /** Gets or sets font weight */
  75106. get fontWeight(): string;
  75107. set fontWeight(value: string);
  75108. /**
  75109. * Gets or sets style
  75110. * @see http://doc.babylonjs.com/how_to/gui#styles
  75111. */
  75112. get style(): BABYLON.Nullable<Style>;
  75113. set style(value: BABYLON.Nullable<Style>);
  75114. /** @hidden */
  75115. get _isFontSizeInPercentage(): boolean;
  75116. /** Gets or sets font size in pixels */
  75117. get fontSizeInPixels(): number;
  75118. set fontSizeInPixels(value: number);
  75119. /** Gets or sets font size */
  75120. get fontSize(): string | number;
  75121. set fontSize(value: string | number);
  75122. /** Gets or sets foreground color */
  75123. get color(): string;
  75124. set color(value: string);
  75125. /** Gets or sets z index which is used to reorder controls on the z axis */
  75126. get zIndex(): number;
  75127. set zIndex(value: number);
  75128. /** Gets or sets a boolean indicating if the control can be rendered */
  75129. get notRenderable(): boolean;
  75130. set notRenderable(value: boolean);
  75131. /** Gets or sets a boolean indicating if the control is visible */
  75132. get isVisible(): boolean;
  75133. set isVisible(value: boolean);
  75134. /** Gets a boolean indicating that the control needs to update its rendering */
  75135. get isDirty(): boolean;
  75136. /**
  75137. * Gets the current linked mesh (or null if none)
  75138. */
  75139. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  75140. /**
  75141. * Gets or sets a value indicating the padding to use on the left of the control
  75142. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75143. */
  75144. get paddingLeft(): string | number;
  75145. set paddingLeft(value: string | number);
  75146. /**
  75147. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  75148. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75149. */
  75150. get paddingLeftInPixels(): number;
  75151. set paddingLeftInPixels(value: number);
  75152. /**
  75153. * Gets or sets a value indicating the padding to use on the right of the control
  75154. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75155. */
  75156. get paddingRight(): string | number;
  75157. set paddingRight(value: string | number);
  75158. /**
  75159. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  75160. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75161. */
  75162. get paddingRightInPixels(): number;
  75163. set paddingRightInPixels(value: number);
  75164. /**
  75165. * Gets or sets a value indicating the padding to use on the top of the control
  75166. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75167. */
  75168. get paddingTop(): string | number;
  75169. set paddingTop(value: string | number);
  75170. /**
  75171. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  75172. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75173. */
  75174. get paddingTopInPixels(): number;
  75175. set paddingTopInPixels(value: number);
  75176. /**
  75177. * Gets or sets a value indicating the padding to use on the bottom of the control
  75178. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75179. */
  75180. get paddingBottom(): string | number;
  75181. set paddingBottom(value: string | number);
  75182. /**
  75183. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  75184. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75185. */
  75186. get paddingBottomInPixels(): number;
  75187. set paddingBottomInPixels(value: number);
  75188. /**
  75189. * Gets or sets a value indicating the left coordinate of the control
  75190. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75191. */
  75192. get left(): string | number;
  75193. set left(value: string | number);
  75194. /**
  75195. * Gets or sets a value indicating the left coordinate in pixels of the control
  75196. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75197. */
  75198. get leftInPixels(): number;
  75199. set leftInPixels(value: number);
  75200. /**
  75201. * Gets or sets a value indicating the top coordinate of the control
  75202. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75203. */
  75204. get top(): string | number;
  75205. set top(value: string | number);
  75206. /**
  75207. * Gets or sets a value indicating the top coordinate in pixels of the control
  75208. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75209. */
  75210. get topInPixels(): number;
  75211. set topInPixels(value: number);
  75212. /**
  75213. * Gets or sets a value indicating the offset on X axis to the linked mesh
  75214. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75215. */
  75216. get linkOffsetX(): string | number;
  75217. set linkOffsetX(value: string | number);
  75218. /**
  75219. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  75220. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75221. */
  75222. get linkOffsetXInPixels(): number;
  75223. set linkOffsetXInPixels(value: number);
  75224. /**
  75225. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  75226. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75227. */
  75228. get linkOffsetY(): string | number;
  75229. set linkOffsetY(value: string | number);
  75230. /**
  75231. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  75232. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75233. */
  75234. get linkOffsetYInPixels(): number;
  75235. set linkOffsetYInPixels(value: number);
  75236. /** Gets the center coordinate on X axis */
  75237. get centerX(): number;
  75238. /** Gets the center coordinate on Y axis */
  75239. get centerY(): number;
  75240. /** Gets or sets if control is Enabled*/
  75241. get isEnabled(): boolean;
  75242. set isEnabled(value: boolean);
  75243. /** Gets or sets background color of control if it's disabled*/
  75244. get disabledColor(): string;
  75245. set disabledColor(value: string);
  75246. /** Gets or sets front color of control if it's disabled*/
  75247. get disabledColorItem(): string;
  75248. set disabledColorItem(value: string);
  75249. /**
  75250. * Creates a new control
  75251. * @param name defines the name of the control
  75252. */
  75253. constructor(
  75254. /** defines the name of the control */
  75255. name?: string | undefined);
  75256. /** @hidden */
  75257. protected _getTypeName(): string;
  75258. /**
  75259. * Gets the first ascendant in the hierarchy of the given type
  75260. * @param className defines the required type
  75261. * @returns the ascendant or null if not found
  75262. */
  75263. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  75264. /** @hidden */
  75265. _resetFontCache(): void;
  75266. /**
  75267. * Determines if a container is an ascendant of the current control
  75268. * @param container defines the container to look for
  75269. * @returns true if the container is one of the ascendant of the control
  75270. */
  75271. isAscendant(container: Control): boolean;
  75272. /**
  75273. * Gets coordinates in local control space
  75274. * @param globalCoordinates defines the coordinates to transform
  75275. * @returns the new coordinates in local space
  75276. */
  75277. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  75278. /**
  75279. * Gets coordinates in local control space
  75280. * @param globalCoordinates defines the coordinates to transform
  75281. * @param result defines the target vector2 where to store the result
  75282. * @returns the current control
  75283. */
  75284. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  75285. /**
  75286. * Gets coordinates in parent local control space
  75287. * @param globalCoordinates defines the coordinates to transform
  75288. * @returns the new coordinates in parent local space
  75289. */
  75290. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  75291. /**
  75292. * Move the current control to a vector3 position projected onto the screen.
  75293. * @param position defines the target position
  75294. * @param scene defines the hosting scene
  75295. */
  75296. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  75297. /**
  75298. * Will store all controls that have this control as ascendant in a given array
  75299. * @param results defines the array where to store the descendants
  75300. * @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
  75301. * @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
  75302. */
  75303. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  75304. /**
  75305. * Will return all controls that have this control as ascendant
  75306. * @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
  75307. * @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
  75308. * @return all child controls
  75309. */
  75310. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  75311. /**
  75312. * Link current control with a target mesh
  75313. * @param mesh defines the mesh to link with
  75314. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75315. */
  75316. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  75317. /** @hidden */
  75318. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  75319. /** @hidden */
  75320. _offsetLeft(offset: number): void;
  75321. /** @hidden */
  75322. _offsetTop(offset: number): void;
  75323. /** @hidden */
  75324. _markMatrixAsDirty(): void;
  75325. /** @hidden */
  75326. _flagDescendantsAsMatrixDirty(): void;
  75327. /** @hidden */
  75328. _intersectsRect(rect: Measure): boolean;
  75329. /** @hidden */
  75330. protected invalidateRect(): void;
  75331. /** @hidden */
  75332. _markAsDirty(force?: boolean): void;
  75333. /** @hidden */
  75334. _markAllAsDirty(): void;
  75335. /** @hidden */
  75336. _link(host: AdvancedDynamicTexture): void;
  75337. /** @hidden */
  75338. protected _transform(context?: CanvasRenderingContext2D): void;
  75339. /** @hidden */
  75340. _renderHighlight(context: CanvasRenderingContext2D): void;
  75341. /** @hidden */
  75342. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  75343. /** @hidden */
  75344. protected _applyStates(context: CanvasRenderingContext2D): void;
  75345. /** @hidden */
  75346. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  75347. /** @hidden */
  75348. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75349. protected _evaluateClippingState(parentMeasure: Measure): void;
  75350. /** @hidden */
  75351. _measure(): void;
  75352. /** @hidden */
  75353. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75354. /** @hidden */
  75355. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75356. /** @hidden */
  75357. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75358. /** @hidden */
  75359. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  75360. private static _ClipMeasure;
  75361. private _tmpMeasureA;
  75362. private _clip;
  75363. /** @hidden */
  75364. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  75365. /** @hidden */
  75366. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75367. /**
  75368. * Tests if a given coordinates belong to the current control
  75369. * @param x defines x coordinate to test
  75370. * @param y defines y coordinate to test
  75371. * @returns true if the coordinates are inside the control
  75372. */
  75373. contains(x: number, y: number): boolean;
  75374. /** @hidden */
  75375. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75376. /** @hidden */
  75377. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  75378. /** @hidden */
  75379. _onPointerEnter(target: Control): boolean;
  75380. /** @hidden */
  75381. _onPointerOut(target: Control, force?: boolean): void;
  75382. /** @hidden */
  75383. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75384. /** @hidden */
  75385. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75386. /** @hidden */
  75387. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  75388. /** @hidden */
  75389. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  75390. /** @hidden */
  75391. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75392. private _prepareFont;
  75393. /** Releases associated resources */
  75394. dispose(): void;
  75395. private static _HORIZONTAL_ALIGNMENT_LEFT;
  75396. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  75397. private static _HORIZONTAL_ALIGNMENT_CENTER;
  75398. private static _VERTICAL_ALIGNMENT_TOP;
  75399. private static _VERTICAL_ALIGNMENT_BOTTOM;
  75400. private static _VERTICAL_ALIGNMENT_CENTER;
  75401. /** HORIZONTAL_ALIGNMENT_LEFT */
  75402. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  75403. /** HORIZONTAL_ALIGNMENT_RIGHT */
  75404. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  75405. /** HORIZONTAL_ALIGNMENT_CENTER */
  75406. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  75407. /** VERTICAL_ALIGNMENT_TOP */
  75408. static get VERTICAL_ALIGNMENT_TOP(): number;
  75409. /** VERTICAL_ALIGNMENT_BOTTOM */
  75410. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  75411. /** VERTICAL_ALIGNMENT_CENTER */
  75412. static get VERTICAL_ALIGNMENT_CENTER(): number;
  75413. private static _FontHeightSizes;
  75414. /** @hidden */
  75415. static _GetFontOffset(font: string): {
  75416. ascent: number;
  75417. height: number;
  75418. descent: number;
  75419. };
  75420. /**
  75421. * Creates a stack panel that can be used to render headers
  75422. * @param control defines the control to associate with the header
  75423. * @param text defines the text of the header
  75424. * @param size defines the size of the header
  75425. * @param options defines options used to configure the header
  75426. * @returns a new StackPanel
  75427. * @ignore
  75428. * @hidden
  75429. */
  75430. static AddHeader: (control: Control, text: string, size: string | number, options: {
  75431. isHorizontal: boolean;
  75432. controlFirst: boolean;
  75433. }) => any;
  75434. /** @hidden */
  75435. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  75436. }
  75437. }
  75438. declare module BABYLON.GUI {
  75439. /**
  75440. * Root class for 2D containers
  75441. * @see http://doc.babylonjs.com/how_to/gui#containers
  75442. */
  75443. export class Container extends Control {
  75444. name?: string | undefined;
  75445. /** @hidden */
  75446. _children: Control[];
  75447. /** @hidden */
  75448. protected _measureForChildren: Measure;
  75449. /** @hidden */
  75450. protected _background: string;
  75451. /** @hidden */
  75452. protected _adaptWidthToChildren: boolean;
  75453. /** @hidden */
  75454. protected _adaptHeightToChildren: boolean;
  75455. /**
  75456. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  75457. */
  75458. logLayoutCycleErrors: boolean;
  75459. /**
  75460. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  75461. */
  75462. maxLayoutCycle: number;
  75463. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  75464. get adaptHeightToChildren(): boolean;
  75465. set adaptHeightToChildren(value: boolean);
  75466. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  75467. get adaptWidthToChildren(): boolean;
  75468. set adaptWidthToChildren(value: boolean);
  75469. /** Gets or sets background color */
  75470. get background(): string;
  75471. set background(value: string);
  75472. /** Gets the list of children */
  75473. get children(): Control[];
  75474. /**
  75475. * Creates a new Container
  75476. * @param name defines the name of the container
  75477. */
  75478. constructor(name?: string | undefined);
  75479. protected _getTypeName(): string;
  75480. _flagDescendantsAsMatrixDirty(): void;
  75481. /**
  75482. * Gets a child using its name
  75483. * @param name defines the child name to look for
  75484. * @returns the child control if found
  75485. */
  75486. getChildByName(name: string): BABYLON.Nullable<Control>;
  75487. /**
  75488. * Gets a child using its type and its name
  75489. * @param name defines the child name to look for
  75490. * @param type defines the child type to look for
  75491. * @returns the child control if found
  75492. */
  75493. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  75494. /**
  75495. * Search for a specific control in children
  75496. * @param control defines the control to look for
  75497. * @returns true if the control is in child list
  75498. */
  75499. containsControl(control: Control): boolean;
  75500. /**
  75501. * Adds a new control to the current container
  75502. * @param control defines the control to add
  75503. * @returns the current container
  75504. */
  75505. addControl(control: BABYLON.Nullable<Control>): Container;
  75506. /**
  75507. * Removes all controls from the current container
  75508. * @returns the current container
  75509. */
  75510. clearControls(): Container;
  75511. /**
  75512. * Removes a control from the current container
  75513. * @param control defines the control to remove
  75514. * @returns the current container
  75515. */
  75516. removeControl(control: Control): Container;
  75517. /** @hidden */
  75518. _reOrderControl(control: Control): void;
  75519. /** @hidden */
  75520. _offsetLeft(offset: number): void;
  75521. /** @hidden */
  75522. _offsetTop(offset: number): void;
  75523. /** @hidden */
  75524. _markAllAsDirty(): void;
  75525. /** @hidden */
  75526. protected _localDraw(context: CanvasRenderingContext2D): void;
  75527. /** @hidden */
  75528. _link(host: AdvancedDynamicTexture): void;
  75529. /** @hidden */
  75530. protected _beforeLayout(): void;
  75531. /** @hidden */
  75532. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75533. /** @hidden */
  75534. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  75535. protected _postMeasure(): void;
  75536. /** @hidden */
  75537. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  75538. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  75539. /** @hidden */
  75540. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75541. /** @hidden */
  75542. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75543. /** Releases associated resources */
  75544. dispose(): void;
  75545. }
  75546. }
  75547. declare module BABYLON.GUI {
  75548. /** Class used to create rectangle container */
  75549. export class Rectangle extends Container {
  75550. name?: string | undefined;
  75551. private _thickness;
  75552. private _cornerRadius;
  75553. /** Gets or sets border thickness */
  75554. get thickness(): number;
  75555. set thickness(value: number);
  75556. /** Gets or sets the corner radius angle */
  75557. get cornerRadius(): number;
  75558. set cornerRadius(value: number);
  75559. /**
  75560. * Creates a new Rectangle
  75561. * @param name defines the control name
  75562. */
  75563. constructor(name?: string | undefined);
  75564. protected _getTypeName(): string;
  75565. protected _localDraw(context: CanvasRenderingContext2D): void;
  75566. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75567. private _drawRoundedRect;
  75568. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  75569. }
  75570. }
  75571. declare module BABYLON.GUI {
  75572. /**
  75573. * Enum that determines the text-wrapping mode to use.
  75574. */
  75575. export enum TextWrapping {
  75576. /**
  75577. * Clip the text when it's larger than Control.width; this is the default mode.
  75578. */
  75579. Clip = 0,
  75580. /**
  75581. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  75582. */
  75583. WordWrap = 1,
  75584. /**
  75585. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  75586. */
  75587. Ellipsis = 2
  75588. }
  75589. /**
  75590. * Class used to create text block control
  75591. */
  75592. export class TextBlock extends Control {
  75593. /**
  75594. * Defines the name of the control
  75595. */
  75596. name?: string | undefined;
  75597. private _text;
  75598. private _textWrapping;
  75599. private _textHorizontalAlignment;
  75600. private _textVerticalAlignment;
  75601. private _lines;
  75602. private _resizeToFit;
  75603. private _lineSpacing;
  75604. private _outlineWidth;
  75605. private _outlineColor;
  75606. /**
  75607. * An event triggered after the text is changed
  75608. */
  75609. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  75610. /**
  75611. * An event triggered after the text was broken up into lines
  75612. */
  75613. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  75614. /**
  75615. * Function used to split a string into words. By default, a string is split at each space character found
  75616. */
  75617. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  75618. /**
  75619. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  75620. */
  75621. get lines(): any[];
  75622. /**
  75623. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  75624. */
  75625. get resizeToFit(): boolean;
  75626. /**
  75627. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  75628. */
  75629. set resizeToFit(value: boolean);
  75630. /**
  75631. * Gets or sets a boolean indicating if text must be wrapped
  75632. */
  75633. get textWrapping(): TextWrapping | boolean;
  75634. /**
  75635. * Gets or sets a boolean indicating if text must be wrapped
  75636. */
  75637. set textWrapping(value: TextWrapping | boolean);
  75638. /**
  75639. * Gets or sets text to display
  75640. */
  75641. get text(): string;
  75642. /**
  75643. * Gets or sets text to display
  75644. */
  75645. set text(value: string);
  75646. /**
  75647. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  75648. */
  75649. get textHorizontalAlignment(): number;
  75650. /**
  75651. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  75652. */
  75653. set textHorizontalAlignment(value: number);
  75654. /**
  75655. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  75656. */
  75657. get textVerticalAlignment(): number;
  75658. /**
  75659. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  75660. */
  75661. set textVerticalAlignment(value: number);
  75662. /**
  75663. * Gets or sets line spacing value
  75664. */
  75665. set lineSpacing(value: string | number);
  75666. /**
  75667. * Gets or sets line spacing value
  75668. */
  75669. get lineSpacing(): string | number;
  75670. /**
  75671. * Gets or sets outlineWidth of the text to display
  75672. */
  75673. get outlineWidth(): number;
  75674. /**
  75675. * Gets or sets outlineWidth of the text to display
  75676. */
  75677. set outlineWidth(value: number);
  75678. /**
  75679. * Gets or sets outlineColor of the text to display
  75680. */
  75681. get outlineColor(): string;
  75682. /**
  75683. * Gets or sets outlineColor of the text to display
  75684. */
  75685. set outlineColor(value: string);
  75686. /**
  75687. * Creates a new TextBlock object
  75688. * @param name defines the name of the control
  75689. * @param text defines the text to display (emptry string by default)
  75690. */
  75691. constructor(
  75692. /**
  75693. * Defines the name of the control
  75694. */
  75695. name?: string | undefined, text?: string);
  75696. protected _getTypeName(): string;
  75697. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75698. private _drawText;
  75699. /** @hidden */
  75700. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75701. protected _applyStates(context: CanvasRenderingContext2D): void;
  75702. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  75703. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  75704. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  75705. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  75706. protected _renderLines(context: CanvasRenderingContext2D): void;
  75707. /**
  75708. * Given a width constraint applied on the text block, find the expected height
  75709. * @returns expected height
  75710. */
  75711. computeExpectedHeight(): number;
  75712. dispose(): void;
  75713. }
  75714. }
  75715. declare module BABYLON.GUI {
  75716. /**
  75717. * Class used to create 2D images
  75718. */
  75719. export class Image extends Control {
  75720. name?: string | undefined;
  75721. private _workingCanvas;
  75722. private _domImage;
  75723. private _imageWidth;
  75724. private _imageHeight;
  75725. private _loaded;
  75726. private _stretch;
  75727. private _source;
  75728. private _autoScale;
  75729. private _sourceLeft;
  75730. private _sourceTop;
  75731. private _sourceWidth;
  75732. private _sourceHeight;
  75733. private _svgAttributesComputationCompleted;
  75734. private _isSVG;
  75735. private _cellWidth;
  75736. private _cellHeight;
  75737. private _cellId;
  75738. private _populateNinePatchSlicesFromImage;
  75739. private _sliceLeft;
  75740. private _sliceRight;
  75741. private _sliceTop;
  75742. private _sliceBottom;
  75743. private _detectPointerOnOpaqueOnly;
  75744. /**
  75745. * BABYLON.Observable notified when the content is loaded
  75746. */
  75747. onImageLoadedObservable: BABYLON.Observable<Image>;
  75748. /**
  75749. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  75750. */
  75751. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  75752. /**
  75753. * Gets a boolean indicating that the content is loaded
  75754. */
  75755. get isLoaded(): boolean;
  75756. /**
  75757. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  75758. */
  75759. get populateNinePatchSlicesFromImage(): boolean;
  75760. set populateNinePatchSlicesFromImage(value: boolean);
  75761. /**
  75762. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  75763. * Beware using this as this will comsume more memory as the image has to be stored twice
  75764. */
  75765. get detectPointerOnOpaqueOnly(): boolean;
  75766. set detectPointerOnOpaqueOnly(value: boolean);
  75767. /**
  75768. * Gets or sets the left value for slicing (9-patch)
  75769. */
  75770. get sliceLeft(): number;
  75771. set sliceLeft(value: number);
  75772. /**
  75773. * Gets or sets the right value for slicing (9-patch)
  75774. */
  75775. get sliceRight(): number;
  75776. set sliceRight(value: number);
  75777. /**
  75778. * Gets or sets the top value for slicing (9-patch)
  75779. */
  75780. get sliceTop(): number;
  75781. set sliceTop(value: number);
  75782. /**
  75783. * Gets or sets the bottom value for slicing (9-patch)
  75784. */
  75785. get sliceBottom(): number;
  75786. set sliceBottom(value: number);
  75787. /**
  75788. * Gets or sets the left coordinate in the source image
  75789. */
  75790. get sourceLeft(): number;
  75791. set sourceLeft(value: number);
  75792. /**
  75793. * Gets or sets the top coordinate in the source image
  75794. */
  75795. get sourceTop(): number;
  75796. set sourceTop(value: number);
  75797. /**
  75798. * Gets or sets the width to capture in the source image
  75799. */
  75800. get sourceWidth(): number;
  75801. set sourceWidth(value: number);
  75802. /**
  75803. * Gets or sets the height to capture in the source image
  75804. */
  75805. get sourceHeight(): number;
  75806. set sourceHeight(value: number);
  75807. /** Indicates if the format of the image is SVG */
  75808. get isSVG(): boolean;
  75809. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  75810. get svgAttributesComputationCompleted(): boolean;
  75811. /**
  75812. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  75813. * @see http://doc.babylonjs.com/how_to/gui#image
  75814. */
  75815. get autoScale(): boolean;
  75816. set autoScale(value: boolean);
  75817. /** Gets or sets the streching mode used by the image */
  75818. get stretch(): number;
  75819. set stretch(value: number);
  75820. /** @hidden */
  75821. _rotate90(n: number, preserveProperties?: boolean): Image;
  75822. private _handleRotationForSVGImage;
  75823. private _rotate90SourceProperties;
  75824. /**
  75825. * Gets or sets the internal DOM image used to render the control
  75826. */
  75827. set domImage(value: HTMLImageElement);
  75828. get domImage(): HTMLImageElement;
  75829. private _onImageLoaded;
  75830. private _extractNinePatchSliceDataFromImage;
  75831. /**
  75832. * Gets or sets image source url
  75833. */
  75834. set source(value: BABYLON.Nullable<string>);
  75835. /**
  75836. * Checks for svg document with icon id present
  75837. */
  75838. private _svgCheck;
  75839. /**
  75840. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  75841. * given external svg file and icon id
  75842. */
  75843. private _getSVGAttribs;
  75844. /**
  75845. * Gets or sets the cell width to use when animation sheet is enabled
  75846. * @see http://doc.babylonjs.com/how_to/gui#image
  75847. */
  75848. get cellWidth(): number;
  75849. set cellWidth(value: number);
  75850. /**
  75851. * Gets or sets the cell height to use when animation sheet is enabled
  75852. * @see http://doc.babylonjs.com/how_to/gui#image
  75853. */
  75854. get cellHeight(): number;
  75855. set cellHeight(value: number);
  75856. /**
  75857. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  75858. * @see http://doc.babylonjs.com/how_to/gui#image
  75859. */
  75860. get cellId(): number;
  75861. set cellId(value: number);
  75862. /**
  75863. * Creates a new Image
  75864. * @param name defines the control name
  75865. * @param url defines the image url
  75866. */
  75867. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  75868. /**
  75869. * Tests if a given coordinates belong to the current control
  75870. * @param x defines x coordinate to test
  75871. * @param y defines y coordinate to test
  75872. * @returns true if the coordinates are inside the control
  75873. */
  75874. contains(x: number, y: number): boolean;
  75875. protected _getTypeName(): string;
  75876. /** Force the control to synchronize with its content */
  75877. synchronizeSizeWithContent(): void;
  75878. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75879. private _prepareWorkingCanvasForOpaqueDetection;
  75880. private _drawImage;
  75881. _draw(context: CanvasRenderingContext2D): void;
  75882. private _renderCornerPatch;
  75883. private _renderNinePatch;
  75884. dispose(): void;
  75885. /** STRETCH_NONE */
  75886. static readonly STRETCH_NONE: number;
  75887. /** STRETCH_FILL */
  75888. static readonly STRETCH_FILL: number;
  75889. /** STRETCH_UNIFORM */
  75890. static readonly STRETCH_UNIFORM: number;
  75891. /** STRETCH_EXTEND */
  75892. static readonly STRETCH_EXTEND: number;
  75893. /** NINE_PATCH */
  75894. static readonly STRETCH_NINE_PATCH: number;
  75895. }
  75896. }
  75897. declare module BABYLON.GUI {
  75898. /**
  75899. * Class used to create 2D buttons
  75900. */
  75901. export class Button extends Rectangle {
  75902. name?: string | undefined;
  75903. /**
  75904. * Function called to generate a pointer enter animation
  75905. */
  75906. pointerEnterAnimation: () => void;
  75907. /**
  75908. * Function called to generate a pointer out animation
  75909. */
  75910. pointerOutAnimation: () => void;
  75911. /**
  75912. * Function called to generate a pointer down animation
  75913. */
  75914. pointerDownAnimation: () => void;
  75915. /**
  75916. * Function called to generate a pointer up animation
  75917. */
  75918. pointerUpAnimation: () => void;
  75919. /**
  75920. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  75921. */
  75922. delegatePickingToChildren: boolean;
  75923. private _image;
  75924. /**
  75925. * Returns the image part of the button (if any)
  75926. */
  75927. get image(): BABYLON.Nullable<Image>;
  75928. private _textBlock;
  75929. /**
  75930. * Returns the image part of the button (if any)
  75931. */
  75932. get textBlock(): BABYLON.Nullable<TextBlock>;
  75933. /**
  75934. * Creates a new Button
  75935. * @param name defines the name of the button
  75936. */
  75937. constructor(name?: string | undefined);
  75938. protected _getTypeName(): string;
  75939. /** @hidden */
  75940. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75941. /** @hidden */
  75942. _onPointerEnter(target: Control): boolean;
  75943. /** @hidden */
  75944. _onPointerOut(target: Control, force?: boolean): void;
  75945. /** @hidden */
  75946. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75947. /** @hidden */
  75948. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75949. /**
  75950. * Creates a new button made with an image and a text
  75951. * @param name defines the name of the button
  75952. * @param text defines the text of the button
  75953. * @param imageUrl defines the url of the image
  75954. * @returns a new Button
  75955. */
  75956. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  75957. /**
  75958. * Creates a new button made with an image
  75959. * @param name defines the name of the button
  75960. * @param imageUrl defines the url of the image
  75961. * @returns a new Button
  75962. */
  75963. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  75964. /**
  75965. * Creates a new button made with a text
  75966. * @param name defines the name of the button
  75967. * @param text defines the text of the button
  75968. * @returns a new Button
  75969. */
  75970. static CreateSimpleButton(name: string, text: string): Button;
  75971. /**
  75972. * Creates a new button made with an image and a centered text
  75973. * @param name defines the name of the button
  75974. * @param text defines the text of the button
  75975. * @param imageUrl defines the url of the image
  75976. * @returns a new Button
  75977. */
  75978. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  75979. }
  75980. }
  75981. declare module BABYLON.GUI {
  75982. /**
  75983. * Class used to create a 2D stack panel container
  75984. */
  75985. export class StackPanel extends Container {
  75986. name?: string | undefined;
  75987. private _isVertical;
  75988. private _manualWidth;
  75989. private _manualHeight;
  75990. private _doNotTrackManualChanges;
  75991. /**
  75992. * Gets or sets a boolean indicating that layou warnings should be ignored
  75993. */
  75994. ignoreLayoutWarnings: boolean;
  75995. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  75996. get isVertical(): boolean;
  75997. set isVertical(value: boolean);
  75998. /**
  75999. * Gets or sets panel width.
  76000. * This value should not be set when in horizontal mode as it will be computed automatically
  76001. */
  76002. set width(value: string | number);
  76003. get width(): string | number;
  76004. /**
  76005. * Gets or sets panel height.
  76006. * This value should not be set when in vertical mode as it will be computed automatically
  76007. */
  76008. set height(value: string | number);
  76009. get height(): string | number;
  76010. /**
  76011. * Creates a new StackPanel
  76012. * @param name defines control name
  76013. */
  76014. constructor(name?: string | undefined);
  76015. protected _getTypeName(): string;
  76016. /** @hidden */
  76017. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76018. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76019. protected _postMeasure(): void;
  76020. }
  76021. }
  76022. declare module BABYLON.GUI {
  76023. /**
  76024. * Class used to represent a 2D checkbox
  76025. */
  76026. export class Checkbox extends Control {
  76027. name?: string | undefined;
  76028. private _isChecked;
  76029. private _background;
  76030. private _checkSizeRatio;
  76031. private _thickness;
  76032. /** Gets or sets border thickness */
  76033. get thickness(): number;
  76034. set thickness(value: number);
  76035. /**
  76036. * BABYLON.Observable raised when isChecked property changes
  76037. */
  76038. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  76039. /** Gets or sets a value indicating the ratio between overall size and check size */
  76040. get checkSizeRatio(): number;
  76041. set checkSizeRatio(value: number);
  76042. /** Gets or sets background color */
  76043. get background(): string;
  76044. set background(value: string);
  76045. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  76046. get isChecked(): boolean;
  76047. set isChecked(value: boolean);
  76048. /**
  76049. * Creates a new CheckBox
  76050. * @param name defines the control name
  76051. */
  76052. constructor(name?: string | undefined);
  76053. protected _getTypeName(): string;
  76054. /** @hidden */
  76055. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76056. /** @hidden */
  76057. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76058. /**
  76059. * Utility function to easily create a checkbox with a header
  76060. * @param title defines the label to use for the header
  76061. * @param onValueChanged defines the callback to call when value changes
  76062. * @returns a StackPanel containing the checkbox and a textBlock
  76063. */
  76064. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  76065. }
  76066. }
  76067. declare module BABYLON.GUI {
  76068. /**
  76069. * Class used to store key control properties
  76070. */
  76071. export class KeyPropertySet {
  76072. /** Width */
  76073. width?: string;
  76074. /** Height */
  76075. height?: string;
  76076. /** Left padding */
  76077. paddingLeft?: string;
  76078. /** Right padding */
  76079. paddingRight?: string;
  76080. /** Top padding */
  76081. paddingTop?: string;
  76082. /** Bottom padding */
  76083. paddingBottom?: string;
  76084. /** Foreground color */
  76085. color?: string;
  76086. /** Background color */
  76087. background?: string;
  76088. }
  76089. /**
  76090. * Class used to create virtual keyboard
  76091. */
  76092. export class VirtualKeyboard extends StackPanel {
  76093. /** BABYLON.Observable raised when a key is pressed */
  76094. onKeyPressObservable: BABYLON.Observable<string>;
  76095. /** Gets or sets default key button width */
  76096. defaultButtonWidth: string;
  76097. /** Gets or sets default key button height */
  76098. defaultButtonHeight: string;
  76099. /** Gets or sets default key button left padding */
  76100. defaultButtonPaddingLeft: string;
  76101. /** Gets or sets default key button right padding */
  76102. defaultButtonPaddingRight: string;
  76103. /** Gets or sets default key button top padding */
  76104. defaultButtonPaddingTop: string;
  76105. /** Gets or sets default key button bottom padding */
  76106. defaultButtonPaddingBottom: string;
  76107. /** Gets or sets default key button foreground color */
  76108. defaultButtonColor: string;
  76109. /** Gets or sets default key button background color */
  76110. defaultButtonBackground: string;
  76111. /** Gets or sets shift button foreground color */
  76112. shiftButtonColor: string;
  76113. /** Gets or sets shift button thickness*/
  76114. selectedShiftThickness: number;
  76115. /** Gets shift key state */
  76116. shiftState: number;
  76117. protected _getTypeName(): string;
  76118. private _createKey;
  76119. /**
  76120. * Adds a new row of keys
  76121. * @param keys defines the list of keys to add
  76122. * @param propertySets defines the associated property sets
  76123. */
  76124. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  76125. /**
  76126. * Set the shift key to a specific state
  76127. * @param shiftState defines the new shift state
  76128. */
  76129. applyShiftState(shiftState: number): void;
  76130. private _currentlyConnectedInputText;
  76131. private _connectedInputTexts;
  76132. private _onKeyPressObserver;
  76133. /** Gets the input text control currently attached to the keyboard */
  76134. get connectedInputText(): BABYLON.Nullable<InputText>;
  76135. /**
  76136. * Connects the keyboard with an input text control
  76137. *
  76138. * @param input defines the target control
  76139. */
  76140. connect(input: InputText): void;
  76141. /**
  76142. * Disconnects the keyboard from connected InputText controls
  76143. *
  76144. * @param input optionally defines a target control, otherwise all are disconnected
  76145. */
  76146. disconnect(input?: InputText): void;
  76147. private _removeConnectedInputObservables;
  76148. /**
  76149. * Release all resources
  76150. */
  76151. dispose(): void;
  76152. /**
  76153. * Creates a new keyboard using a default layout
  76154. *
  76155. * @param name defines control name
  76156. * @returns a new VirtualKeyboard
  76157. */
  76158. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  76159. }
  76160. }
  76161. declare module BABYLON.GUI {
  76162. /**
  76163. * Class used to create input text control
  76164. */
  76165. export class InputText extends Control implements IFocusableControl {
  76166. name?: string | undefined;
  76167. private _text;
  76168. private _placeholderText;
  76169. private _background;
  76170. private _focusedBackground;
  76171. private _focusedColor;
  76172. private _placeholderColor;
  76173. private _thickness;
  76174. private _margin;
  76175. private _autoStretchWidth;
  76176. private _maxWidth;
  76177. private _isFocused;
  76178. private _blinkTimeout;
  76179. private _blinkIsEven;
  76180. private _cursorOffset;
  76181. private _scrollLeft;
  76182. private _textWidth;
  76183. private _clickedCoordinate;
  76184. private _deadKey;
  76185. private _addKey;
  76186. private _currentKey;
  76187. private _isTextHighlightOn;
  76188. private _textHighlightColor;
  76189. private _highligherOpacity;
  76190. private _highlightedText;
  76191. private _startHighlightIndex;
  76192. private _endHighlightIndex;
  76193. private _cursorIndex;
  76194. private _onFocusSelectAll;
  76195. private _isPointerDown;
  76196. private _onClipboardObserver;
  76197. private _onPointerDblTapObserver;
  76198. /** @hidden */
  76199. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  76200. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  76201. promptMessage: string;
  76202. /** Force disable prompt on mobile device */
  76203. disableMobilePrompt: boolean;
  76204. /** BABYLON.Observable raised when the text changes */
  76205. onTextChangedObservable: BABYLON.Observable<InputText>;
  76206. /** BABYLON.Observable raised just before an entered character is to be added */
  76207. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  76208. /** BABYLON.Observable raised when the control gets the focus */
  76209. onFocusObservable: BABYLON.Observable<InputText>;
  76210. /** BABYLON.Observable raised when the control loses the focus */
  76211. onBlurObservable: BABYLON.Observable<InputText>;
  76212. /**Observable raised when the text is highlighted */
  76213. onTextHighlightObservable: BABYLON.Observable<InputText>;
  76214. /**Observable raised when copy event is triggered */
  76215. onTextCopyObservable: BABYLON.Observable<InputText>;
  76216. /** BABYLON.Observable raised when cut event is triggered */
  76217. onTextCutObservable: BABYLON.Observable<InputText>;
  76218. /** BABYLON.Observable raised when paste event is triggered */
  76219. onTextPasteObservable: BABYLON.Observable<InputText>;
  76220. /** BABYLON.Observable raised when a key event was processed */
  76221. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  76222. /** Gets or sets the maximum width allowed by the control */
  76223. get maxWidth(): string | number;
  76224. /** Gets the maximum width allowed by the control in pixels */
  76225. get maxWidthInPixels(): number;
  76226. set maxWidth(value: string | number);
  76227. /** Gets or sets the text highlighter transparency; default: 0.4 */
  76228. get highligherOpacity(): number;
  76229. set highligherOpacity(value: number);
  76230. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  76231. get onFocusSelectAll(): boolean;
  76232. set onFocusSelectAll(value: boolean);
  76233. /** Gets or sets the text hightlight color */
  76234. get textHighlightColor(): string;
  76235. set textHighlightColor(value: string);
  76236. /** Gets or sets control margin */
  76237. get margin(): string;
  76238. /** Gets control margin in pixels */
  76239. get marginInPixels(): number;
  76240. set margin(value: string);
  76241. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  76242. get autoStretchWidth(): boolean;
  76243. set autoStretchWidth(value: boolean);
  76244. /** Gets or sets border thickness */
  76245. get thickness(): number;
  76246. set thickness(value: number);
  76247. /** Gets or sets the background color when focused */
  76248. get focusedBackground(): string;
  76249. set focusedBackground(value: string);
  76250. /** Gets or sets the background color when focused */
  76251. get focusedColor(): string;
  76252. set focusedColor(value: string);
  76253. /** Gets or sets the background color */
  76254. get background(): string;
  76255. set background(value: string);
  76256. /** Gets or sets the placeholder color */
  76257. get placeholderColor(): string;
  76258. set placeholderColor(value: string);
  76259. /** Gets or sets the text displayed when the control is empty */
  76260. get placeholderText(): string;
  76261. set placeholderText(value: string);
  76262. /** Gets or sets the dead key flag */
  76263. get deadKey(): boolean;
  76264. set deadKey(flag: boolean);
  76265. /** Gets or sets the highlight text */
  76266. get highlightedText(): string;
  76267. set highlightedText(text: string);
  76268. /** Gets or sets if the current key should be added */
  76269. get addKey(): boolean;
  76270. set addKey(flag: boolean);
  76271. /** Gets or sets the value of the current key being entered */
  76272. get currentKey(): string;
  76273. set currentKey(key: string);
  76274. /** Gets or sets the text displayed in the control */
  76275. get text(): string;
  76276. set text(value: string);
  76277. /** Gets or sets control width */
  76278. get width(): string | number;
  76279. set width(value: string | number);
  76280. /**
  76281. * Creates a new InputText
  76282. * @param name defines the control name
  76283. * @param text defines the text of the control
  76284. */
  76285. constructor(name?: string | undefined, text?: string);
  76286. /** @hidden */
  76287. onBlur(): void;
  76288. /** @hidden */
  76289. onFocus(): void;
  76290. protected _getTypeName(): string;
  76291. /**
  76292. * Function called to get the list of controls that should not steal the focus from this control
  76293. * @returns an array of controls
  76294. */
  76295. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  76296. /** @hidden */
  76297. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  76298. /** @hidden */
  76299. private _updateValueFromCursorIndex;
  76300. /** @hidden */
  76301. private _processDblClick;
  76302. /** @hidden */
  76303. private _selectAllText;
  76304. /**
  76305. * Handles the keyboard event
  76306. * @param evt Defines the KeyboardEvent
  76307. */
  76308. processKeyboard(evt: KeyboardEvent): void;
  76309. /** @hidden */
  76310. private _onCopyText;
  76311. /** @hidden */
  76312. private _onCutText;
  76313. /** @hidden */
  76314. private _onPasteText;
  76315. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76316. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76317. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76318. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76319. protected _beforeRenderText(text: string): string;
  76320. dispose(): void;
  76321. }
  76322. }
  76323. declare module BABYLON.GUI {
  76324. /**
  76325. * Class used to create a 2D grid container
  76326. */
  76327. export class Grid extends Container {
  76328. name?: string | undefined;
  76329. private _rowDefinitions;
  76330. private _columnDefinitions;
  76331. private _cells;
  76332. private _childControls;
  76333. /**
  76334. * Gets the number of columns
  76335. */
  76336. get columnCount(): number;
  76337. /**
  76338. * Gets the number of rows
  76339. */
  76340. get rowCount(): number;
  76341. /** Gets the list of children */
  76342. get children(): Control[];
  76343. /** Gets the list of cells (e.g. the containers) */
  76344. get cells(): {
  76345. [key: string]: Container;
  76346. };
  76347. /**
  76348. * Gets the definition of a specific row
  76349. * @param index defines the index of the row
  76350. * @returns the row definition
  76351. */
  76352. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  76353. /**
  76354. * Gets the definition of a specific column
  76355. * @param index defines the index of the column
  76356. * @returns the column definition
  76357. */
  76358. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  76359. /**
  76360. * Adds a new row to the grid
  76361. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  76362. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  76363. * @returns the current grid
  76364. */
  76365. addRowDefinition(height: number, isPixel?: boolean): Grid;
  76366. /**
  76367. * Adds a new column to the grid
  76368. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  76369. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  76370. * @returns the current grid
  76371. */
  76372. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  76373. /**
  76374. * Update a row definition
  76375. * @param index defines the index of the row to update
  76376. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  76377. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  76378. * @returns the current grid
  76379. */
  76380. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  76381. /**
  76382. * Update a column definition
  76383. * @param index defines the index of the column to update
  76384. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  76385. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  76386. * @returns the current grid
  76387. */
  76388. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  76389. /**
  76390. * Gets the list of children stored in a specific cell
  76391. * @param row defines the row to check
  76392. * @param column defines the column to check
  76393. * @returns the list of controls
  76394. */
  76395. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  76396. /**
  76397. * Gets a string representing the child cell info (row x column)
  76398. * @param child defines the control to get info from
  76399. * @returns a string containing the child cell info (row x column)
  76400. */
  76401. getChildCellInfo(child: Control): string;
  76402. private _removeCell;
  76403. private _offsetCell;
  76404. /**
  76405. * Remove a column definition at specified index
  76406. * @param index defines the index of the column to remove
  76407. * @returns the current grid
  76408. */
  76409. removeColumnDefinition(index: number): Grid;
  76410. /**
  76411. * Remove a row definition at specified index
  76412. * @param index defines the index of the row to remove
  76413. * @returns the current grid
  76414. */
  76415. removeRowDefinition(index: number): Grid;
  76416. /**
  76417. * Adds a new control to the current grid
  76418. * @param control defines the control to add
  76419. * @param row defines the row where to add the control (0 by default)
  76420. * @param column defines the column where to add the control (0 by default)
  76421. * @returns the current grid
  76422. */
  76423. addControl(control: Control, row?: number, column?: number): Grid;
  76424. /**
  76425. * Removes a control from the current container
  76426. * @param control defines the control to remove
  76427. * @returns the current container
  76428. */
  76429. removeControl(control: Control): Container;
  76430. /**
  76431. * Creates a new Grid
  76432. * @param name defines control name
  76433. */
  76434. constructor(name?: string | undefined);
  76435. protected _getTypeName(): string;
  76436. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  76437. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76438. _flagDescendantsAsMatrixDirty(): void;
  76439. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  76440. /** Releases associated resources */
  76441. dispose(): void;
  76442. }
  76443. }
  76444. declare module BABYLON.GUI {
  76445. /** Class used to create color pickers */
  76446. export class ColorPicker extends Control {
  76447. name?: string | undefined;
  76448. private static _Epsilon;
  76449. private _colorWheelCanvas;
  76450. private _value;
  76451. private _tmpColor;
  76452. private _pointerStartedOnSquare;
  76453. private _pointerStartedOnWheel;
  76454. private _squareLeft;
  76455. private _squareTop;
  76456. private _squareSize;
  76457. private _h;
  76458. private _s;
  76459. private _v;
  76460. private _lastPointerDownID;
  76461. /**
  76462. * BABYLON.Observable raised when the value changes
  76463. */
  76464. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  76465. /** Gets or sets the color of the color picker */
  76466. get value(): BABYLON.Color3;
  76467. set value(value: BABYLON.Color3);
  76468. /**
  76469. * Gets or sets control width
  76470. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  76471. */
  76472. get width(): string | number;
  76473. set width(value: string | number);
  76474. /**
  76475. * Gets or sets control height
  76476. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  76477. */
  76478. get height(): string | number;
  76479. /** Gets or sets control height */
  76480. set height(value: string | number);
  76481. /** Gets or sets control size */
  76482. get size(): string | number;
  76483. set size(value: string | number);
  76484. /**
  76485. * Creates a new ColorPicker
  76486. * @param name defines the control name
  76487. */
  76488. constructor(name?: string | undefined);
  76489. protected _getTypeName(): string;
  76490. /** @hidden */
  76491. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76492. private _updateSquareProps;
  76493. private _drawGradientSquare;
  76494. private _drawCircle;
  76495. private _createColorWheelCanvas;
  76496. /** @hidden */
  76497. _draw(context: CanvasRenderingContext2D): void;
  76498. private _pointerIsDown;
  76499. private _updateValueFromPointer;
  76500. private _isPointOnSquare;
  76501. private _isPointOnWheel;
  76502. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76503. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76504. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76505. /**
  76506. * This function expands the color picker by creating a color picker dialog with manual
  76507. * color value input and the ability to save colors into an array to be used later in
  76508. * subsequent launches of the dialogue.
  76509. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  76510. * @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.
  76511. * @returns picked color as a hex string and the saved colors array as hex strings.
  76512. */
  76513. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  76514. pickerWidth?: string;
  76515. pickerHeight?: string;
  76516. headerHeight?: string;
  76517. lastColor?: string;
  76518. swatchLimit?: number;
  76519. numSwatchesPerLine?: number;
  76520. savedColors?: Array<string>;
  76521. }): Promise<{
  76522. savedColors?: string[];
  76523. pickedColor: string;
  76524. }>;
  76525. }
  76526. }
  76527. declare module BABYLON.GUI {
  76528. /** Class used to create 2D ellipse containers */
  76529. export class Ellipse extends Container {
  76530. name?: string | undefined;
  76531. private _thickness;
  76532. /** Gets or sets border thickness */
  76533. get thickness(): number;
  76534. set thickness(value: number);
  76535. /**
  76536. * Creates a new Ellipse
  76537. * @param name defines the control name
  76538. */
  76539. constructor(name?: string | undefined);
  76540. protected _getTypeName(): string;
  76541. protected _localDraw(context: CanvasRenderingContext2D): void;
  76542. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76543. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  76544. }
  76545. }
  76546. declare module BABYLON.GUI {
  76547. /**
  76548. * Class used to create a password control
  76549. */
  76550. export class InputPassword extends InputText {
  76551. protected _beforeRenderText(text: string): string;
  76552. }
  76553. }
  76554. declare module BABYLON.GUI {
  76555. /** Class used to render 2D lines */
  76556. export class Line extends Control {
  76557. name?: string | undefined;
  76558. private _lineWidth;
  76559. private _x1;
  76560. private _y1;
  76561. private _x2;
  76562. private _y2;
  76563. private _dash;
  76564. private _connectedControl;
  76565. private _connectedControlDirtyObserver;
  76566. /** Gets or sets the dash pattern */
  76567. get dash(): Array<number>;
  76568. set dash(value: Array<number>);
  76569. /** Gets or sets the control connected with the line end */
  76570. get connectedControl(): Control;
  76571. set connectedControl(value: Control);
  76572. /** Gets or sets start coordinates on X axis */
  76573. get x1(): string | number;
  76574. set x1(value: string | number);
  76575. /** Gets or sets start coordinates on Y axis */
  76576. get y1(): string | number;
  76577. set y1(value: string | number);
  76578. /** Gets or sets end coordinates on X axis */
  76579. get x2(): string | number;
  76580. set x2(value: string | number);
  76581. /** Gets or sets end coordinates on Y axis */
  76582. get y2(): string | number;
  76583. set y2(value: string | number);
  76584. /** Gets or sets line width */
  76585. get lineWidth(): number;
  76586. set lineWidth(value: number);
  76587. /** Gets or sets horizontal alignment */
  76588. set horizontalAlignment(value: number);
  76589. /** Gets or sets vertical alignment */
  76590. set verticalAlignment(value: number);
  76591. private get _effectiveX2();
  76592. private get _effectiveY2();
  76593. /**
  76594. * Creates a new Line
  76595. * @param name defines the control name
  76596. */
  76597. constructor(name?: string | undefined);
  76598. protected _getTypeName(): string;
  76599. _draw(context: CanvasRenderingContext2D): void;
  76600. _measure(): void;
  76601. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76602. /**
  76603. * Move one end of the line given 3D cartesian coordinates.
  76604. * @param position Targeted world position
  76605. * @param scene BABYLON.Scene
  76606. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  76607. */
  76608. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  76609. /**
  76610. * Move one end of the line to a position in screen absolute space.
  76611. * @param projectedPosition Position in screen absolute space (X, Y)
  76612. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  76613. */
  76614. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  76615. }
  76616. }
  76617. declare module BABYLON.GUI {
  76618. /**
  76619. * Class used to store a point for a MultiLine object.
  76620. * The point can be pure 2D coordinates, a mesh or a control
  76621. */
  76622. export class MultiLinePoint {
  76623. private _multiLine;
  76624. private _x;
  76625. private _y;
  76626. private _control;
  76627. private _mesh;
  76628. private _controlObserver;
  76629. private _meshObserver;
  76630. /** @hidden */
  76631. _point: BABYLON.Vector2;
  76632. /**
  76633. * Creates a new MultiLinePoint
  76634. * @param multiLine defines the source MultiLine object
  76635. */
  76636. constructor(multiLine: MultiLine);
  76637. /** Gets or sets x coordinate */
  76638. get x(): string | number;
  76639. set x(value: string | number);
  76640. /** Gets or sets y coordinate */
  76641. get y(): string | number;
  76642. set y(value: string | number);
  76643. /** Gets or sets the control associated with this point */
  76644. get control(): BABYLON.Nullable<Control>;
  76645. set control(value: BABYLON.Nullable<Control>);
  76646. /** Gets or sets the mesh associated with this point */
  76647. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  76648. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  76649. /** Resets links */
  76650. resetLinks(): void;
  76651. /**
  76652. * Gets a translation vector
  76653. * @returns the translation vector
  76654. */
  76655. translate(): BABYLON.Vector2;
  76656. private _translatePoint;
  76657. /** Release associated resources */
  76658. dispose(): void;
  76659. }
  76660. }
  76661. declare module BABYLON.GUI {
  76662. /**
  76663. * Class used to create multi line control
  76664. */
  76665. export class MultiLine extends Control {
  76666. name?: string | undefined;
  76667. private _lineWidth;
  76668. private _dash;
  76669. private _points;
  76670. private _minX;
  76671. private _minY;
  76672. private _maxX;
  76673. private _maxY;
  76674. /**
  76675. * Creates a new MultiLine
  76676. * @param name defines the control name
  76677. */
  76678. constructor(name?: string | undefined);
  76679. /** Gets or sets dash pattern */
  76680. get dash(): Array<number>;
  76681. set dash(value: Array<number>);
  76682. /**
  76683. * Gets point stored at specified index
  76684. * @param index defines the index to look for
  76685. * @returns the requested point if found
  76686. */
  76687. getAt(index: number): MultiLinePoint;
  76688. /** Function called when a point is updated */
  76689. onPointUpdate: () => void;
  76690. /**
  76691. * Adds new points to the point collection
  76692. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  76693. * @returns the list of created MultiLinePoint
  76694. */
  76695. add(...items: (AbstractMesh | Control | {
  76696. x: string | number;
  76697. y: string | number;
  76698. })[]): MultiLinePoint[];
  76699. /**
  76700. * Adds a new point to the point collection
  76701. * @param item defines the item (mesh, control or 2d coordiantes) to add
  76702. * @returns the created MultiLinePoint
  76703. */
  76704. push(item?: (AbstractMesh | Control | {
  76705. x: string | number;
  76706. y: string | number;
  76707. })): MultiLinePoint;
  76708. /**
  76709. * Remove a specific value or point from the active point collection
  76710. * @param value defines the value or point to remove
  76711. */
  76712. remove(value: number | MultiLinePoint): void;
  76713. /**
  76714. * Resets this object to initial state (no point)
  76715. */
  76716. reset(): void;
  76717. /**
  76718. * Resets all links
  76719. */
  76720. resetLinks(): void;
  76721. /** Gets or sets line width */
  76722. get lineWidth(): number;
  76723. set lineWidth(value: number);
  76724. set horizontalAlignment(value: number);
  76725. set verticalAlignment(value: number);
  76726. protected _getTypeName(): string;
  76727. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76728. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76729. _measure(): void;
  76730. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76731. dispose(): void;
  76732. }
  76733. }
  76734. declare module BABYLON.GUI {
  76735. /**
  76736. * Class used to create radio button controls
  76737. */
  76738. export class RadioButton extends Control {
  76739. name?: string | undefined;
  76740. private _isChecked;
  76741. private _background;
  76742. private _checkSizeRatio;
  76743. private _thickness;
  76744. /** Gets or sets border thickness */
  76745. get thickness(): number;
  76746. set thickness(value: number);
  76747. /** Gets or sets group name */
  76748. group: string;
  76749. /** BABYLON.Observable raised when isChecked is changed */
  76750. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  76751. /** Gets or sets a value indicating the ratio between overall size and check size */
  76752. get checkSizeRatio(): number;
  76753. set checkSizeRatio(value: number);
  76754. /** Gets or sets background color */
  76755. get background(): string;
  76756. set background(value: string);
  76757. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  76758. get isChecked(): boolean;
  76759. set isChecked(value: boolean);
  76760. /**
  76761. * Creates a new RadioButton
  76762. * @param name defines the control name
  76763. */
  76764. constructor(name?: string | undefined);
  76765. protected _getTypeName(): string;
  76766. _draw(context: CanvasRenderingContext2D): void;
  76767. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76768. /**
  76769. * Utility function to easily create a radio button with a header
  76770. * @param title defines the label to use for the header
  76771. * @param group defines the group to use for the radio button
  76772. * @param isChecked defines the initial state of the radio button
  76773. * @param onValueChanged defines the callback to call when value changes
  76774. * @returns a StackPanel containing the radio button and a textBlock
  76775. */
  76776. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  76777. }
  76778. }
  76779. declare module BABYLON.GUI {
  76780. /**
  76781. * Class used to create slider controls
  76782. */
  76783. export class BaseSlider extends Control {
  76784. name?: string | undefined;
  76785. protected _thumbWidth: ValueAndUnit;
  76786. private _minimum;
  76787. private _maximum;
  76788. private _value;
  76789. private _isVertical;
  76790. protected _barOffset: ValueAndUnit;
  76791. private _isThumbClamped;
  76792. protected _displayThumb: boolean;
  76793. private _step;
  76794. private _lastPointerDownID;
  76795. protected _effectiveBarOffset: number;
  76796. protected _renderLeft: number;
  76797. protected _renderTop: number;
  76798. protected _renderWidth: number;
  76799. protected _renderHeight: number;
  76800. protected _backgroundBoxLength: number;
  76801. protected _backgroundBoxThickness: number;
  76802. protected _effectiveThumbThickness: number;
  76803. /** BABYLON.Observable raised when the sldier value changes */
  76804. onValueChangedObservable: BABYLON.Observable<number>;
  76805. /** Gets or sets a boolean indicating if the thumb must be rendered */
  76806. get displayThumb(): boolean;
  76807. set displayThumb(value: boolean);
  76808. /** Gets or sets a step to apply to values (0 by default) */
  76809. get step(): number;
  76810. set step(value: number);
  76811. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  76812. get barOffset(): string | number;
  76813. /** Gets main bar offset in pixels*/
  76814. get barOffsetInPixels(): number;
  76815. set barOffset(value: string | number);
  76816. /** Gets or sets thumb width */
  76817. get thumbWidth(): string | number;
  76818. /** Gets thumb width in pixels */
  76819. get thumbWidthInPixels(): number;
  76820. set thumbWidth(value: string | number);
  76821. /** Gets or sets minimum value */
  76822. get minimum(): number;
  76823. set minimum(value: number);
  76824. /** Gets or sets maximum value */
  76825. get maximum(): number;
  76826. set maximum(value: number);
  76827. /** Gets or sets current value */
  76828. get value(): number;
  76829. set value(value: number);
  76830. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  76831. get isVertical(): boolean;
  76832. set isVertical(value: boolean);
  76833. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  76834. get isThumbClamped(): boolean;
  76835. set isThumbClamped(value: boolean);
  76836. /**
  76837. * Creates a new BaseSlider
  76838. * @param name defines the control name
  76839. */
  76840. constructor(name?: string | undefined);
  76841. protected _getTypeName(): string;
  76842. protected _getThumbPosition(): number;
  76843. protected _getThumbThickness(type: string): number;
  76844. protected _prepareRenderingData(type: string): void;
  76845. private _pointerIsDown;
  76846. /** @hidden */
  76847. protected _updateValueFromPointer(x: number, y: number): void;
  76848. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76849. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76850. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76851. }
  76852. }
  76853. declare module BABYLON.GUI {
  76854. /**
  76855. * Class used to create slider controls
  76856. */
  76857. export class Slider extends BaseSlider {
  76858. name?: string | undefined;
  76859. private _background;
  76860. private _borderColor;
  76861. private _isThumbCircle;
  76862. protected _displayValueBar: boolean;
  76863. /** Gets or sets a boolean indicating if the value bar must be rendered */
  76864. get displayValueBar(): boolean;
  76865. set displayValueBar(value: boolean);
  76866. /** Gets or sets border color */
  76867. get borderColor(): string;
  76868. set borderColor(value: string);
  76869. /** Gets or sets background color */
  76870. get background(): string;
  76871. set background(value: string);
  76872. /** Gets or sets a boolean indicating if the thumb should be round or square */
  76873. get isThumbCircle(): boolean;
  76874. set isThumbCircle(value: boolean);
  76875. /**
  76876. * Creates a new Slider
  76877. * @param name defines the control name
  76878. */
  76879. constructor(name?: string | undefined);
  76880. protected _getTypeName(): string;
  76881. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76882. }
  76883. }
  76884. declare module BABYLON.GUI {
  76885. /** Class used to create a RadioGroup
  76886. * which contains groups of radio buttons
  76887. */
  76888. export class SelectorGroup {
  76889. /** name of SelectorGroup */
  76890. name: string;
  76891. private _groupPanel;
  76892. private _selectors;
  76893. private _groupHeader;
  76894. /**
  76895. * Creates a new SelectorGroup
  76896. * @param name of group, used as a group heading
  76897. */
  76898. constructor(
  76899. /** name of SelectorGroup */
  76900. name: string);
  76901. /** Gets the groupPanel of the SelectorGroup */
  76902. get groupPanel(): StackPanel;
  76903. /** Gets the selectors array */
  76904. get selectors(): StackPanel[];
  76905. /** Gets and sets the group header */
  76906. get header(): string;
  76907. set header(label: string);
  76908. /** @hidden */
  76909. private _addGroupHeader;
  76910. /** @hidden*/
  76911. _getSelector(selectorNb: number): StackPanel | undefined;
  76912. /** Removes the selector at the given position
  76913. * @param selectorNb the position of the selector within the group
  76914. */
  76915. removeSelector(selectorNb: number): void;
  76916. }
  76917. /** Class used to create a CheckboxGroup
  76918. * which contains groups of checkbox buttons
  76919. */
  76920. export class CheckboxGroup extends SelectorGroup {
  76921. /** Adds a checkbox as a control
  76922. * @param text is the label for the selector
  76923. * @param func is the function called when the Selector is checked
  76924. * @param checked is true when Selector is checked
  76925. */
  76926. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  76927. /** @hidden */
  76928. _setSelectorLabel(selectorNb: number, label: string): void;
  76929. /** @hidden */
  76930. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76931. /** @hidden */
  76932. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76933. /** @hidden */
  76934. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76935. }
  76936. /** Class used to create a RadioGroup
  76937. * which contains groups of radio buttons
  76938. */
  76939. export class RadioGroup extends SelectorGroup {
  76940. private _selectNb;
  76941. /** Adds a radio button as a control
  76942. * @param label is the label for the selector
  76943. * @param func is the function called when the Selector is checked
  76944. * @param checked is true when Selector is checked
  76945. */
  76946. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  76947. /** @hidden */
  76948. _setSelectorLabel(selectorNb: number, label: string): void;
  76949. /** @hidden */
  76950. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76951. /** @hidden */
  76952. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76953. /** @hidden */
  76954. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76955. }
  76956. /** Class used to create a SliderGroup
  76957. * which contains groups of slider buttons
  76958. */
  76959. export class SliderGroup extends SelectorGroup {
  76960. /**
  76961. * Adds a slider to the SelectorGroup
  76962. * @param label is the label for the SliderBar
  76963. * @param func is the function called when the Slider moves
  76964. * @param unit is a string describing the units used, eg degrees or metres
  76965. * @param min is the minimum value for the Slider
  76966. * @param max is the maximum value for the Slider
  76967. * @param value is the start value for the Slider between min and max
  76968. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  76969. */
  76970. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  76971. /** @hidden */
  76972. _setSelectorLabel(selectorNb: number, label: string): void;
  76973. /** @hidden */
  76974. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76975. /** @hidden */
  76976. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76977. /** @hidden */
  76978. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76979. }
  76980. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  76981. * @see http://doc.babylonjs.com/how_to/selector
  76982. */
  76983. export class SelectionPanel extends Rectangle {
  76984. /** name of SelectionPanel */
  76985. name: string;
  76986. /** an array of SelectionGroups */
  76987. groups: SelectorGroup[];
  76988. private _panel;
  76989. private _buttonColor;
  76990. private _buttonBackground;
  76991. private _headerColor;
  76992. private _barColor;
  76993. private _barHeight;
  76994. private _spacerHeight;
  76995. private _labelColor;
  76996. private _groups;
  76997. private _bars;
  76998. /**
  76999. * Creates a new SelectionPanel
  77000. * @param name of SelectionPanel
  77001. * @param groups is an array of SelectionGroups
  77002. */
  77003. constructor(
  77004. /** name of SelectionPanel */
  77005. name: string,
  77006. /** an array of SelectionGroups */
  77007. groups?: SelectorGroup[]);
  77008. protected _getTypeName(): string;
  77009. /** Gets or sets the headerColor */
  77010. get headerColor(): string;
  77011. set headerColor(color: string);
  77012. private _setHeaderColor;
  77013. /** Gets or sets the button color */
  77014. get buttonColor(): string;
  77015. set buttonColor(color: string);
  77016. private _setbuttonColor;
  77017. /** Gets or sets the label color */
  77018. get labelColor(): string;
  77019. set labelColor(color: string);
  77020. private _setLabelColor;
  77021. /** Gets or sets the button background */
  77022. get buttonBackground(): string;
  77023. set buttonBackground(color: string);
  77024. private _setButtonBackground;
  77025. /** Gets or sets the color of separator bar */
  77026. get barColor(): string;
  77027. set barColor(color: string);
  77028. private _setBarColor;
  77029. /** Gets or sets the height of separator bar */
  77030. get barHeight(): string;
  77031. set barHeight(value: string);
  77032. private _setBarHeight;
  77033. /** Gets or sets the height of spacers*/
  77034. get spacerHeight(): string;
  77035. set spacerHeight(value: string);
  77036. private _setSpacerHeight;
  77037. /** Adds a bar between groups */
  77038. private _addSpacer;
  77039. /** Add a group to the selection panel
  77040. * @param group is the selector group to add
  77041. */
  77042. addGroup(group: SelectorGroup): void;
  77043. /** Remove the group from the given position
  77044. * @param groupNb is the position of the group in the list
  77045. */
  77046. removeGroup(groupNb: number): void;
  77047. /** Change a group header label
  77048. * @param label is the new group header label
  77049. * @param groupNb is the number of the group to relabel
  77050. * */
  77051. setHeaderName(label: string, groupNb: number): void;
  77052. /** Change selector label to the one given
  77053. * @param label is the new selector label
  77054. * @param groupNb is the number of the groupcontaining the selector
  77055. * @param selectorNb is the number of the selector within a group to relabel
  77056. * */
  77057. relabel(label: string, groupNb: number, selectorNb: number): void;
  77058. /** For a given group position remove the selector at the given position
  77059. * @param groupNb is the number of the group to remove the selector from
  77060. * @param selectorNb is the number of the selector within the group
  77061. */
  77062. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  77063. /** For a given group position of correct type add a checkbox button
  77064. * @param groupNb is the number of the group to remove the selector from
  77065. * @param label is the label for the selector
  77066. * @param func is the function called when the Selector is checked
  77067. * @param checked is true when Selector is checked
  77068. */
  77069. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  77070. /** For a given group position of correct type add a radio button
  77071. * @param groupNb is the number of the group to remove the selector from
  77072. * @param label is the label for the selector
  77073. * @param func is the function called when the Selector is checked
  77074. * @param checked is true when Selector is checked
  77075. */
  77076. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  77077. /**
  77078. * For a given slider group add a slider
  77079. * @param groupNb is the number of the group to add the slider to
  77080. * @param label is the label for the Slider
  77081. * @param func is the function called when the Slider moves
  77082. * @param unit is a string describing the units used, eg degrees or metres
  77083. * @param min is the minimum value for the Slider
  77084. * @param max is the maximum value for the Slider
  77085. * @param value is the start value for the Slider between min and max
  77086. * @param onVal is the function used to format the value displayed, eg radians to degrees
  77087. */
  77088. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  77089. }
  77090. }
  77091. declare module BABYLON.GUI {
  77092. /**
  77093. * Class used to hold a the container for ScrollViewer
  77094. * @hidden
  77095. */
  77096. export class _ScrollViewerWindow extends Container {
  77097. parentClientWidth: number;
  77098. parentClientHeight: number;
  77099. private _freezeControls;
  77100. private _parentMeasure;
  77101. private _oldLeft;
  77102. private _oldTop;
  77103. get freezeControls(): boolean;
  77104. set freezeControls(value: boolean);
  77105. private _bucketWidth;
  77106. private _bucketHeight;
  77107. private _buckets;
  77108. private _bucketLen;
  77109. get bucketWidth(): number;
  77110. get bucketHeight(): number;
  77111. setBucketSizes(width: number, height: number): void;
  77112. private _useBuckets;
  77113. private _makeBuckets;
  77114. private _dispatchInBuckets;
  77115. private _updateMeasures;
  77116. private _updateChildrenMeasures;
  77117. private _restoreMeasures;
  77118. /**
  77119. * Creates a new ScrollViewerWindow
  77120. * @param name of ScrollViewerWindow
  77121. */
  77122. constructor(name?: string);
  77123. protected _getTypeName(): string;
  77124. /** @hidden */
  77125. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77126. /** @hidden */
  77127. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  77128. private _scrollChildren;
  77129. private _scrollChildrenWithBuckets;
  77130. /** @hidden */
  77131. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  77132. protected _postMeasure(): void;
  77133. }
  77134. }
  77135. declare module BABYLON.GUI {
  77136. /**
  77137. * Class used to create slider controls
  77138. */
  77139. export class ScrollBar extends BaseSlider {
  77140. name?: string | undefined;
  77141. private _background;
  77142. private _borderColor;
  77143. private _tempMeasure;
  77144. /** Gets or sets border color */
  77145. get borderColor(): string;
  77146. set borderColor(value: string);
  77147. /** Gets or sets background color */
  77148. get background(): string;
  77149. set background(value: string);
  77150. /**
  77151. * Creates a new Slider
  77152. * @param name defines the control name
  77153. */
  77154. constructor(name?: string | undefined);
  77155. protected _getTypeName(): string;
  77156. protected _getThumbThickness(): number;
  77157. _draw(context: CanvasRenderingContext2D): void;
  77158. private _first;
  77159. private _originX;
  77160. private _originY;
  77161. /** @hidden */
  77162. protected _updateValueFromPointer(x: number, y: number): void;
  77163. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77164. }
  77165. }
  77166. declare module BABYLON.GUI {
  77167. /**
  77168. * Class used to create slider controls
  77169. */
  77170. export class ImageScrollBar extends BaseSlider {
  77171. name?: string | undefined;
  77172. private _backgroundBaseImage;
  77173. private _backgroundImage;
  77174. private _thumbImage;
  77175. private _thumbBaseImage;
  77176. private _thumbLength;
  77177. private _thumbHeight;
  77178. private _barImageHeight;
  77179. private _tempMeasure;
  77180. /** Number of 90° rotation to apply on the images when in vertical mode */
  77181. num90RotationInVerticalMode: number;
  77182. /**
  77183. * Gets or sets the image used to render the background for horizontal bar
  77184. */
  77185. get backgroundImage(): Image;
  77186. set backgroundImage(value: Image);
  77187. /**
  77188. * Gets or sets the image used to render the thumb
  77189. */
  77190. get thumbImage(): Image;
  77191. set thumbImage(value: Image);
  77192. /**
  77193. * Gets or sets the length of the thumb
  77194. */
  77195. get thumbLength(): number;
  77196. set thumbLength(value: number);
  77197. /**
  77198. * Gets or sets the height of the thumb
  77199. */
  77200. get thumbHeight(): number;
  77201. set thumbHeight(value: number);
  77202. /**
  77203. * Gets or sets the height of the bar image
  77204. */
  77205. get barImageHeight(): number;
  77206. set barImageHeight(value: number);
  77207. /**
  77208. * Creates a new ImageScrollBar
  77209. * @param name defines the control name
  77210. */
  77211. constructor(name?: string | undefined);
  77212. protected _getTypeName(): string;
  77213. protected _getThumbThickness(): number;
  77214. _draw(context: CanvasRenderingContext2D): void;
  77215. private _first;
  77216. private _originX;
  77217. private _originY;
  77218. /** @hidden */
  77219. protected _updateValueFromPointer(x: number, y: number): void;
  77220. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77221. }
  77222. }
  77223. declare module BABYLON.GUI {
  77224. /**
  77225. * Class used to hold a viewer window and sliders in a grid
  77226. */
  77227. export class ScrollViewer extends Rectangle {
  77228. private _grid;
  77229. private _horizontalBarSpace;
  77230. private _verticalBarSpace;
  77231. private _dragSpace;
  77232. private _horizontalBar;
  77233. private _verticalBar;
  77234. private _barColor;
  77235. private _barBackground;
  77236. private _barImage;
  77237. private _horizontalBarImage;
  77238. private _verticalBarImage;
  77239. private _barBackgroundImage;
  77240. private _horizontalBarBackgroundImage;
  77241. private _verticalBarBackgroundImage;
  77242. private _barSize;
  77243. private _window;
  77244. private _pointerIsOver;
  77245. private _wheelPrecision;
  77246. private _onWheelObserver;
  77247. private _clientWidth;
  77248. private _clientHeight;
  77249. private _useImageBar;
  77250. private _thumbLength;
  77251. private _thumbHeight;
  77252. private _barImageHeight;
  77253. private _horizontalBarImageHeight;
  77254. private _verticalBarImageHeight;
  77255. private _oldWindowContentsWidth;
  77256. private _oldWindowContentsHeight;
  77257. /**
  77258. * Gets the horizontal scrollbar
  77259. */
  77260. get horizontalBar(): ScrollBar | ImageScrollBar;
  77261. /**
  77262. * Gets the vertical scrollbar
  77263. */
  77264. get verticalBar(): ScrollBar | ImageScrollBar;
  77265. /**
  77266. * Adds a new control to the current container
  77267. * @param control defines the control to add
  77268. * @returns the current container
  77269. */
  77270. addControl(control: BABYLON.Nullable<Control>): Container;
  77271. /**
  77272. * Removes a control from the current container
  77273. * @param control defines the control to remove
  77274. * @returns the current container
  77275. */
  77276. removeControl(control: Control): Container;
  77277. /** Gets the list of children */
  77278. get children(): Control[];
  77279. _flagDescendantsAsMatrixDirty(): void;
  77280. /**
  77281. * Freezes or unfreezes the controls in the window.
  77282. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  77283. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  77284. */
  77285. get freezeControls(): boolean;
  77286. set freezeControls(value: boolean);
  77287. /** Gets the bucket width */
  77288. get bucketWidth(): number;
  77289. /** Gets the bucket height */
  77290. get bucketHeight(): number;
  77291. /**
  77292. * Sets the bucket sizes.
  77293. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  77294. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  77295. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  77296. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  77297. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  77298. * used), that's why it is not enabled by default.
  77299. * @param width width of the bucket
  77300. * @param height height of the bucket
  77301. */
  77302. setBucketSizes(width: number, height: number): void;
  77303. private _forceHorizontalBar;
  77304. private _forceVerticalBar;
  77305. /**
  77306. * Forces the horizontal scroll bar to be displayed
  77307. */
  77308. get forceHorizontalBar(): boolean;
  77309. set forceHorizontalBar(value: boolean);
  77310. /**
  77311. * Forces the vertical scroll bar to be displayed
  77312. */
  77313. get forceVerticalBar(): boolean;
  77314. set forceVerticalBar(value: boolean);
  77315. /**
  77316. * Creates a new ScrollViewer
  77317. * @param name of ScrollViewer
  77318. */
  77319. constructor(name?: string, isImageBased?: boolean);
  77320. /** Reset the scroll viewer window to initial size */
  77321. resetWindow(): void;
  77322. protected _getTypeName(): string;
  77323. private _buildClientSizes;
  77324. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77325. protected _postMeasure(): void;
  77326. /**
  77327. * Gets or sets the mouse wheel precision
  77328. * from 0 to 1 with a default value of 0.05
  77329. * */
  77330. get wheelPrecision(): number;
  77331. set wheelPrecision(value: number);
  77332. /** Gets or sets the scroll bar container background color */
  77333. get scrollBackground(): string;
  77334. set scrollBackground(color: string);
  77335. /** Gets or sets the bar color */
  77336. get barColor(): string;
  77337. set barColor(color: string);
  77338. /** Gets or sets the bar image */
  77339. get thumbImage(): Image;
  77340. set thumbImage(value: Image);
  77341. /** Gets or sets the horizontal bar image */
  77342. get horizontalThumbImage(): Image;
  77343. set horizontalThumbImage(value: Image);
  77344. /** Gets or sets the vertical bar image */
  77345. get verticalThumbImage(): Image;
  77346. set verticalThumbImage(value: Image);
  77347. /** Gets or sets the size of the bar */
  77348. get barSize(): number;
  77349. set barSize(value: number);
  77350. /** Gets or sets the length of the thumb */
  77351. get thumbLength(): number;
  77352. set thumbLength(value: number);
  77353. /** Gets or sets the height of the thumb */
  77354. get thumbHeight(): number;
  77355. set thumbHeight(value: number);
  77356. /** Gets or sets the height of the bar image */
  77357. get barImageHeight(): number;
  77358. set barImageHeight(value: number);
  77359. /** Gets or sets the height of the horizontal bar image */
  77360. get horizontalBarImageHeight(): number;
  77361. set horizontalBarImageHeight(value: number);
  77362. /** Gets or sets the height of the vertical bar image */
  77363. get verticalBarImageHeight(): number;
  77364. set verticalBarImageHeight(value: number);
  77365. /** Gets or sets the bar background */
  77366. get barBackground(): string;
  77367. set barBackground(color: string);
  77368. /** Gets or sets the bar background image */
  77369. get barImage(): Image;
  77370. set barImage(value: Image);
  77371. /** Gets or sets the horizontal bar background image */
  77372. get horizontalBarImage(): Image;
  77373. set horizontalBarImage(value: Image);
  77374. /** Gets or sets the vertical bar background image */
  77375. get verticalBarImage(): Image;
  77376. set verticalBarImage(value: Image);
  77377. private _setWindowPosition;
  77378. /** @hidden */
  77379. private _updateScroller;
  77380. _link(host: AdvancedDynamicTexture): void;
  77381. /** @hidden */
  77382. private _addBar;
  77383. /** @hidden */
  77384. private _attachWheel;
  77385. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  77386. /** Releases associated resources */
  77387. dispose(): void;
  77388. }
  77389. }
  77390. declare module BABYLON.GUI {
  77391. /** Class used to render a grid */
  77392. export class DisplayGrid extends Control {
  77393. name?: string | undefined;
  77394. private _cellWidth;
  77395. private _cellHeight;
  77396. private _minorLineTickness;
  77397. private _minorLineColor;
  77398. private _majorLineTickness;
  77399. private _majorLineColor;
  77400. private _majorLineFrequency;
  77401. private _background;
  77402. private _displayMajorLines;
  77403. private _displayMinorLines;
  77404. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  77405. get displayMinorLines(): boolean;
  77406. set displayMinorLines(value: boolean);
  77407. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  77408. get displayMajorLines(): boolean;
  77409. set displayMajorLines(value: boolean);
  77410. /** Gets or sets background color (Black by default) */
  77411. get background(): string;
  77412. set background(value: string);
  77413. /** Gets or sets the width of each cell (20 by default) */
  77414. get cellWidth(): number;
  77415. set cellWidth(value: number);
  77416. /** Gets or sets the height of each cell (20 by default) */
  77417. get cellHeight(): number;
  77418. set cellHeight(value: number);
  77419. /** Gets or sets the tickness of minor lines (1 by default) */
  77420. get minorLineTickness(): number;
  77421. set minorLineTickness(value: number);
  77422. /** Gets or sets the color of minor lines (DarkGray by default) */
  77423. get minorLineColor(): string;
  77424. set minorLineColor(value: string);
  77425. /** Gets or sets the tickness of major lines (2 by default) */
  77426. get majorLineTickness(): number;
  77427. set majorLineTickness(value: number);
  77428. /** Gets or sets the color of major lines (White by default) */
  77429. get majorLineColor(): string;
  77430. set majorLineColor(value: string);
  77431. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  77432. get majorLineFrequency(): number;
  77433. set majorLineFrequency(value: number);
  77434. /**
  77435. * Creates a new GridDisplayRectangle
  77436. * @param name defines the control name
  77437. */
  77438. constructor(name?: string | undefined);
  77439. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77440. protected _getTypeName(): string;
  77441. }
  77442. }
  77443. declare module BABYLON.GUI {
  77444. /**
  77445. * Class used to create slider controls based on images
  77446. */
  77447. export class ImageBasedSlider extends BaseSlider {
  77448. name?: string | undefined;
  77449. private _backgroundImage;
  77450. private _thumbImage;
  77451. private _valueBarImage;
  77452. private _tempMeasure;
  77453. get displayThumb(): boolean;
  77454. set displayThumb(value: boolean);
  77455. /**
  77456. * Gets or sets the image used to render the background
  77457. */
  77458. get backgroundImage(): Image;
  77459. set backgroundImage(value: Image);
  77460. /**
  77461. * Gets or sets the image used to render the value bar
  77462. */
  77463. get valueBarImage(): Image;
  77464. set valueBarImage(value: Image);
  77465. /**
  77466. * Gets or sets the image used to render the thumb
  77467. */
  77468. get thumbImage(): Image;
  77469. set thumbImage(value: Image);
  77470. /**
  77471. * Creates a new ImageBasedSlider
  77472. * @param name defines the control name
  77473. */
  77474. constructor(name?: string | undefined);
  77475. protected _getTypeName(): string;
  77476. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77477. }
  77478. }
  77479. declare module BABYLON.GUI {
  77480. /**
  77481. * Forcing an export so that this code will execute
  77482. * @hidden
  77483. */
  77484. const name = "Statics";
  77485. }
  77486. declare module BABYLON.GUI {
  77487. /**
  77488. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  77489. */
  77490. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  77491. /**
  77492. * Define the instrumented AdvancedDynamicTexture.
  77493. */
  77494. texture: AdvancedDynamicTexture;
  77495. private _captureRenderTime;
  77496. private _renderTime;
  77497. private _captureLayoutTime;
  77498. private _layoutTime;
  77499. private _onBeginRenderObserver;
  77500. private _onEndRenderObserver;
  77501. private _onBeginLayoutObserver;
  77502. private _onEndLayoutObserver;
  77503. /**
  77504. * Gets the perf counter used to capture render time
  77505. */
  77506. get renderTimeCounter(): BABYLON.PerfCounter;
  77507. /**
  77508. * Gets the perf counter used to capture layout time
  77509. */
  77510. get layoutTimeCounter(): BABYLON.PerfCounter;
  77511. /**
  77512. * Enable or disable the render time capture
  77513. */
  77514. get captureRenderTime(): boolean;
  77515. set captureRenderTime(value: boolean);
  77516. /**
  77517. * Enable or disable the layout time capture
  77518. */
  77519. get captureLayoutTime(): boolean;
  77520. set captureLayoutTime(value: boolean);
  77521. /**
  77522. * Instantiates a new advanced dynamic texture instrumentation.
  77523. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  77524. * @param texture Defines the AdvancedDynamicTexture to instrument
  77525. */
  77526. constructor(
  77527. /**
  77528. * Define the instrumented AdvancedDynamicTexture.
  77529. */
  77530. texture: AdvancedDynamicTexture);
  77531. /**
  77532. * Dispose and release associated resources.
  77533. */
  77534. dispose(): void;
  77535. }
  77536. }
  77537. declare module BABYLON.GUI {
  77538. /**
  77539. * Class used to load GUI via XML.
  77540. */
  77541. export class XmlLoader {
  77542. private _nodes;
  77543. private _nodeTypes;
  77544. private _isLoaded;
  77545. private _objectAttributes;
  77546. private _parentClass;
  77547. /**
  77548. * Create a new xml loader
  77549. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  77550. */
  77551. constructor(parentClass?: null);
  77552. private _getChainElement;
  77553. private _getClassAttribute;
  77554. private _createGuiElement;
  77555. private _parseGrid;
  77556. private _parseElement;
  77557. private _prepareSourceElement;
  77558. private _parseElementsFromSource;
  77559. private _parseXml;
  77560. /**
  77561. * Gets if the loading has finished.
  77562. * @returns whether the loading has finished or not
  77563. */
  77564. isLoaded(): boolean;
  77565. /**
  77566. * Gets a loaded node / control by id.
  77567. * @param id the Controls id set in the xml
  77568. * @returns element of type Control
  77569. */
  77570. getNodeById(id: string): any;
  77571. /**
  77572. * Gets all loaded nodes / controls
  77573. * @returns Array of controls
  77574. */
  77575. getNodes(): any;
  77576. /**
  77577. * Initiates the xml layout loading
  77578. * @param xmlFile defines the xml layout to load
  77579. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  77580. * @param callback defines the callback called on layout load.
  77581. */
  77582. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  77583. }
  77584. }
  77585. declare module BABYLON.GUI {
  77586. /**
  77587. * Class used to create containers for controls
  77588. */
  77589. export class Container3D extends Control3D {
  77590. private _blockLayout;
  77591. /**
  77592. * Gets the list of child controls
  77593. */
  77594. protected _children: Control3D[];
  77595. /**
  77596. * Gets the list of child controls
  77597. */
  77598. get children(): Array<Control3D>;
  77599. /**
  77600. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  77601. * This is helpful to optimize layout operation when adding multiple children in a row
  77602. */
  77603. get blockLayout(): boolean;
  77604. set blockLayout(value: boolean);
  77605. /**
  77606. * Creates a new container
  77607. * @param name defines the container name
  77608. */
  77609. constructor(name?: string);
  77610. /**
  77611. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  77612. * @returns the current container
  77613. */
  77614. updateLayout(): Container3D;
  77615. /**
  77616. * Gets a boolean indicating if the given control is in the children of this control
  77617. * @param control defines the control to check
  77618. * @returns true if the control is in the child list
  77619. */
  77620. containsControl(control: Control3D): boolean;
  77621. /**
  77622. * Adds a control to the children of this control
  77623. * @param control defines the control to add
  77624. * @returns the current container
  77625. */
  77626. addControl(control: Control3D): Container3D;
  77627. /**
  77628. * This function will be called everytime a new control is added
  77629. */
  77630. protected _arrangeChildren(): void;
  77631. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  77632. /**
  77633. * Removes a control from the children of this control
  77634. * @param control defines the control to remove
  77635. * @returns the current container
  77636. */
  77637. removeControl(control: Control3D): Container3D;
  77638. protected _getTypeName(): string;
  77639. /**
  77640. * Releases all associated resources
  77641. */
  77642. dispose(): void;
  77643. /** Control rotation will remain unchanged */
  77644. static readonly UNSET_ORIENTATION: number;
  77645. /** Control will rotate to make it look at sphere central axis */
  77646. static readonly FACEORIGIN_ORIENTATION: number;
  77647. /** Control will rotate to make it look back at sphere central axis */
  77648. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  77649. /** Control will rotate to look at z axis (0, 0, 1) */
  77650. static readonly FACEFORWARD_ORIENTATION: number;
  77651. /** Control will rotate to look at negative z axis (0, 0, -1) */
  77652. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  77653. }
  77654. }
  77655. declare module BABYLON.GUI {
  77656. /**
  77657. * Class used to manage 3D user interface
  77658. * @see http://doc.babylonjs.com/how_to/gui3d
  77659. */
  77660. export class GUI3DManager implements BABYLON.IDisposable {
  77661. private _scene;
  77662. private _sceneDisposeObserver;
  77663. private _utilityLayer;
  77664. private _rootContainer;
  77665. private _pointerObserver;
  77666. private _pointerOutObserver;
  77667. /** @hidden */
  77668. _lastPickedControl: Control3D;
  77669. /** @hidden */
  77670. _lastControlOver: {
  77671. [pointerId: number]: Control3D;
  77672. };
  77673. /** @hidden */
  77674. _lastControlDown: {
  77675. [pointerId: number]: Control3D;
  77676. };
  77677. /**
  77678. * BABYLON.Observable raised when the point picked by the pointer events changed
  77679. */
  77680. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  77681. /** @hidden */
  77682. _sharedMaterials: {
  77683. [key: string]: BABYLON.Material;
  77684. };
  77685. /** Gets the hosting scene */
  77686. get scene(): BABYLON.Scene;
  77687. /** Gets associated utility layer */
  77688. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  77689. /**
  77690. * Creates a new GUI3DManager
  77691. * @param scene
  77692. */
  77693. constructor(scene?: BABYLON.Scene);
  77694. private _handlePointerOut;
  77695. private _doPicking;
  77696. /**
  77697. * Gets the root container
  77698. */
  77699. get rootContainer(): Container3D;
  77700. /**
  77701. * Gets a boolean indicating if the given control is in the root child list
  77702. * @param control defines the control to check
  77703. * @returns true if the control is in the root child list
  77704. */
  77705. containsControl(control: Control3D): boolean;
  77706. /**
  77707. * Adds a control to the root child list
  77708. * @param control defines the control to add
  77709. * @returns the current manager
  77710. */
  77711. addControl(control: Control3D): GUI3DManager;
  77712. /**
  77713. * Removes a control from the root child list
  77714. * @param control defines the control to remove
  77715. * @returns the current container
  77716. */
  77717. removeControl(control: Control3D): GUI3DManager;
  77718. /**
  77719. * Releases all associated resources
  77720. */
  77721. dispose(): void;
  77722. }
  77723. }
  77724. declare module BABYLON.GUI {
  77725. /**
  77726. * Class used to transport BABYLON.Vector3 information for pointer events
  77727. */
  77728. export class Vector3WithInfo extends BABYLON.Vector3 {
  77729. /** defines the current mouse button index */
  77730. buttonIndex: number;
  77731. /**
  77732. * Creates a new Vector3WithInfo
  77733. * @param source defines the vector3 data to transport
  77734. * @param buttonIndex defines the current mouse button index
  77735. */
  77736. constructor(source: BABYLON.Vector3,
  77737. /** defines the current mouse button index */
  77738. buttonIndex?: number);
  77739. }
  77740. }
  77741. declare module BABYLON.GUI {
  77742. /**
  77743. * Class used as base class for controls
  77744. */
  77745. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  77746. /** Defines the control name */
  77747. name?: string | undefined;
  77748. /** @hidden */
  77749. _host: GUI3DManager;
  77750. private _node;
  77751. private _downCount;
  77752. private _enterCount;
  77753. private _downPointerIds;
  77754. private _isVisible;
  77755. /** Gets or sets the control position in world space */
  77756. get position(): BABYLON.Vector3;
  77757. set position(value: BABYLON.Vector3);
  77758. /** Gets or sets the control scaling in world space */
  77759. get scaling(): BABYLON.Vector3;
  77760. set scaling(value: BABYLON.Vector3);
  77761. /** Callback used to start pointer enter animation */
  77762. pointerEnterAnimation: () => void;
  77763. /** Callback used to start pointer out animation */
  77764. pointerOutAnimation: () => void;
  77765. /** Callback used to start pointer down animation */
  77766. pointerDownAnimation: () => void;
  77767. /** Callback used to start pointer up animation */
  77768. pointerUpAnimation: () => void;
  77769. /**
  77770. * An event triggered when the pointer move over the control
  77771. */
  77772. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  77773. /**
  77774. * An event triggered when the pointer move out of the control
  77775. */
  77776. onPointerOutObservable: BABYLON.Observable<Control3D>;
  77777. /**
  77778. * An event triggered when the pointer taps the control
  77779. */
  77780. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  77781. /**
  77782. * An event triggered when pointer is up
  77783. */
  77784. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  77785. /**
  77786. * An event triggered when a control is clicked on (with a mouse)
  77787. */
  77788. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  77789. /**
  77790. * An event triggered when pointer enters the control
  77791. */
  77792. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  77793. /**
  77794. * Gets or sets the parent container
  77795. */
  77796. parent: BABYLON.Nullable<Container3D>;
  77797. private _behaviors;
  77798. /**
  77799. * Gets the list of attached behaviors
  77800. * @see http://doc.babylonjs.com/features/behaviour
  77801. */
  77802. get behaviors(): BABYLON.Behavior<Control3D>[];
  77803. /**
  77804. * Attach a behavior to the control
  77805. * @see http://doc.babylonjs.com/features/behaviour
  77806. * @param behavior defines the behavior to attach
  77807. * @returns the current control
  77808. */
  77809. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  77810. /**
  77811. * Remove an attached behavior
  77812. * @see http://doc.babylonjs.com/features/behaviour
  77813. * @param behavior defines the behavior to attach
  77814. * @returns the current control
  77815. */
  77816. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  77817. /**
  77818. * Gets an attached behavior by name
  77819. * @param name defines the name of the behavior to look for
  77820. * @see http://doc.babylonjs.com/features/behaviour
  77821. * @returns null if behavior was not found else the requested behavior
  77822. */
  77823. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  77824. /** Gets or sets a boolean indicating if the control is visible */
  77825. get isVisible(): boolean;
  77826. set isVisible(value: boolean);
  77827. /**
  77828. * Creates a new control
  77829. * @param name defines the control name
  77830. */
  77831. constructor(
  77832. /** Defines the control name */
  77833. name?: string | undefined);
  77834. /**
  77835. * Gets a string representing the class name
  77836. */
  77837. get typeName(): string;
  77838. /**
  77839. * Get the current class name of the control.
  77840. * @returns current class name
  77841. */
  77842. getClassName(): string;
  77843. protected _getTypeName(): string;
  77844. /**
  77845. * Gets the transform node used by this control
  77846. */
  77847. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  77848. /**
  77849. * Gets the mesh used to render this control
  77850. */
  77851. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  77852. /**
  77853. * Link the control as child of the given node
  77854. * @param node defines the node to link to. Use null to unlink the control
  77855. * @returns the current control
  77856. */
  77857. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  77858. /** @hidden **/
  77859. _prepareNode(scene: BABYLON.Scene): void;
  77860. /**
  77861. * Node creation.
  77862. * Can be overriden by children
  77863. * @param scene defines the scene where the node must be attached
  77864. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  77865. */
  77866. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  77867. /**
  77868. * Affect a material to the given mesh
  77869. * @param mesh defines the mesh which will represent the control
  77870. */
  77871. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77872. /** @hidden */
  77873. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  77874. /** @hidden */
  77875. _onPointerEnter(target: Control3D): boolean;
  77876. /** @hidden */
  77877. _onPointerOut(target: Control3D): void;
  77878. /** @hidden */
  77879. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  77880. /** @hidden */
  77881. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77882. /** @hidden */
  77883. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  77884. /** @hidden */
  77885. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  77886. /** @hidden */
  77887. _disposeNode(): void;
  77888. /**
  77889. * Releases all associated resources
  77890. */
  77891. dispose(): void;
  77892. }
  77893. }
  77894. declare module BABYLON.GUI {
  77895. /**
  77896. * Class used as a root to all buttons
  77897. */
  77898. export class AbstractButton3D extends Control3D {
  77899. /**
  77900. * Creates a new button
  77901. * @param name defines the control name
  77902. */
  77903. constructor(name?: string);
  77904. protected _getTypeName(): string;
  77905. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77906. }
  77907. }
  77908. declare module BABYLON.GUI {
  77909. /**
  77910. * Class used to create a button in 3D
  77911. */
  77912. export class Button3D extends AbstractButton3D {
  77913. /** @hidden */
  77914. protected _currentMaterial: BABYLON.Material;
  77915. private _facadeTexture;
  77916. private _content;
  77917. private _contentResolution;
  77918. private _contentScaleRatio;
  77919. /**
  77920. * Gets or sets the texture resolution used to render content (512 by default)
  77921. */
  77922. get contentResolution(): BABYLON.int;
  77923. set contentResolution(value: BABYLON.int);
  77924. /**
  77925. * Gets or sets the texture scale ratio used to render content (2 by default)
  77926. */
  77927. get contentScaleRatio(): number;
  77928. set contentScaleRatio(value: number);
  77929. protected _disposeFacadeTexture(): void;
  77930. protected _resetContent(): void;
  77931. /**
  77932. * Creates a new button
  77933. * @param name defines the control name
  77934. */
  77935. constructor(name?: string);
  77936. /**
  77937. * Gets or sets the GUI 2D content used to display the button's facade
  77938. */
  77939. get content(): Control;
  77940. set content(value: Control);
  77941. /**
  77942. * Apply the facade texture (created from the content property).
  77943. * This function can be overloaded by child classes
  77944. * @param facadeTexture defines the AdvancedDynamicTexture to use
  77945. */
  77946. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  77947. protected _getTypeName(): string;
  77948. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77949. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77950. /**
  77951. * Releases all associated resources
  77952. */
  77953. dispose(): void;
  77954. }
  77955. }
  77956. declare module BABYLON.GUI {
  77957. /**
  77958. * Abstract class used to create a container panel deployed on the surface of a volume
  77959. */
  77960. export abstract class VolumeBasedPanel extends Container3D {
  77961. private _columns;
  77962. private _rows;
  77963. private _rowThenColum;
  77964. private _orientation;
  77965. protected _cellWidth: number;
  77966. protected _cellHeight: number;
  77967. /**
  77968. * Gets or sets the distance between elements
  77969. */
  77970. margin: number;
  77971. /**
  77972. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  77973. * | Value | Type | Description |
  77974. * | ----- | ----------------------------------- | ----------- |
  77975. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  77976. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  77977. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  77978. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  77979. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  77980. */
  77981. get orientation(): number;
  77982. set orientation(value: number);
  77983. /**
  77984. * Gets or sets the number of columns requested (10 by default).
  77985. * The panel will automatically compute the number of rows based on number of child controls.
  77986. */
  77987. get columns(): BABYLON.int;
  77988. set columns(value: BABYLON.int);
  77989. /**
  77990. * Gets or sets a the number of rows requested.
  77991. * The panel will automatically compute the number of columns based on number of child controls.
  77992. */
  77993. get rows(): BABYLON.int;
  77994. set rows(value: BABYLON.int);
  77995. /**
  77996. * Creates new VolumeBasedPanel
  77997. */
  77998. constructor();
  77999. protected _arrangeChildren(): void;
  78000. /** Child classes must implement this function to provide correct control positioning */
  78001. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78002. /** Child classes can implement this function to provide additional processing */
  78003. protected _finalProcessing(): void;
  78004. }
  78005. }
  78006. declare module BABYLON.GUI {
  78007. /**
  78008. * Class used to create a container panel deployed on the surface of a cylinder
  78009. */
  78010. export class CylinderPanel extends VolumeBasedPanel {
  78011. private _radius;
  78012. /**
  78013. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  78014. */
  78015. get radius(): BABYLON.float;
  78016. set radius(value: BABYLON.float);
  78017. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78018. private _cylindricalMapping;
  78019. }
  78020. }
  78021. declare module BABYLON.GUI {
  78022. /** @hidden */
  78023. export var fluentVertexShader: {
  78024. name: string;
  78025. shader: string;
  78026. };
  78027. }
  78028. declare module BABYLON.GUI {
  78029. /** @hidden */
  78030. export var fluentPixelShader: {
  78031. name: string;
  78032. shader: string;
  78033. };
  78034. }
  78035. declare module BABYLON.GUI {
  78036. /** @hidden */
  78037. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  78038. INNERGLOW: boolean;
  78039. BORDER: boolean;
  78040. HOVERLIGHT: boolean;
  78041. TEXTURE: boolean;
  78042. constructor();
  78043. }
  78044. /**
  78045. * Class used to render controls with fluent desgin
  78046. */
  78047. export class FluentMaterial extends BABYLON.PushMaterial {
  78048. /**
  78049. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  78050. */
  78051. innerGlowColorIntensity: number;
  78052. /**
  78053. * Gets or sets the inner glow color (white by default)
  78054. */
  78055. innerGlowColor: BABYLON.Color3;
  78056. /**
  78057. * Gets or sets alpha value (default is 1.0)
  78058. */
  78059. alpha: number;
  78060. /**
  78061. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  78062. */
  78063. albedoColor: BABYLON.Color3;
  78064. /**
  78065. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  78066. */
  78067. renderBorders: boolean;
  78068. /**
  78069. * Gets or sets border width (default is 0.5)
  78070. */
  78071. borderWidth: number;
  78072. /**
  78073. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  78074. */
  78075. edgeSmoothingValue: number;
  78076. /**
  78077. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  78078. */
  78079. borderMinValue: number;
  78080. /**
  78081. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  78082. */
  78083. renderHoverLight: boolean;
  78084. /**
  78085. * Gets or sets the radius used to render the hover light (default is 1.0)
  78086. */
  78087. hoverRadius: number;
  78088. /**
  78089. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  78090. */
  78091. hoverColor: BABYLON.Color4;
  78092. /**
  78093. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  78094. */
  78095. hoverPosition: BABYLON.Vector3;
  78096. private _albedoTexture;
  78097. /** Gets or sets the texture to use for albedo color */
  78098. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78099. /**
  78100. * Creates a new Fluent material
  78101. * @param name defines the name of the material
  78102. * @param scene defines the hosting scene
  78103. */
  78104. constructor(name: string, scene: BABYLON.Scene);
  78105. needAlphaBlending(): boolean;
  78106. needAlphaTesting(): boolean;
  78107. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78108. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78109. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78110. getActiveTextures(): BABYLON.BaseTexture[];
  78111. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78112. dispose(forceDisposeEffect?: boolean): void;
  78113. clone(name: string): FluentMaterial;
  78114. serialize(): any;
  78115. getClassName(): string;
  78116. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  78117. }
  78118. }
  78119. declare module BABYLON.GUI {
  78120. /**
  78121. * Class used to create a holographic button in 3D
  78122. */
  78123. export class HolographicButton extends Button3D {
  78124. private _backPlate;
  78125. private _textPlate;
  78126. private _frontPlate;
  78127. private _text;
  78128. private _imageUrl;
  78129. private _shareMaterials;
  78130. private _frontMaterial;
  78131. private _backMaterial;
  78132. private _plateMaterial;
  78133. private _pickedPointObserver;
  78134. private _tooltipFade;
  78135. private _tooltipTextBlock;
  78136. private _tooltipTexture;
  78137. private _tooltipMesh;
  78138. private _tooltipHoverObserver;
  78139. private _tooltipOutObserver;
  78140. private _disposeTooltip;
  78141. /**
  78142. * Rendering ground id of all the mesh in the button
  78143. */
  78144. set renderingGroupId(id: number);
  78145. get renderingGroupId(): number;
  78146. /**
  78147. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  78148. */
  78149. set tooltipText(text: BABYLON.Nullable<string>);
  78150. get tooltipText(): BABYLON.Nullable<string>;
  78151. /**
  78152. * Gets or sets text for the button
  78153. */
  78154. get text(): string;
  78155. set text(value: string);
  78156. /**
  78157. * Gets or sets the image url for the button
  78158. */
  78159. get imageUrl(): string;
  78160. set imageUrl(value: string);
  78161. /**
  78162. * Gets the back material used by this button
  78163. */
  78164. get backMaterial(): FluentMaterial;
  78165. /**
  78166. * Gets the front material used by this button
  78167. */
  78168. get frontMaterial(): FluentMaterial;
  78169. /**
  78170. * Gets the plate material used by this button
  78171. */
  78172. get plateMaterial(): BABYLON.StandardMaterial;
  78173. /**
  78174. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  78175. */
  78176. get shareMaterials(): boolean;
  78177. /**
  78178. * Creates a new button
  78179. * @param name defines the control name
  78180. */
  78181. constructor(name?: string, shareMaterials?: boolean);
  78182. protected _getTypeName(): string;
  78183. private _rebuildContent;
  78184. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78185. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  78186. private _createBackMaterial;
  78187. private _createFrontMaterial;
  78188. private _createPlateMaterial;
  78189. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  78190. /**
  78191. * Releases all associated resources
  78192. */
  78193. dispose(): void;
  78194. }
  78195. }
  78196. declare module BABYLON.GUI {
  78197. /**
  78198. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  78199. */
  78200. export class MeshButton3D extends Button3D {
  78201. /** @hidden */
  78202. protected _currentMesh: BABYLON.Mesh;
  78203. /**
  78204. * Creates a new 3D button based on a mesh
  78205. * @param mesh mesh to become a 3D button
  78206. * @param name defines the control name
  78207. */
  78208. constructor(mesh: BABYLON.Mesh, name?: string);
  78209. protected _getTypeName(): string;
  78210. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78211. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  78212. }
  78213. }
  78214. declare module BABYLON.GUI {
  78215. /**
  78216. * Class used to create a container panel deployed on the surface of a plane
  78217. */
  78218. export class PlanePanel extends VolumeBasedPanel {
  78219. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78220. }
  78221. }
  78222. declare module BABYLON.GUI {
  78223. /**
  78224. * Class used to create a container panel where items get randomized planar mapping
  78225. */
  78226. export class ScatterPanel extends VolumeBasedPanel {
  78227. private _iteration;
  78228. /**
  78229. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  78230. */
  78231. get iteration(): BABYLON.float;
  78232. set iteration(value: BABYLON.float);
  78233. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78234. private _scatterMapping;
  78235. protected _finalProcessing(): void;
  78236. }
  78237. }
  78238. declare module BABYLON.GUI {
  78239. /**
  78240. * Class used to create a container panel deployed on the surface of a sphere
  78241. */
  78242. export class SpherePanel extends VolumeBasedPanel {
  78243. private _radius;
  78244. /**
  78245. * Gets or sets the radius of the sphere where to project controls (5 by default)
  78246. */
  78247. get radius(): BABYLON.float;
  78248. set radius(value: BABYLON.float);
  78249. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78250. private _sphericalMapping;
  78251. }
  78252. }
  78253. declare module BABYLON.GUI {
  78254. /**
  78255. * Class used to create a stack panel in 3D on XY plane
  78256. */
  78257. export class StackPanel3D extends Container3D {
  78258. private _isVertical;
  78259. /**
  78260. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  78261. */
  78262. get isVertical(): boolean;
  78263. set isVertical(value: boolean);
  78264. /**
  78265. * Gets or sets the distance between elements
  78266. */
  78267. margin: number;
  78268. /**
  78269. * Creates new StackPanel
  78270. * @param isVertical
  78271. */
  78272. constructor(isVertical?: boolean);
  78273. protected _arrangeChildren(): void;
  78274. }
  78275. }
  78276. declare module BABYLON {
  78277. /**
  78278. * Configuration for glTF validation
  78279. */
  78280. export interface IGLTFValidationConfiguration {
  78281. /**
  78282. * The url of the glTF validator.
  78283. */
  78284. url: string;
  78285. }
  78286. /**
  78287. * glTF validation
  78288. */
  78289. export class GLTFValidation {
  78290. /**
  78291. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  78292. */
  78293. static Configuration: IGLTFValidationConfiguration;
  78294. private static _LoadScriptPromise;
  78295. /**
  78296. * Validate a glTF asset using the glTF-Validator.
  78297. * @param data The JSON of a glTF or the array buffer of a binary glTF
  78298. * @param rootUrl The root url for the glTF
  78299. * @param fileName The file name for the glTF
  78300. * @param getExternalResource The callback to get external resources for the glTF validator
  78301. * @returns A promise that resolves with the glTF validation results once complete
  78302. */
  78303. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  78304. }
  78305. }
  78306. declare module BABYLON {
  78307. /**
  78308. * Mode that determines the coordinate system to use.
  78309. */
  78310. export enum GLTFLoaderCoordinateSystemMode {
  78311. /**
  78312. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  78313. */
  78314. AUTO = 0,
  78315. /**
  78316. * Sets the useRightHandedSystem flag on the scene.
  78317. */
  78318. FORCE_RIGHT_HANDED = 1
  78319. }
  78320. /**
  78321. * Mode that determines what animations will start.
  78322. */
  78323. export enum GLTFLoaderAnimationStartMode {
  78324. /**
  78325. * No animation will start.
  78326. */
  78327. NONE = 0,
  78328. /**
  78329. * The first animation will start.
  78330. */
  78331. FIRST = 1,
  78332. /**
  78333. * All animations will start.
  78334. */
  78335. ALL = 2
  78336. }
  78337. /**
  78338. * Interface that contains the data for the glTF asset.
  78339. */
  78340. export interface IGLTFLoaderData {
  78341. /**
  78342. * The object that represents the glTF JSON.
  78343. */
  78344. json: Object;
  78345. /**
  78346. * The BIN chunk of a binary glTF.
  78347. */
  78348. bin: Nullable<IDataBuffer>;
  78349. }
  78350. /**
  78351. * Interface for extending the loader.
  78352. */
  78353. export interface IGLTFLoaderExtension {
  78354. /**
  78355. * The name of this extension.
  78356. */
  78357. readonly name: string;
  78358. /**
  78359. * Defines whether this extension is enabled.
  78360. */
  78361. enabled: boolean;
  78362. /**
  78363. * Defines the order of this extension.
  78364. * The loader sorts the extensions using these values when loading.
  78365. */
  78366. order?: number;
  78367. }
  78368. /**
  78369. * Loader state.
  78370. */
  78371. export enum GLTFLoaderState {
  78372. /**
  78373. * The asset is loading.
  78374. */
  78375. LOADING = 0,
  78376. /**
  78377. * The asset is ready for rendering.
  78378. */
  78379. READY = 1,
  78380. /**
  78381. * The asset is completely loaded.
  78382. */
  78383. COMPLETE = 2
  78384. }
  78385. /** @hidden */
  78386. export interface IImportMeshAsyncOutput {
  78387. meshes: AbstractMesh[];
  78388. particleSystems: IParticleSystem[];
  78389. skeletons: Skeleton[];
  78390. animationGroups: AnimationGroup[];
  78391. lights: Light[];
  78392. transformNodes: TransformNode[];
  78393. }
  78394. /** @hidden */
  78395. export interface IGLTFLoader extends IDisposable {
  78396. readonly state: Nullable<GLTFLoaderState>;
  78397. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  78398. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  78399. }
  78400. /**
  78401. * File loader for loading glTF files into a scene.
  78402. */
  78403. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  78404. /** @hidden */
  78405. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  78406. /** @hidden */
  78407. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  78408. /**
  78409. * Raised when the asset has been parsed
  78410. */
  78411. onParsedObservable: Observable<IGLTFLoaderData>;
  78412. private _onParsedObserver;
  78413. /**
  78414. * Raised when the asset has been parsed
  78415. */
  78416. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  78417. /**
  78418. * 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.
  78419. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  78420. * Defaults to true.
  78421. * @hidden
  78422. */
  78423. static IncrementalLoading: boolean;
  78424. /**
  78425. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  78426. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  78427. * @hidden
  78428. */
  78429. static HomogeneousCoordinates: boolean;
  78430. /**
  78431. * The coordinate system mode. Defaults to AUTO.
  78432. */
  78433. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  78434. /**
  78435. * The animation start mode. Defaults to FIRST.
  78436. */
  78437. animationStartMode: GLTFLoaderAnimationStartMode;
  78438. /**
  78439. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  78440. */
  78441. compileMaterials: boolean;
  78442. /**
  78443. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  78444. */
  78445. useClipPlane: boolean;
  78446. /**
  78447. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  78448. */
  78449. compileShadowGenerators: boolean;
  78450. /**
  78451. * Defines if the Alpha blended materials are only applied as coverage.
  78452. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  78453. * If true, no extra effects are applied to transparent pixels.
  78454. */
  78455. transparencyAsCoverage: boolean;
  78456. /**
  78457. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  78458. * Enabling will disable offline support and glTF validator.
  78459. * Defaults to false.
  78460. */
  78461. useRangeRequests: boolean;
  78462. /**
  78463. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  78464. */
  78465. createInstances: boolean;
  78466. /**
  78467. * Function called before loading a url referenced by the asset.
  78468. */
  78469. preprocessUrlAsync: (url: string) => Promise<string>;
  78470. /**
  78471. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  78472. */
  78473. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  78474. private _onMeshLoadedObserver;
  78475. /**
  78476. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  78477. */
  78478. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  78479. /**
  78480. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  78481. */
  78482. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  78483. private _onTextureLoadedObserver;
  78484. /**
  78485. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  78486. */
  78487. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  78488. /**
  78489. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  78490. */
  78491. readonly onMaterialLoadedObservable: Observable<Material>;
  78492. private _onMaterialLoadedObserver;
  78493. /**
  78494. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  78495. */
  78496. set onMaterialLoaded(callback: (material: Material) => void);
  78497. /**
  78498. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  78499. */
  78500. readonly onCameraLoadedObservable: Observable<Camera>;
  78501. private _onCameraLoadedObserver;
  78502. /**
  78503. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  78504. */
  78505. set onCameraLoaded(callback: (camera: Camera) => void);
  78506. /**
  78507. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  78508. * For assets with LODs, raised when all of the LODs are complete.
  78509. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  78510. */
  78511. readonly onCompleteObservable: Observable<void>;
  78512. private _onCompleteObserver;
  78513. /**
  78514. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  78515. * For assets with LODs, raised when all of the LODs are complete.
  78516. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  78517. */
  78518. set onComplete(callback: () => void);
  78519. /**
  78520. * Observable raised when an error occurs.
  78521. */
  78522. readonly onErrorObservable: Observable<any>;
  78523. private _onErrorObserver;
  78524. /**
  78525. * Callback raised when an error occurs.
  78526. */
  78527. set onError(callback: (reason: any) => void);
  78528. /**
  78529. * Observable raised after the loader is disposed.
  78530. */
  78531. readonly onDisposeObservable: Observable<void>;
  78532. private _onDisposeObserver;
  78533. /**
  78534. * Callback raised after the loader is disposed.
  78535. */
  78536. set onDispose(callback: () => void);
  78537. /**
  78538. * Observable raised after a loader extension is created.
  78539. * Set additional options for a loader extension in this event.
  78540. */
  78541. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  78542. private _onExtensionLoadedObserver;
  78543. /**
  78544. * Callback raised after a loader extension is created.
  78545. */
  78546. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  78547. /**
  78548. * Defines if the loader logging is enabled.
  78549. */
  78550. get loggingEnabled(): boolean;
  78551. set loggingEnabled(value: boolean);
  78552. /**
  78553. * Defines if the loader should capture performance counters.
  78554. */
  78555. get capturePerformanceCounters(): boolean;
  78556. set capturePerformanceCounters(value: boolean);
  78557. /**
  78558. * Defines if the loader should validate the asset.
  78559. */
  78560. validate: boolean;
  78561. /**
  78562. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  78563. */
  78564. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  78565. private _onValidatedObserver;
  78566. /**
  78567. * Callback raised after a loader extension is created.
  78568. */
  78569. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  78570. private _loader;
  78571. private _progressCallback?;
  78572. private _requests;
  78573. /**
  78574. * Name of the loader ("gltf")
  78575. */
  78576. name: string;
  78577. /** @hidden */
  78578. extensions: ISceneLoaderPluginExtensions;
  78579. /**
  78580. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  78581. */
  78582. dispose(): void;
  78583. /** @hidden */
  78584. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  78585. /** @hidden */
  78586. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  78587. /** @hidden */
  78588. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  78589. meshes: AbstractMesh[];
  78590. particleSystems: IParticleSystem[];
  78591. skeletons: Skeleton[];
  78592. animationGroups: AnimationGroup[];
  78593. }>;
  78594. /** @hidden */
  78595. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  78596. /** @hidden */
  78597. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  78598. /** @hidden */
  78599. canDirectLoad(data: string): boolean;
  78600. /** @hidden */
  78601. directLoad(scene: Scene, data: string): any;
  78602. /**
  78603. * The callback that allows custom handling of the root url based on the response url.
  78604. * @param rootUrl the original root url
  78605. * @param responseURL the response url if available
  78606. * @returns the new root url
  78607. */
  78608. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  78609. /** @hidden */
  78610. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  78611. /**
  78612. * The loader state or null if the loader is not active.
  78613. */
  78614. get loaderState(): Nullable<GLTFLoaderState>;
  78615. /**
  78616. * Returns a promise that resolves when the asset is completely loaded.
  78617. * @returns a promise that resolves when the asset is completely loaded.
  78618. */
  78619. whenCompleteAsync(): Promise<void>;
  78620. /** @hidden */
  78621. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  78622. /** @hidden */
  78623. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  78624. private _onProgress;
  78625. private _validate;
  78626. private _getLoader;
  78627. private _parseJson;
  78628. private _unpackBinaryAsync;
  78629. private _unpackBinaryV1Async;
  78630. private _unpackBinaryV2Async;
  78631. private static _parseVersion;
  78632. private static _compareVersion;
  78633. private static readonly _logSpaces;
  78634. private _logIndentLevel;
  78635. private _loggingEnabled;
  78636. /** @hidden */
  78637. _log: (message: string) => void;
  78638. /** @hidden */
  78639. _logOpen(message: string): void;
  78640. /** @hidden */
  78641. _logClose(): void;
  78642. private _logEnabled;
  78643. private _logDisabled;
  78644. private _capturePerformanceCounters;
  78645. /** @hidden */
  78646. _startPerformanceCounter: (counterName: string) => void;
  78647. /** @hidden */
  78648. _endPerformanceCounter: (counterName: string) => void;
  78649. private _startPerformanceCounterEnabled;
  78650. private _startPerformanceCounterDisabled;
  78651. private _endPerformanceCounterEnabled;
  78652. private _endPerformanceCounterDisabled;
  78653. }
  78654. }
  78655. declare module BABYLON.GLTF1 {
  78656. /**
  78657. * Enums
  78658. * @hidden
  78659. */
  78660. export enum EComponentType {
  78661. BYTE = 5120,
  78662. UNSIGNED_BYTE = 5121,
  78663. SHORT = 5122,
  78664. UNSIGNED_SHORT = 5123,
  78665. FLOAT = 5126
  78666. }
  78667. /** @hidden */
  78668. export enum EShaderType {
  78669. FRAGMENT = 35632,
  78670. VERTEX = 35633
  78671. }
  78672. /** @hidden */
  78673. export enum EParameterType {
  78674. BYTE = 5120,
  78675. UNSIGNED_BYTE = 5121,
  78676. SHORT = 5122,
  78677. UNSIGNED_SHORT = 5123,
  78678. INT = 5124,
  78679. UNSIGNED_INT = 5125,
  78680. FLOAT = 5126,
  78681. FLOAT_VEC2 = 35664,
  78682. FLOAT_VEC3 = 35665,
  78683. FLOAT_VEC4 = 35666,
  78684. INT_VEC2 = 35667,
  78685. INT_VEC3 = 35668,
  78686. INT_VEC4 = 35669,
  78687. BOOL = 35670,
  78688. BOOL_VEC2 = 35671,
  78689. BOOL_VEC3 = 35672,
  78690. BOOL_VEC4 = 35673,
  78691. FLOAT_MAT2 = 35674,
  78692. FLOAT_MAT3 = 35675,
  78693. FLOAT_MAT4 = 35676,
  78694. SAMPLER_2D = 35678
  78695. }
  78696. /** @hidden */
  78697. export enum ETextureWrapMode {
  78698. CLAMP_TO_EDGE = 33071,
  78699. MIRRORED_REPEAT = 33648,
  78700. REPEAT = 10497
  78701. }
  78702. /** @hidden */
  78703. export enum ETextureFilterType {
  78704. NEAREST = 9728,
  78705. LINEAR = 9728,
  78706. NEAREST_MIPMAP_NEAREST = 9984,
  78707. LINEAR_MIPMAP_NEAREST = 9985,
  78708. NEAREST_MIPMAP_LINEAR = 9986,
  78709. LINEAR_MIPMAP_LINEAR = 9987
  78710. }
  78711. /** @hidden */
  78712. export enum ETextureFormat {
  78713. ALPHA = 6406,
  78714. RGB = 6407,
  78715. RGBA = 6408,
  78716. LUMINANCE = 6409,
  78717. LUMINANCE_ALPHA = 6410
  78718. }
  78719. /** @hidden */
  78720. export enum ECullingType {
  78721. FRONT = 1028,
  78722. BACK = 1029,
  78723. FRONT_AND_BACK = 1032
  78724. }
  78725. /** @hidden */
  78726. export enum EBlendingFunction {
  78727. ZERO = 0,
  78728. ONE = 1,
  78729. SRC_COLOR = 768,
  78730. ONE_MINUS_SRC_COLOR = 769,
  78731. DST_COLOR = 774,
  78732. ONE_MINUS_DST_COLOR = 775,
  78733. SRC_ALPHA = 770,
  78734. ONE_MINUS_SRC_ALPHA = 771,
  78735. DST_ALPHA = 772,
  78736. ONE_MINUS_DST_ALPHA = 773,
  78737. CONSTANT_COLOR = 32769,
  78738. ONE_MINUS_CONSTANT_COLOR = 32770,
  78739. CONSTANT_ALPHA = 32771,
  78740. ONE_MINUS_CONSTANT_ALPHA = 32772,
  78741. SRC_ALPHA_SATURATE = 776
  78742. }
  78743. /** @hidden */
  78744. export interface IGLTFProperty {
  78745. extensions?: {
  78746. [key: string]: any;
  78747. };
  78748. extras?: Object;
  78749. }
  78750. /** @hidden */
  78751. export interface IGLTFChildRootProperty extends IGLTFProperty {
  78752. name?: string;
  78753. }
  78754. /** @hidden */
  78755. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  78756. bufferView: string;
  78757. byteOffset: number;
  78758. byteStride: number;
  78759. count: number;
  78760. type: string;
  78761. componentType: EComponentType;
  78762. max?: number[];
  78763. min?: number[];
  78764. name?: string;
  78765. }
  78766. /** @hidden */
  78767. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  78768. buffer: string;
  78769. byteOffset: number;
  78770. byteLength: number;
  78771. byteStride: number;
  78772. target?: number;
  78773. }
  78774. /** @hidden */
  78775. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  78776. uri: string;
  78777. byteLength?: number;
  78778. type?: string;
  78779. }
  78780. /** @hidden */
  78781. export interface IGLTFShader extends IGLTFChildRootProperty {
  78782. uri: string;
  78783. type: EShaderType;
  78784. }
  78785. /** @hidden */
  78786. export interface IGLTFProgram extends IGLTFChildRootProperty {
  78787. attributes: string[];
  78788. fragmentShader: string;
  78789. vertexShader: string;
  78790. }
  78791. /** @hidden */
  78792. export interface IGLTFTechniqueParameter {
  78793. type: number;
  78794. count?: number;
  78795. semantic?: string;
  78796. node?: string;
  78797. value?: number | boolean | string | Array<any>;
  78798. source?: string;
  78799. babylonValue?: any;
  78800. }
  78801. /** @hidden */
  78802. export interface IGLTFTechniqueCommonProfile {
  78803. lightingModel: string;
  78804. texcoordBindings: Object;
  78805. parameters?: Array<any>;
  78806. }
  78807. /** @hidden */
  78808. export interface IGLTFTechniqueStatesFunctions {
  78809. blendColor?: number[];
  78810. blendEquationSeparate?: number[];
  78811. blendFuncSeparate?: number[];
  78812. colorMask: boolean[];
  78813. cullFace: number[];
  78814. }
  78815. /** @hidden */
  78816. export interface IGLTFTechniqueStates {
  78817. enable: number[];
  78818. functions: IGLTFTechniqueStatesFunctions;
  78819. }
  78820. /** @hidden */
  78821. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  78822. parameters: {
  78823. [key: string]: IGLTFTechniqueParameter;
  78824. };
  78825. program: string;
  78826. attributes: {
  78827. [key: string]: string;
  78828. };
  78829. uniforms: {
  78830. [key: string]: string;
  78831. };
  78832. states: IGLTFTechniqueStates;
  78833. }
  78834. /** @hidden */
  78835. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  78836. technique?: string;
  78837. values: string[];
  78838. }
  78839. /** @hidden */
  78840. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  78841. attributes: {
  78842. [key: string]: string;
  78843. };
  78844. indices: string;
  78845. material: string;
  78846. mode?: number;
  78847. }
  78848. /** @hidden */
  78849. export interface IGLTFMesh extends IGLTFChildRootProperty {
  78850. primitives: IGLTFMeshPrimitive[];
  78851. }
  78852. /** @hidden */
  78853. export interface IGLTFImage extends IGLTFChildRootProperty {
  78854. uri: string;
  78855. }
  78856. /** @hidden */
  78857. export interface IGLTFSampler extends IGLTFChildRootProperty {
  78858. magFilter?: number;
  78859. minFilter?: number;
  78860. wrapS?: number;
  78861. wrapT?: number;
  78862. }
  78863. /** @hidden */
  78864. export interface IGLTFTexture extends IGLTFChildRootProperty {
  78865. sampler: string;
  78866. source: string;
  78867. format?: ETextureFormat;
  78868. internalFormat?: ETextureFormat;
  78869. target?: number;
  78870. type?: number;
  78871. babylonTexture?: Texture;
  78872. }
  78873. /** @hidden */
  78874. export interface IGLTFAmbienLight {
  78875. color?: number[];
  78876. }
  78877. /** @hidden */
  78878. export interface IGLTFDirectionalLight {
  78879. color?: number[];
  78880. }
  78881. /** @hidden */
  78882. export interface IGLTFPointLight {
  78883. color?: number[];
  78884. constantAttenuation?: number;
  78885. linearAttenuation?: number;
  78886. quadraticAttenuation?: number;
  78887. }
  78888. /** @hidden */
  78889. export interface IGLTFSpotLight {
  78890. color?: number[];
  78891. constantAttenuation?: number;
  78892. fallOfAngle?: number;
  78893. fallOffExponent?: number;
  78894. linearAttenuation?: number;
  78895. quadraticAttenuation?: number;
  78896. }
  78897. /** @hidden */
  78898. export interface IGLTFLight extends IGLTFChildRootProperty {
  78899. type: string;
  78900. }
  78901. /** @hidden */
  78902. export interface IGLTFCameraOrthographic {
  78903. xmag: number;
  78904. ymag: number;
  78905. zfar: number;
  78906. znear: number;
  78907. }
  78908. /** @hidden */
  78909. export interface IGLTFCameraPerspective {
  78910. aspectRatio: number;
  78911. yfov: number;
  78912. zfar: number;
  78913. znear: number;
  78914. }
  78915. /** @hidden */
  78916. export interface IGLTFCamera extends IGLTFChildRootProperty {
  78917. type: string;
  78918. }
  78919. /** @hidden */
  78920. export interface IGLTFAnimationChannelTarget {
  78921. id: string;
  78922. path: string;
  78923. }
  78924. /** @hidden */
  78925. export interface IGLTFAnimationChannel {
  78926. sampler: string;
  78927. target: IGLTFAnimationChannelTarget;
  78928. }
  78929. /** @hidden */
  78930. export interface IGLTFAnimationSampler {
  78931. input: string;
  78932. output: string;
  78933. interpolation?: string;
  78934. }
  78935. /** @hidden */
  78936. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  78937. channels?: IGLTFAnimationChannel[];
  78938. parameters?: {
  78939. [key: string]: string;
  78940. };
  78941. samplers?: {
  78942. [key: string]: IGLTFAnimationSampler;
  78943. };
  78944. }
  78945. /** @hidden */
  78946. export interface IGLTFNodeInstanceSkin {
  78947. skeletons: string[];
  78948. skin: string;
  78949. meshes: string[];
  78950. }
  78951. /** @hidden */
  78952. export interface IGLTFSkins extends IGLTFChildRootProperty {
  78953. bindShapeMatrix: number[];
  78954. inverseBindMatrices: string;
  78955. jointNames: string[];
  78956. babylonSkeleton?: Skeleton;
  78957. }
  78958. /** @hidden */
  78959. export interface IGLTFNode extends IGLTFChildRootProperty {
  78960. camera?: string;
  78961. children: string[];
  78962. skin?: string;
  78963. jointName?: string;
  78964. light?: string;
  78965. matrix: number[];
  78966. mesh?: string;
  78967. meshes?: string[];
  78968. rotation?: number[];
  78969. scale?: number[];
  78970. translation?: number[];
  78971. babylonNode?: Node;
  78972. }
  78973. /** @hidden */
  78974. export interface IGLTFScene extends IGLTFChildRootProperty {
  78975. nodes: string[];
  78976. }
  78977. /** @hidden */
  78978. export interface IGLTFRuntime {
  78979. extensions: {
  78980. [key: string]: any;
  78981. };
  78982. accessors: {
  78983. [key: string]: IGLTFAccessor;
  78984. };
  78985. buffers: {
  78986. [key: string]: IGLTFBuffer;
  78987. };
  78988. bufferViews: {
  78989. [key: string]: IGLTFBufferView;
  78990. };
  78991. meshes: {
  78992. [key: string]: IGLTFMesh;
  78993. };
  78994. lights: {
  78995. [key: string]: IGLTFLight;
  78996. };
  78997. cameras: {
  78998. [key: string]: IGLTFCamera;
  78999. };
  79000. nodes: {
  79001. [key: string]: IGLTFNode;
  79002. };
  79003. images: {
  79004. [key: string]: IGLTFImage;
  79005. };
  79006. textures: {
  79007. [key: string]: IGLTFTexture;
  79008. };
  79009. shaders: {
  79010. [key: string]: IGLTFShader;
  79011. };
  79012. programs: {
  79013. [key: string]: IGLTFProgram;
  79014. };
  79015. samplers: {
  79016. [key: string]: IGLTFSampler;
  79017. };
  79018. techniques: {
  79019. [key: string]: IGLTFTechnique;
  79020. };
  79021. materials: {
  79022. [key: string]: IGLTFMaterial;
  79023. };
  79024. animations: {
  79025. [key: string]: IGLTFAnimation;
  79026. };
  79027. skins: {
  79028. [key: string]: IGLTFSkins;
  79029. };
  79030. currentScene?: Object;
  79031. scenes: {
  79032. [key: string]: IGLTFScene;
  79033. };
  79034. extensionsUsed: string[];
  79035. extensionsRequired?: string[];
  79036. buffersCount: number;
  79037. shaderscount: number;
  79038. scene: Scene;
  79039. rootUrl: string;
  79040. loadedBufferCount: number;
  79041. loadedBufferViews: {
  79042. [name: string]: ArrayBufferView;
  79043. };
  79044. loadedShaderCount: number;
  79045. importOnlyMeshes: boolean;
  79046. importMeshesNames?: string[];
  79047. dummyNodes: Node[];
  79048. forAssetContainer: boolean;
  79049. }
  79050. /** @hidden */
  79051. export interface INodeToRoot {
  79052. bone: Bone;
  79053. node: IGLTFNode;
  79054. id: string;
  79055. }
  79056. /** @hidden */
  79057. export interface IJointNode {
  79058. node: IGLTFNode;
  79059. id: string;
  79060. }
  79061. }
  79062. declare module BABYLON.GLTF1 {
  79063. /**
  79064. * Utils functions for GLTF
  79065. * @hidden
  79066. */
  79067. export class GLTFUtils {
  79068. /**
  79069. * Sets the given "parameter" matrix
  79070. * @param scene: the Scene object
  79071. * @param source: the source node where to pick the matrix
  79072. * @param parameter: the GLTF technique parameter
  79073. * @param uniformName: the name of the shader's uniform
  79074. * @param shaderMaterial: the shader material
  79075. */
  79076. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  79077. /**
  79078. * Sets the given "parameter" matrix
  79079. * @param shaderMaterial: the shader material
  79080. * @param uniform: the name of the shader's uniform
  79081. * @param value: the value of the uniform
  79082. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  79083. */
  79084. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  79085. /**
  79086. * Returns the wrap mode of the texture
  79087. * @param mode: the mode value
  79088. */
  79089. static GetWrapMode(mode: number): number;
  79090. /**
  79091. * Returns the byte stride giving an accessor
  79092. * @param accessor: the GLTF accessor objet
  79093. */
  79094. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  79095. /**
  79096. * Returns the texture filter mode giving a mode value
  79097. * @param mode: the filter mode value
  79098. */
  79099. static GetTextureFilterMode(mode: number): ETextureFilterType;
  79100. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  79101. /**
  79102. * Returns a buffer from its accessor
  79103. * @param gltfRuntime: the GLTF runtime
  79104. * @param accessor: the GLTF accessor
  79105. */
  79106. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  79107. /**
  79108. * Decodes a buffer view into a string
  79109. * @param view: the buffer view
  79110. */
  79111. static DecodeBufferToText(view: ArrayBufferView): string;
  79112. /**
  79113. * Returns the default material of gltf. Related to
  79114. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  79115. * @param scene: the Babylon.js scene
  79116. */
  79117. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  79118. private static _DefaultMaterial;
  79119. }
  79120. }
  79121. declare module BABYLON.GLTF1 {
  79122. /**
  79123. * Implementation of the base glTF spec
  79124. * @hidden
  79125. */
  79126. export class GLTFLoaderBase {
  79127. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  79128. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  79129. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  79130. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  79131. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  79132. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  79133. }
  79134. /**
  79135. * glTF V1 Loader
  79136. * @hidden
  79137. */
  79138. export class GLTFLoader implements IGLTFLoader {
  79139. static Extensions: {
  79140. [name: string]: GLTFLoaderExtension;
  79141. };
  79142. static RegisterExtension(extension: GLTFLoaderExtension): void;
  79143. state: Nullable<GLTFLoaderState>;
  79144. dispose(): void;
  79145. private _importMeshAsync;
  79146. /**
  79147. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  79148. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  79149. * @param scene the scene the meshes should be added to
  79150. * @param forAssetContainer defines if the entities must be stored in the scene
  79151. * @param data gltf data containing information of the meshes in a loaded file
  79152. * @param rootUrl root url to load from
  79153. * @param onProgress event that fires when loading progress has occured
  79154. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  79155. */
  79156. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  79157. private _loadAsync;
  79158. /**
  79159. * Imports all objects from a loaded gltf file and adds them to the scene
  79160. * @param scene the scene the objects should be added to
  79161. * @param data gltf data containing information of the meshes in a loaded file
  79162. * @param rootUrl root url to load from
  79163. * @param onProgress event that fires when loading progress has occured
  79164. * @returns a promise which completes when objects have been loaded to the scene
  79165. */
  79166. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  79167. private _loadShadersAsync;
  79168. private _loadBuffersAsync;
  79169. private _createNodes;
  79170. }
  79171. /** @hidden */
  79172. export abstract class GLTFLoaderExtension {
  79173. private _name;
  79174. constructor(name: string);
  79175. get name(): string;
  79176. /**
  79177. * Defines an override for loading the runtime
  79178. * Return true to stop further extensions from loading the runtime
  79179. */
  79180. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  79181. /**
  79182. * Defines an onverride for creating gltf runtime
  79183. * Return true to stop further extensions from creating the runtime
  79184. */
  79185. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  79186. /**
  79187. * Defines an override for loading buffers
  79188. * Return true to stop further extensions from loading this buffer
  79189. */
  79190. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  79191. /**
  79192. * Defines an override for loading texture buffers
  79193. * Return true to stop further extensions from loading this texture data
  79194. */
  79195. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79196. /**
  79197. * Defines an override for creating textures
  79198. * Return true to stop further extensions from loading this texture
  79199. */
  79200. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  79201. /**
  79202. * Defines an override for loading shader strings
  79203. * Return true to stop further extensions from loading this shader data
  79204. */
  79205. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  79206. /**
  79207. * Defines an override for loading materials
  79208. * Return true to stop further extensions from loading this material
  79209. */
  79210. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  79211. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  79212. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  79213. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  79214. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  79215. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  79216. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  79217. private static LoadTextureBufferAsync;
  79218. private static CreateTextureAsync;
  79219. private static ApplyExtensions;
  79220. }
  79221. }
  79222. declare module BABYLON.GLTF1 {
  79223. /** @hidden */
  79224. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  79225. private _bin;
  79226. constructor();
  79227. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  79228. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79229. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79230. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  79231. }
  79232. }
  79233. declare module BABYLON.GLTF1 {
  79234. /** @hidden */
  79235. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  79236. constructor();
  79237. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  79238. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  79239. private _loadTexture;
  79240. }
  79241. }
  79242. declare module BABYLON.GLTF2.Loader {
  79243. /**
  79244. * Loader interface with an index field.
  79245. */
  79246. export interface IArrayItem {
  79247. /**
  79248. * The index of this item in the array.
  79249. */
  79250. index: number;
  79251. }
  79252. /**
  79253. * Loader interface with additional members.
  79254. */
  79255. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  79256. /** @hidden */
  79257. _data?: Promise<ArrayBufferView>;
  79258. /** @hidden */
  79259. _babylonVertexBuffer?: Promise<VertexBuffer>;
  79260. }
  79261. /**
  79262. * Loader interface with additional members.
  79263. */
  79264. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  79265. }
  79266. /** @hidden */
  79267. export interface _IAnimationSamplerData {
  79268. input: Float32Array;
  79269. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  79270. output: Float32Array;
  79271. }
  79272. /**
  79273. * Loader interface with additional members.
  79274. */
  79275. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  79276. /** @hidden */
  79277. _data?: Promise<_IAnimationSamplerData>;
  79278. }
  79279. /**
  79280. * Loader interface with additional members.
  79281. */
  79282. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  79283. channels: IAnimationChannel[];
  79284. samplers: IAnimationSampler[];
  79285. /** @hidden */
  79286. _babylonAnimationGroup?: AnimationGroup;
  79287. }
  79288. /**
  79289. * Loader interface with additional members.
  79290. */
  79291. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  79292. /** @hidden */
  79293. _data?: Promise<ArrayBufferView>;
  79294. }
  79295. /**
  79296. * Loader interface with additional members.
  79297. */
  79298. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  79299. /** @hidden */
  79300. _data?: Promise<ArrayBufferView>;
  79301. /** @hidden */
  79302. _babylonBuffer?: Promise<Buffer>;
  79303. }
  79304. /**
  79305. * Loader interface with additional members.
  79306. */
  79307. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  79308. }
  79309. /**
  79310. * Loader interface with additional members.
  79311. */
  79312. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  79313. /** @hidden */
  79314. _data?: Promise<ArrayBufferView>;
  79315. }
  79316. /**
  79317. * Loader interface with additional members.
  79318. */
  79319. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  79320. }
  79321. /**
  79322. * Loader interface with additional members.
  79323. */
  79324. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  79325. }
  79326. /**
  79327. * Loader interface with additional members.
  79328. */
  79329. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  79330. baseColorTexture?: ITextureInfo;
  79331. metallicRoughnessTexture?: ITextureInfo;
  79332. }
  79333. /**
  79334. * Loader interface with additional members.
  79335. */
  79336. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  79337. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  79338. normalTexture?: IMaterialNormalTextureInfo;
  79339. occlusionTexture?: IMaterialOcclusionTextureInfo;
  79340. emissiveTexture?: ITextureInfo;
  79341. /** @hidden */
  79342. _data?: {
  79343. [babylonDrawMode: number]: {
  79344. babylonMaterial: Material;
  79345. babylonMeshes: AbstractMesh[];
  79346. promise: Promise<void>;
  79347. };
  79348. };
  79349. }
  79350. /**
  79351. * Loader interface with additional members.
  79352. */
  79353. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  79354. primitives: IMeshPrimitive[];
  79355. }
  79356. /**
  79357. * Loader interface with additional members.
  79358. */
  79359. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  79360. /** @hidden */
  79361. _instanceData?: {
  79362. babylonSourceMesh: Mesh;
  79363. promise: Promise<any>;
  79364. };
  79365. }
  79366. /**
  79367. * Loader interface with additional members.
  79368. */
  79369. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  79370. /**
  79371. * The parent glTF node.
  79372. */
  79373. parent?: INode;
  79374. /** @hidden */
  79375. _babylonTransformNode?: TransformNode;
  79376. /** @hidden */
  79377. _primitiveBabylonMeshes?: AbstractMesh[];
  79378. /** @hidden */
  79379. _babylonBones?: Bone[];
  79380. /** @hidden */
  79381. _numMorphTargets?: number;
  79382. }
  79383. /** @hidden */
  79384. export interface _ISamplerData {
  79385. noMipMaps: boolean;
  79386. samplingMode: number;
  79387. wrapU: number;
  79388. wrapV: number;
  79389. }
  79390. /**
  79391. * Loader interface with additional members.
  79392. */
  79393. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  79394. /** @hidden */
  79395. _data?: _ISamplerData;
  79396. }
  79397. /**
  79398. * Loader interface with additional members.
  79399. */
  79400. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  79401. }
  79402. /**
  79403. * Loader interface with additional members.
  79404. */
  79405. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  79406. /** @hidden */
  79407. _data?: {
  79408. babylonSkeleton: Skeleton;
  79409. promise: Promise<void>;
  79410. };
  79411. }
  79412. /**
  79413. * Loader interface with additional members.
  79414. */
  79415. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  79416. }
  79417. /**
  79418. * Loader interface with additional members.
  79419. */
  79420. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  79421. }
  79422. /**
  79423. * Loader interface with additional members.
  79424. */
  79425. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  79426. accessors?: IAccessor[];
  79427. animations?: IAnimation[];
  79428. buffers?: IBuffer[];
  79429. bufferViews?: IBufferView[];
  79430. cameras?: ICamera[];
  79431. images?: IImage[];
  79432. materials?: IMaterial[];
  79433. meshes?: IMesh[];
  79434. nodes?: INode[];
  79435. samplers?: ISampler[];
  79436. scenes?: IScene[];
  79437. skins?: ISkin[];
  79438. textures?: ITexture[];
  79439. }
  79440. }
  79441. declare module BABYLON.GLTF2 {
  79442. /**
  79443. * Interface for a glTF loader extension.
  79444. */
  79445. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  79446. /**
  79447. * Called after the loader state changes to LOADING.
  79448. */
  79449. onLoading?(): void;
  79450. /**
  79451. * Called after the loader state changes to READY.
  79452. */
  79453. onReady?(): void;
  79454. /**
  79455. * Define this method to modify the default behavior when loading scenes.
  79456. * @param context The context when loading the asset
  79457. * @param scene The glTF scene property
  79458. * @returns A promise that resolves when the load is complete or null if not handled
  79459. */
  79460. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  79461. /**
  79462. * Define this method to modify the default behavior when loading nodes.
  79463. * @param context The context when loading the asset
  79464. * @param node The glTF node property
  79465. * @param assign A function called synchronously after parsing the glTF properties
  79466. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  79467. */
  79468. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79469. /**
  79470. * Define this method to modify the default behavior when loading cameras.
  79471. * @param context The context when loading the asset
  79472. * @param camera The glTF camera property
  79473. * @param assign A function called synchronously after parsing the glTF properties
  79474. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  79475. */
  79476. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  79477. /**
  79478. * @hidden
  79479. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  79480. * @param context The context when loading the asset
  79481. * @param primitive The glTF mesh primitive property
  79482. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  79483. */
  79484. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  79485. /**
  79486. * @hidden
  79487. * Define this method to modify the default behavior when loading data for mesh primitives.
  79488. * @param context The context when loading the asset
  79489. * @param name The mesh name when loading the asset
  79490. * @param node The glTF node when loading the asset
  79491. * @param mesh The glTF mesh when loading the asset
  79492. * @param primitive The glTF mesh primitive property
  79493. * @param assign A function called synchronously after parsing the glTF properties
  79494. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  79495. */
  79496. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  79497. /**
  79498. * @hidden
  79499. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  79500. * @param context The context when loading the asset
  79501. * @param material The glTF material property
  79502. * @param assign A function called synchronously after parsing the glTF properties
  79503. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  79504. */
  79505. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  79506. /**
  79507. * Define this method to modify the default behavior when creating materials.
  79508. * @param context The context when loading the asset
  79509. * @param material The glTF material property
  79510. * @param babylonDrawMode The draw mode for the Babylon material
  79511. * @returns The Babylon material or null if not handled
  79512. */
  79513. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  79514. /**
  79515. * Define this method to modify the default behavior when loading material properties.
  79516. * @param context The context when loading the asset
  79517. * @param material The glTF material property
  79518. * @param babylonMaterial The Babylon material
  79519. * @returns A promise that resolves when the load is complete or null if not handled
  79520. */
  79521. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79522. /**
  79523. * Define this method to modify the default behavior when loading texture infos.
  79524. * @param context The context when loading the asset
  79525. * @param textureInfo The glTF texture info property
  79526. * @param assign A function called synchronously after parsing the glTF properties
  79527. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  79528. */
  79529. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79530. /**
  79531. * @hidden
  79532. * Define this method to modify the default behavior when loading textures.
  79533. * @param context The context when loading the asset
  79534. * @param texture The glTF texture property
  79535. * @param assign A function called synchronously after parsing the glTF properties
  79536. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  79537. */
  79538. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79539. /**
  79540. * Define this method to modify the default behavior when loading animations.
  79541. * @param context The context when loading the asset
  79542. * @param animation The glTF animation property
  79543. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  79544. */
  79545. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  79546. /**
  79547. * @hidden
  79548. * Define this method to modify the default behavior when loading skins.
  79549. * @param context The context when loading the asset
  79550. * @param node The glTF node property
  79551. * @param skin The glTF skin property
  79552. * @returns A promise that resolves when the load is complete or null if not handled
  79553. */
  79554. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  79555. /**
  79556. * @hidden
  79557. * Define this method to modify the default behavior when loading uris.
  79558. * @param context The context when loading the asset
  79559. * @param property The glTF property associated with the uri
  79560. * @param uri The uri to load
  79561. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  79562. */
  79563. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  79564. /**
  79565. * Define this method to modify the default behavior when loading buffer views.
  79566. * @param context The context when loading the asset
  79567. * @param bufferView The glTF buffer view property
  79568. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  79569. */
  79570. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  79571. /**
  79572. * Define this method to modify the default behavior when loading buffers.
  79573. * @param context The context when loading the asset
  79574. * @param buffer The glTF buffer property
  79575. * @param byteOffset The byte offset to load
  79576. * @param byteLength The byte length to load
  79577. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  79578. */
  79579. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  79580. }
  79581. }
  79582. declare module BABYLON.GLTF2 {
  79583. /**
  79584. * Helper class for working with arrays when loading the glTF asset
  79585. */
  79586. export class ArrayItem {
  79587. /**
  79588. * Gets an item from the given array.
  79589. * @param context The context when loading the asset
  79590. * @param array The array to get the item from
  79591. * @param index The index to the array
  79592. * @returns The array item
  79593. */
  79594. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  79595. /**
  79596. * Assign an `index` field to each item of the given array.
  79597. * @param array The array of items
  79598. */
  79599. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  79600. }
  79601. /**
  79602. * The glTF 2.0 loader
  79603. */
  79604. export class GLTFLoader implements IGLTFLoader {
  79605. /** @hidden */
  79606. _completePromises: Promise<any>[];
  79607. /** @hidden */
  79608. _forAssetContainer: boolean;
  79609. /** Storage */
  79610. _babylonLights: Light[];
  79611. /** @hidden */
  79612. _disableInstancedMesh: number;
  79613. private _disposed;
  79614. private _parent;
  79615. private _state;
  79616. private _extensions;
  79617. private _rootUrl;
  79618. private _fileName;
  79619. private _uniqueRootUrl;
  79620. private _gltf;
  79621. private _bin;
  79622. private _babylonScene;
  79623. private _rootBabylonMesh;
  79624. private _defaultBabylonMaterialData;
  79625. private static _RegisteredExtensions;
  79626. /**
  79627. * The default glTF sampler.
  79628. */
  79629. static readonly DefaultSampler: ISampler;
  79630. /**
  79631. * Registers a loader extension.
  79632. * @param name The name of the loader extension.
  79633. * @param factory The factory function that creates the loader extension.
  79634. */
  79635. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  79636. /**
  79637. * Unregisters a loader extension.
  79638. * @param name The name of the loader extension.
  79639. * @returns A boolean indicating whether the extension has been unregistered
  79640. */
  79641. static UnregisterExtension(name: string): boolean;
  79642. /**
  79643. * The loader state.
  79644. */
  79645. get state(): Nullable<GLTFLoaderState>;
  79646. /**
  79647. * The object that represents the glTF JSON.
  79648. */
  79649. get gltf(): IGLTF;
  79650. /**
  79651. * The BIN chunk of a binary glTF.
  79652. */
  79653. get bin(): Nullable<IDataBuffer>;
  79654. /**
  79655. * The parent file loader.
  79656. */
  79657. get parent(): GLTFFileLoader;
  79658. /**
  79659. * The Babylon scene when loading the asset.
  79660. */
  79661. get babylonScene(): Scene;
  79662. /**
  79663. * The root Babylon mesh when loading the asset.
  79664. */
  79665. get rootBabylonMesh(): Mesh;
  79666. /** @hidden */
  79667. constructor(parent: GLTFFileLoader);
  79668. /** @hidden */
  79669. dispose(): void;
  79670. /** @hidden */
  79671. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  79672. /** @hidden */
  79673. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  79674. private _loadAsync;
  79675. private _loadData;
  79676. private _setupData;
  79677. private _loadExtensions;
  79678. private _checkExtensions;
  79679. private _setState;
  79680. private _createRootNode;
  79681. /**
  79682. * Loads a glTF scene.
  79683. * @param context The context when loading the asset
  79684. * @param scene The glTF scene property
  79685. * @returns A promise that resolves when the load is complete
  79686. */
  79687. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  79688. private _forEachPrimitive;
  79689. private _getMeshes;
  79690. private _getTransformNodes;
  79691. private _getSkeletons;
  79692. private _getAnimationGroups;
  79693. private _startAnimations;
  79694. /**
  79695. * Loads a glTF node.
  79696. * @param context The context when loading the asset
  79697. * @param node The glTF node property
  79698. * @param assign A function called synchronously after parsing the glTF properties
  79699. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  79700. */
  79701. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  79702. private _loadMeshAsync;
  79703. /**
  79704. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  79705. * @param context The context when loading the asset
  79706. * @param name The mesh name when loading the asset
  79707. * @param node The glTF node when loading the asset
  79708. * @param mesh The glTF mesh when loading the asset
  79709. * @param primitive The glTF mesh primitive property
  79710. * @param assign A function called synchronously after parsing the glTF properties
  79711. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  79712. */
  79713. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  79714. private _loadVertexDataAsync;
  79715. private _createMorphTargets;
  79716. private _loadMorphTargetsAsync;
  79717. private _loadMorphTargetVertexDataAsync;
  79718. private static _LoadTransform;
  79719. private _loadSkinAsync;
  79720. private _loadBones;
  79721. private _loadBone;
  79722. private _loadSkinInverseBindMatricesDataAsync;
  79723. private _updateBoneMatrices;
  79724. private _getNodeMatrix;
  79725. /**
  79726. * Loads a glTF camera.
  79727. * @param context The context when loading the asset
  79728. * @param camera The glTF camera property
  79729. * @param assign A function called synchronously after parsing the glTF properties
  79730. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  79731. */
  79732. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  79733. private _loadAnimationsAsync;
  79734. /**
  79735. * Loads a glTF animation.
  79736. * @param context The context when loading the asset
  79737. * @param animation The glTF animation property
  79738. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  79739. */
  79740. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  79741. /**
  79742. * @hidden Loads a glTF animation channel.
  79743. * @param context The context when loading the asset
  79744. * @param animationContext The context of the animation when loading the asset
  79745. * @param animation The glTF animation property
  79746. * @param channel The glTF animation channel property
  79747. * @param babylonAnimationGroup The babylon animation group property
  79748. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  79749. * @returns A void promise when the channel load is complete
  79750. */
  79751. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  79752. private _loadAnimationSamplerAsync;
  79753. private _loadBufferAsync;
  79754. /**
  79755. * Loads a glTF buffer view.
  79756. * @param context The context when loading the asset
  79757. * @param bufferView The glTF buffer view property
  79758. * @returns A promise that resolves with the loaded data when the load is complete
  79759. */
  79760. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  79761. private _loadAccessorAsync;
  79762. /** @hidden */
  79763. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  79764. private _loadIndicesAccessorAsync;
  79765. private _loadVertexBufferViewAsync;
  79766. private _loadVertexAccessorAsync;
  79767. private _loadMaterialMetallicRoughnessPropertiesAsync;
  79768. /** @hidden */
  79769. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  79770. private _createDefaultMaterial;
  79771. /**
  79772. * Creates a Babylon material from a glTF material.
  79773. * @param context The context when loading the asset
  79774. * @param material The glTF material property
  79775. * @param babylonDrawMode The draw mode for the Babylon material
  79776. * @returns The Babylon material
  79777. */
  79778. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  79779. /**
  79780. * Loads properties from a glTF material into a Babylon material.
  79781. * @param context The context when loading the asset
  79782. * @param material The glTF material property
  79783. * @param babylonMaterial The Babylon material
  79784. * @returns A promise that resolves when the load is complete
  79785. */
  79786. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  79787. /**
  79788. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  79789. * @param context The context when loading the asset
  79790. * @param material The glTF material property
  79791. * @param babylonMaterial The Babylon material
  79792. * @returns A promise that resolves when the load is complete
  79793. */
  79794. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  79795. /**
  79796. * Loads the alpha properties from a glTF material into a Babylon material.
  79797. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  79798. * @param context The context when loading the asset
  79799. * @param material The glTF material property
  79800. * @param babylonMaterial The Babylon material
  79801. */
  79802. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  79803. /**
  79804. * Loads a glTF texture info.
  79805. * @param context The context when loading the asset
  79806. * @param textureInfo The glTF texture info property
  79807. * @param assign A function called synchronously after parsing the glTF properties
  79808. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  79809. */
  79810. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79811. /** @hidden */
  79812. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79813. /** @hidden */
  79814. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79815. private _loadSampler;
  79816. /**
  79817. * Loads a glTF image.
  79818. * @param context The context when loading the asset
  79819. * @param image The glTF image property
  79820. * @returns A promise that resolves with the loaded data when the load is complete
  79821. */
  79822. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  79823. /**
  79824. * Loads a glTF uri.
  79825. * @param context The context when loading the asset
  79826. * @param property The glTF property associated with the uri
  79827. * @param uri The base64 or relative uri
  79828. * @returns A promise that resolves with the loaded data when the load is complete
  79829. */
  79830. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  79831. /**
  79832. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  79833. * @param babylonObject the Babylon object with metadata
  79834. * @param pointer the JSON pointer
  79835. */
  79836. static AddPointerMetadata(babylonObject: {
  79837. metadata: any;
  79838. }, pointer: string): void;
  79839. private static _GetTextureWrapMode;
  79840. private static _GetTextureSamplingMode;
  79841. private static _GetTypedArrayConstructor;
  79842. private static _GetTypedArray;
  79843. private static _GetNumComponents;
  79844. private static _ValidateUri;
  79845. /** @hidden */
  79846. static _GetDrawMode(context: string, mode: number | undefined): number;
  79847. private _compileMaterialsAsync;
  79848. private _compileShadowGeneratorsAsync;
  79849. private _forEachExtensions;
  79850. private _applyExtensions;
  79851. private _extensionsOnLoading;
  79852. private _extensionsOnReady;
  79853. private _extensionsLoadSceneAsync;
  79854. private _extensionsLoadNodeAsync;
  79855. private _extensionsLoadCameraAsync;
  79856. private _extensionsLoadVertexDataAsync;
  79857. private _extensionsLoadMeshPrimitiveAsync;
  79858. private _extensionsLoadMaterialAsync;
  79859. private _extensionsCreateMaterial;
  79860. private _extensionsLoadMaterialPropertiesAsync;
  79861. private _extensionsLoadTextureInfoAsync;
  79862. private _extensionsLoadTextureAsync;
  79863. private _extensionsLoadAnimationAsync;
  79864. private _extensionsLoadSkinAsync;
  79865. private _extensionsLoadUriAsync;
  79866. private _extensionsLoadBufferViewAsync;
  79867. private _extensionsLoadBufferAsync;
  79868. /**
  79869. * Helper method called by a loader extension to load an glTF extension.
  79870. * @param context The context when loading the asset
  79871. * @param property The glTF property to load the extension from
  79872. * @param extensionName The name of the extension to load
  79873. * @param actionAsync The action to run
  79874. * @returns The promise returned by actionAsync or null if the extension does not exist
  79875. */
  79876. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  79877. /**
  79878. * Helper method called by a loader extension to load a glTF extra.
  79879. * @param context The context when loading the asset
  79880. * @param property The glTF property to load the extra from
  79881. * @param extensionName The name of the extension to load
  79882. * @param actionAsync The action to run
  79883. * @returns The promise returned by actionAsync or null if the extra does not exist
  79884. */
  79885. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  79886. /**
  79887. * Checks for presence of an extension.
  79888. * @param name The name of the extension to check
  79889. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  79890. */
  79891. isExtensionUsed(name: string): boolean;
  79892. /**
  79893. * Increments the indentation level and logs a message.
  79894. * @param message The message to log
  79895. */
  79896. logOpen(message: string): void;
  79897. /**
  79898. * Decrements the indentation level.
  79899. */
  79900. logClose(): void;
  79901. /**
  79902. * Logs a message
  79903. * @param message The message to log
  79904. */
  79905. log(message: string): void;
  79906. /**
  79907. * Starts a performance counter.
  79908. * @param counterName The name of the performance counter
  79909. */
  79910. startPerformanceCounter(counterName: string): void;
  79911. /**
  79912. * Ends a performance counter.
  79913. * @param counterName The name of the performance counter
  79914. */
  79915. endPerformanceCounter(counterName: string): void;
  79916. }
  79917. }
  79918. declare module BABYLON.GLTF2.Loader.Extensions {
  79919. /**
  79920. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  79921. */
  79922. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  79923. /**
  79924. * The name of this extension.
  79925. */
  79926. readonly name: string;
  79927. /**
  79928. * Defines whether this extension is enabled.
  79929. */
  79930. enabled: boolean;
  79931. private _loader;
  79932. private _lights?;
  79933. /** @hidden */
  79934. constructor(loader: GLTFLoader);
  79935. /** @hidden */
  79936. dispose(): void;
  79937. /** @hidden */
  79938. onLoading(): void;
  79939. /** @hidden */
  79940. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  79941. private _loadLightAsync;
  79942. }
  79943. }
  79944. declare module BABYLON.GLTF2.Loader.Extensions {
  79945. /**
  79946. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  79947. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  79948. * !!! Experimental Extension Subject to Changes !!!
  79949. */
  79950. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  79951. /**
  79952. * The name of this extension.
  79953. */
  79954. readonly name: string;
  79955. /**
  79956. * Defines whether this extension is enabled.
  79957. */
  79958. enabled: boolean;
  79959. private _loader;
  79960. /** @hidden */
  79961. constructor(loader: GLTFLoader);
  79962. /** @hidden */
  79963. dispose(): void;
  79964. /** @hidden */
  79965. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79966. }
  79967. }
  79968. declare module BABYLON.GLTF2.Loader.Extensions {
  79969. /**
  79970. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  79971. */
  79972. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  79973. /**
  79974. * The name of this extension.
  79975. */
  79976. readonly name: string;
  79977. /**
  79978. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  79979. */
  79980. dracoCompression?: DracoCompression;
  79981. /**
  79982. * Defines whether this extension is enabled.
  79983. */
  79984. enabled: boolean;
  79985. private _loader;
  79986. /** @hidden */
  79987. constructor(loader: GLTFLoader);
  79988. /** @hidden */
  79989. dispose(): void;
  79990. /** @hidden */
  79991. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  79992. }
  79993. }
  79994. declare module BABYLON.GLTF2.Loader.Extensions {
  79995. /**
  79996. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  79997. */
  79998. export class KHR_lights implements IGLTFLoaderExtension {
  79999. /**
  80000. * The name of this extension.
  80001. */
  80002. readonly name: string;
  80003. /**
  80004. * Defines whether this extension is enabled.
  80005. */
  80006. enabled: boolean;
  80007. private _loader;
  80008. private _lights?;
  80009. /** @hidden */
  80010. constructor(loader: GLTFLoader);
  80011. /** @hidden */
  80012. dispose(): void;
  80013. /** @hidden */
  80014. onLoading(): void;
  80015. /** @hidden */
  80016. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80017. }
  80018. }
  80019. declare module BABYLON.GLTF2.Loader.Extensions {
  80020. /**
  80021. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  80022. */
  80023. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  80024. /**
  80025. * The name of this extension.
  80026. */
  80027. readonly name: string;
  80028. /**
  80029. * Defines whether this extension is enabled.
  80030. */
  80031. enabled: boolean;
  80032. /**
  80033. * Defines a number that determines the order the extensions are applied.
  80034. */
  80035. order: number;
  80036. private _loader;
  80037. /** @hidden */
  80038. constructor(loader: GLTFLoader);
  80039. /** @hidden */
  80040. dispose(): void;
  80041. /** @hidden */
  80042. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80043. private _loadSpecularGlossinessPropertiesAsync;
  80044. }
  80045. }
  80046. declare module BABYLON.GLTF2.Loader.Extensions {
  80047. /**
  80048. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  80049. */
  80050. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  80051. /**
  80052. * The name of this extension.
  80053. */
  80054. readonly name: string;
  80055. /**
  80056. * Defines whether this extension is enabled.
  80057. */
  80058. enabled: boolean;
  80059. /**
  80060. * Defines a number that determines the order the extensions are applied.
  80061. */
  80062. order: number;
  80063. private _loader;
  80064. /** @hidden */
  80065. constructor(loader: GLTFLoader);
  80066. /** @hidden */
  80067. dispose(): void;
  80068. /** @hidden */
  80069. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80070. private _loadUnlitPropertiesAsync;
  80071. }
  80072. }
  80073. declare module BABYLON.GLTF2.Loader.Extensions {
  80074. /**
  80075. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  80076. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  80077. * !!! Experimental Extension Subject to Changes !!!
  80078. */
  80079. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  80080. /**
  80081. * The name of this extension.
  80082. */
  80083. readonly name: string;
  80084. /**
  80085. * Defines whether this extension is enabled.
  80086. */
  80087. enabled: boolean;
  80088. /**
  80089. * Defines a number that determines the order the extensions are applied.
  80090. */
  80091. order: number;
  80092. private _loader;
  80093. /** @hidden */
  80094. constructor(loader: GLTFLoader);
  80095. /** @hidden */
  80096. dispose(): void;
  80097. /** @hidden */
  80098. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80099. private _loadClearCoatPropertiesAsync;
  80100. }
  80101. }
  80102. declare module BABYLON.GLTF2.Loader.Extensions {
  80103. /**
  80104. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  80105. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  80106. * !!! Experimental Extension Subject to Changes !!!
  80107. */
  80108. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  80109. /**
  80110. * The name of this extension.
  80111. */
  80112. readonly name: string;
  80113. /**
  80114. * Defines whether this extension is enabled.
  80115. */
  80116. enabled: boolean;
  80117. /**
  80118. * Defines a number that determines the order the extensions are applied.
  80119. */
  80120. order: number;
  80121. private _loader;
  80122. /** @hidden */
  80123. constructor(loader: GLTFLoader);
  80124. /** @hidden */
  80125. dispose(): void;
  80126. /** @hidden */
  80127. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80128. private _loadSheenPropertiesAsync;
  80129. }
  80130. }
  80131. declare module BABYLON.GLTF2.Loader.Extensions {
  80132. /**
  80133. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  80134. * !!! Experimental Extension Subject to Changes !!!
  80135. */
  80136. export class KHR_materials_specular implements IGLTFLoaderExtension {
  80137. /**
  80138. * The name of this extension.
  80139. */
  80140. readonly name: string;
  80141. /**
  80142. * Defines whether this extension is enabled.
  80143. */
  80144. enabled: boolean;
  80145. /**
  80146. * Defines a number that determines the order the extensions are applied.
  80147. */
  80148. order: number;
  80149. private _loader;
  80150. /** @hidden */
  80151. constructor(loader: GLTFLoader);
  80152. /** @hidden */
  80153. dispose(): void;
  80154. /** @hidden */
  80155. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80156. private _loadSpecularPropertiesAsync;
  80157. }
  80158. }
  80159. declare module BABYLON.GLTF2.Loader.Extensions {
  80160. /**
  80161. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  80162. * !!! Experimental Extension Subject to Changes !!!
  80163. */
  80164. export class KHR_materials_ior implements IGLTFLoaderExtension {
  80165. /**
  80166. * Default ior Value from the spec.
  80167. */
  80168. private static readonly _DEFAULT_IOR;
  80169. /**
  80170. * The name of this extension.
  80171. */
  80172. readonly name: string;
  80173. /**
  80174. * Defines whether this extension is enabled.
  80175. */
  80176. enabled: boolean;
  80177. /**
  80178. * Defines a number that determines the order the extensions are applied.
  80179. */
  80180. order: number;
  80181. private _loader;
  80182. /** @hidden */
  80183. constructor(loader: GLTFLoader);
  80184. /** @hidden */
  80185. dispose(): void;
  80186. /** @hidden */
  80187. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80188. private _loadIorPropertiesAsync;
  80189. }
  80190. }
  80191. declare module BABYLON.GLTF2.Loader.Extensions {
  80192. /**
  80193. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  80194. * !!! Experimental Extension Subject to Changes !!!
  80195. */
  80196. export class KHR_materials_variants implements IGLTFLoaderExtension {
  80197. /**
  80198. * The name of this extension.
  80199. */
  80200. readonly name: string;
  80201. /**
  80202. * Defines whether this extension is enabled.
  80203. */
  80204. enabled: boolean;
  80205. private _loader;
  80206. /** @hidden */
  80207. constructor(loader: GLTFLoader);
  80208. /** @hidden */
  80209. dispose(): void;
  80210. /**
  80211. * Gets the list of available variant tag names for this asset.
  80212. * @param rootMesh The glTF root mesh
  80213. * @returns the list of all the variant names for this model
  80214. */
  80215. static GetAvailableVariants(rootMesh: Mesh): string[];
  80216. /**
  80217. * Select a variant given a variant tag name or a list of variant tag names.
  80218. * @param rootMesh The glTF root mesh
  80219. * @param variantName The variant name(s) to select.
  80220. */
  80221. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  80222. /**
  80223. * Reset back to the original before selecting a variant.
  80224. * @param rootMesh The glTF root mesh
  80225. */
  80226. static Reset(rootMesh: Mesh): void;
  80227. /**
  80228. * Gets the last selected variant tag name(s) or null if original.
  80229. * @param rootMesh The glTF root mesh
  80230. * @returns The selected variant tag name(s).
  80231. */
  80232. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  80233. private static _GetExtensionMetadata;
  80234. /** @hidden */
  80235. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  80236. }
  80237. }
  80238. declare module BABYLON.GLTF2.Loader.Extensions {
  80239. /**
  80240. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  80241. * !!! Experimental Extension Subject to Changes !!!
  80242. */
  80243. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  80244. /**
  80245. * The name of this extension.
  80246. */
  80247. readonly name: string;
  80248. /**
  80249. * Defines whether this extension is enabled.
  80250. */
  80251. enabled: boolean;
  80252. /**
  80253. * Defines a number that determines the order the extensions are applied.
  80254. */
  80255. order: number;
  80256. private _loader;
  80257. /** @hidden */
  80258. constructor(loader: GLTFLoader);
  80259. /** @hidden */
  80260. dispose(): void;
  80261. /** @hidden */
  80262. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80263. private _loadTransparentPropertiesAsync;
  80264. }
  80265. }
  80266. declare module BABYLON.GLTF2.Loader.Extensions {
  80267. /**
  80268. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  80269. */
  80270. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  80271. /**
  80272. * The name of this extension.
  80273. */
  80274. readonly name: string;
  80275. /**
  80276. * Defines whether this extension is enabled.
  80277. */
  80278. enabled: boolean;
  80279. /** @hidden */
  80280. constructor(loader: GLTFLoader);
  80281. /** @hidden */
  80282. dispose(): void;
  80283. }
  80284. }
  80285. declare module BABYLON.GLTF2.Loader.Extensions {
  80286. /**
  80287. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  80288. * !!! Experimental Extension Subject to Changes !!!
  80289. */
  80290. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  80291. /** The name of this extension. */
  80292. readonly name: string;
  80293. /** Defines whether this extension is enabled. */
  80294. enabled: boolean;
  80295. private _loader;
  80296. /** @hidden */
  80297. constructor(loader: GLTFLoader);
  80298. /** @hidden */
  80299. dispose(): void;
  80300. /** @hidden */
  80301. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80302. }
  80303. }
  80304. declare module BABYLON.GLTF2.Loader.Extensions {
  80305. /**
  80306. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  80307. */
  80308. export class KHR_texture_transform implements IGLTFLoaderExtension {
  80309. /**
  80310. * The name of this extension.
  80311. */
  80312. readonly name: string;
  80313. /**
  80314. * Defines whether this extension is enabled.
  80315. */
  80316. enabled: boolean;
  80317. private _loader;
  80318. /** @hidden */
  80319. constructor(loader: GLTFLoader);
  80320. /** @hidden */
  80321. dispose(): void;
  80322. /** @hidden */
  80323. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80324. }
  80325. }
  80326. declare module BABYLON.GLTF2.Loader.Extensions {
  80327. /**
  80328. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  80329. * !!! Experimental Extension Subject to Changes !!!
  80330. */
  80331. export class KHR_xmp implements IGLTFLoaderExtension {
  80332. /**
  80333. * The name of this extension.
  80334. */
  80335. readonly name: string;
  80336. /**
  80337. * Defines whether this extension is enabled.
  80338. */
  80339. enabled: boolean;
  80340. /**
  80341. * Defines a number that determines the order the extensions are applied.
  80342. */
  80343. order: number;
  80344. private _loader;
  80345. /** @hidden */
  80346. constructor(loader: GLTFLoader);
  80347. /** @hidden */
  80348. dispose(): void;
  80349. /**
  80350. * Called after the loader state changes to LOADING.
  80351. */
  80352. onLoading(): void;
  80353. }
  80354. }
  80355. declare module BABYLON.GLTF2.Loader.Extensions {
  80356. /**
  80357. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  80358. */
  80359. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  80360. /**
  80361. * The name of this extension.
  80362. */
  80363. readonly name: string;
  80364. /**
  80365. * Defines whether this extension is enabled.
  80366. */
  80367. enabled: boolean;
  80368. private _loader;
  80369. private _clips;
  80370. private _emitters;
  80371. /** @hidden */
  80372. constructor(loader: GLTFLoader);
  80373. /** @hidden */
  80374. dispose(): void;
  80375. /** @hidden */
  80376. onLoading(): void;
  80377. /** @hidden */
  80378. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  80379. /** @hidden */
  80380. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80381. /** @hidden */
  80382. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  80383. private _loadClipAsync;
  80384. private _loadEmitterAsync;
  80385. private _getEventAction;
  80386. private _loadAnimationEventAsync;
  80387. }
  80388. }
  80389. declare module BABYLON.GLTF2.Loader.Extensions {
  80390. /**
  80391. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  80392. */
  80393. export class MSFT_lod implements IGLTFLoaderExtension {
  80394. /**
  80395. * The name of this extension.
  80396. */
  80397. readonly name: string;
  80398. /**
  80399. * Defines whether this extension is enabled.
  80400. */
  80401. enabled: boolean;
  80402. /**
  80403. * Defines a number that determines the order the extensions are applied.
  80404. */
  80405. order: number;
  80406. /**
  80407. * Maximum number of LODs to load, starting from the lowest LOD.
  80408. */
  80409. maxLODsToLoad: number;
  80410. /**
  80411. * Observable raised when all node LODs of one level are loaded.
  80412. * The event data is the index of the loaded LOD starting from zero.
  80413. * Dispose the loader to cancel the loading of the next level of LODs.
  80414. */
  80415. onNodeLODsLoadedObservable: Observable<number>;
  80416. /**
  80417. * Observable raised when all material LODs of one level are loaded.
  80418. * The event data is the index of the loaded LOD starting from zero.
  80419. * Dispose the loader to cancel the loading of the next level of LODs.
  80420. */
  80421. onMaterialLODsLoadedObservable: Observable<number>;
  80422. private _loader;
  80423. private _bufferLODs;
  80424. private _nodeIndexLOD;
  80425. private _nodeSignalLODs;
  80426. private _nodePromiseLODs;
  80427. private _nodeBufferLODs;
  80428. private _materialIndexLOD;
  80429. private _materialSignalLODs;
  80430. private _materialPromiseLODs;
  80431. private _materialBufferLODs;
  80432. /** @hidden */
  80433. constructor(loader: GLTFLoader);
  80434. /** @hidden */
  80435. dispose(): void;
  80436. /** @hidden */
  80437. onReady(): void;
  80438. /** @hidden */
  80439. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  80440. /** @hidden */
  80441. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80442. /** @hidden */
  80443. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  80444. /** @hidden */
  80445. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  80446. /** @hidden */
  80447. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  80448. private _loadBufferLOD;
  80449. /**
  80450. * Gets an array of LOD properties from lowest to highest.
  80451. */
  80452. private _getLODs;
  80453. private _disposeTransformNode;
  80454. private _disposeMaterials;
  80455. }
  80456. }
  80457. declare module BABYLON.GLTF2.Loader.Extensions {
  80458. /** @hidden */
  80459. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  80460. readonly name: string;
  80461. enabled: boolean;
  80462. private _loader;
  80463. constructor(loader: GLTFLoader);
  80464. dispose(): void;
  80465. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80466. }
  80467. }
  80468. declare module BABYLON.GLTF2.Loader.Extensions {
  80469. /** @hidden */
  80470. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  80471. readonly name: string;
  80472. enabled: boolean;
  80473. private _loader;
  80474. constructor(loader: GLTFLoader);
  80475. dispose(): void;
  80476. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80477. }
  80478. }
  80479. declare module BABYLON.GLTF2.Loader.Extensions {
  80480. /**
  80481. * Store glTF extras (if present) in BJS objects' metadata
  80482. */
  80483. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  80484. /**
  80485. * The name of this extension.
  80486. */
  80487. readonly name: string;
  80488. /**
  80489. * Defines whether this extension is enabled.
  80490. */
  80491. enabled: boolean;
  80492. private _loader;
  80493. private _assignExtras;
  80494. /** @hidden */
  80495. constructor(loader: GLTFLoader);
  80496. /** @hidden */
  80497. dispose(): void;
  80498. /** @hidden */
  80499. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80500. /** @hidden */
  80501. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  80502. /** @hidden */
  80503. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  80504. }
  80505. }
  80506. declare module BABYLON {
  80507. /**
  80508. * Class reading and parsing the MTL file bundled with the obj file.
  80509. */
  80510. export class MTLFileLoader {
  80511. /**
  80512. * Invert Y-Axis of referenced textures on load
  80513. */
  80514. static INVERT_TEXTURE_Y: boolean;
  80515. /**
  80516. * All material loaded from the mtl will be set here
  80517. */
  80518. materials: StandardMaterial[];
  80519. /**
  80520. * This function will read the mtl file and create each material described inside
  80521. * This function could be improve by adding :
  80522. * -some component missing (Ni, Tf...)
  80523. * -including the specific options available
  80524. *
  80525. * @param scene defines the scene the material will be created in
  80526. * @param data defines the mtl data to parse
  80527. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  80528. * @param forAssetContainer defines if the material should be registered in the scene
  80529. */
  80530. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  80531. /**
  80532. * Gets the texture for the material.
  80533. *
  80534. * If the material is imported from input file,
  80535. * We sanitize the url to ensure it takes the textre from aside the material.
  80536. *
  80537. * @param rootUrl The root url to load from
  80538. * @param value The value stored in the mtl
  80539. * @return The Texture
  80540. */
  80541. private static _getTexture;
  80542. }
  80543. }
  80544. declare module BABYLON {
  80545. /**
  80546. * Options for loading OBJ/MTL files
  80547. */
  80548. type MeshLoadOptions = {
  80549. /**
  80550. * Defines if UVs are optimized by default during load.
  80551. */
  80552. OptimizeWithUV: boolean;
  80553. /**
  80554. * Defines custom scaling of UV coordinates of loaded meshes.
  80555. */
  80556. UVScaling: Vector2;
  80557. /**
  80558. * Invert model on y-axis (does a model scaling inversion)
  80559. */
  80560. InvertY: boolean;
  80561. /**
  80562. * Invert Y-Axis of referenced textures on load
  80563. */
  80564. InvertTextureY: boolean;
  80565. /**
  80566. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  80567. */
  80568. ImportVertexColors: boolean;
  80569. /**
  80570. * Compute the normals for the model, even if normals are present in the file.
  80571. */
  80572. ComputeNormals: boolean;
  80573. /**
  80574. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  80575. */
  80576. SkipMaterials: boolean;
  80577. /**
  80578. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  80579. */
  80580. MaterialLoadingFailsSilently: boolean;
  80581. };
  80582. /**
  80583. * OBJ file type loader.
  80584. * This is a babylon scene loader plugin.
  80585. */
  80586. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  80587. /**
  80588. * Defines if UVs are optimized by default during load.
  80589. */
  80590. static OPTIMIZE_WITH_UV: boolean;
  80591. /**
  80592. * Invert model on y-axis (does a model scaling inversion)
  80593. */
  80594. static INVERT_Y: boolean;
  80595. /**
  80596. * Invert Y-Axis of referenced textures on load
  80597. */
  80598. static get INVERT_TEXTURE_Y(): boolean;
  80599. static set INVERT_TEXTURE_Y(value: boolean);
  80600. /**
  80601. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  80602. */
  80603. static IMPORT_VERTEX_COLORS: boolean;
  80604. /**
  80605. * Compute the normals for the model, even if normals are present in the file.
  80606. */
  80607. static COMPUTE_NORMALS: boolean;
  80608. /**
  80609. * Defines custom scaling of UV coordinates of loaded meshes.
  80610. */
  80611. static UV_SCALING: Vector2;
  80612. /**
  80613. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  80614. */
  80615. static SKIP_MATERIALS: boolean;
  80616. /**
  80617. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  80618. *
  80619. * Defaults to true for backwards compatibility.
  80620. */
  80621. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  80622. /**
  80623. * Defines the name of the plugin.
  80624. */
  80625. name: string;
  80626. /**
  80627. * Defines the extension the plugin is able to load.
  80628. */
  80629. extensions: string;
  80630. /** @hidden */
  80631. obj: RegExp;
  80632. /** @hidden */
  80633. group: RegExp;
  80634. /** @hidden */
  80635. mtllib: RegExp;
  80636. /** @hidden */
  80637. usemtl: RegExp;
  80638. /** @hidden */
  80639. smooth: RegExp;
  80640. /** @hidden */
  80641. vertexPattern: RegExp;
  80642. /** @hidden */
  80643. normalPattern: RegExp;
  80644. /** @hidden */
  80645. uvPattern: RegExp;
  80646. /** @hidden */
  80647. facePattern1: RegExp;
  80648. /** @hidden */
  80649. facePattern2: RegExp;
  80650. /** @hidden */
  80651. facePattern3: RegExp;
  80652. /** @hidden */
  80653. facePattern4: RegExp;
  80654. /** @hidden */
  80655. facePattern5: RegExp;
  80656. private _forAssetContainer;
  80657. private _meshLoadOptions;
  80658. /**
  80659. * Creates loader for .OBJ files
  80660. *
  80661. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  80662. */
  80663. constructor(meshLoadOptions?: MeshLoadOptions);
  80664. private static get currentMeshLoadOptions();
  80665. /**
  80666. * Calls synchronously the MTL file attached to this obj.
  80667. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  80668. * Without this function materials are not displayed in the first frame (but displayed after).
  80669. * In consequence it is impossible to get material information in your HTML file
  80670. *
  80671. * @param url The URL of the MTL file
  80672. * @param rootUrl
  80673. * @param onSuccess Callback function to be called when the MTL file is loaded
  80674. * @private
  80675. */
  80676. private _loadMTL;
  80677. /**
  80678. * Instantiates a OBJ file loader plugin.
  80679. * @returns the created plugin
  80680. */
  80681. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  80682. /**
  80683. * If the data string can be loaded directly.
  80684. *
  80685. * @param data string containing the file data
  80686. * @returns if the data can be loaded directly
  80687. */
  80688. canDirectLoad(data: string): boolean;
  80689. /**
  80690. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  80691. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  80692. * @param scene the scene the meshes should be added to
  80693. * @param data the OBJ data to load
  80694. * @param rootUrl root url to load from
  80695. * @param onProgress event that fires when loading progress has occured
  80696. * @param fileName Defines the name of the file to load
  80697. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  80698. */
  80699. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  80700. meshes: AbstractMesh[];
  80701. particleSystems: IParticleSystem[];
  80702. skeletons: Skeleton[];
  80703. animationGroups: AnimationGroup[];
  80704. }>;
  80705. /**
  80706. * Imports all objects from the loaded OBJ data and adds them to the scene
  80707. * @param scene the scene the objects should be added to
  80708. * @param data the OBJ data to load
  80709. * @param rootUrl root url to load from
  80710. * @param onProgress event that fires when loading progress has occured
  80711. * @param fileName Defines the name of the file to load
  80712. * @returns a promise which completes when objects have been loaded to the scene
  80713. */
  80714. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  80715. /**
  80716. * Load into an asset container.
  80717. * @param scene The scene to load into
  80718. * @param data The data to import
  80719. * @param rootUrl The root url for scene and resources
  80720. * @param onProgress The callback when the load progresses
  80721. * @param fileName Defines the name of the file to load
  80722. * @returns The loaded asset container
  80723. */
  80724. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  80725. /**
  80726. * Read the OBJ file and create an Array of meshes.
  80727. * Each mesh contains all information given by the OBJ and the MTL file.
  80728. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  80729. *
  80730. * @param meshesNames
  80731. * @param scene Scene The scene where are displayed the data
  80732. * @param data String The content of the obj file
  80733. * @param rootUrl String The path to the folder
  80734. * @returns Array<AbstractMesh>
  80735. * @private
  80736. */
  80737. private _parseSolid;
  80738. }
  80739. }
  80740. declare module BABYLON {
  80741. /**
  80742. * STL file type loader.
  80743. * This is a babylon scene loader plugin.
  80744. */
  80745. export class STLFileLoader implements ISceneLoaderPlugin {
  80746. /** @hidden */
  80747. solidPattern: RegExp;
  80748. /** @hidden */
  80749. facetsPattern: RegExp;
  80750. /** @hidden */
  80751. normalPattern: RegExp;
  80752. /** @hidden */
  80753. vertexPattern: RegExp;
  80754. /**
  80755. * Defines the name of the plugin.
  80756. */
  80757. name: string;
  80758. /**
  80759. * Defines the extensions the stl loader is able to load.
  80760. * force data to come in as an ArrayBuffer
  80761. * we'll convert to string if it looks like it's an ASCII .stl
  80762. */
  80763. extensions: ISceneLoaderPluginExtensions;
  80764. /**
  80765. * Import meshes into a scene.
  80766. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  80767. * @param scene The scene to import into
  80768. * @param data The data to import
  80769. * @param rootUrl The root url for scene and resources
  80770. * @param meshes The meshes array to import into
  80771. * @param particleSystems The particle systems array to import into
  80772. * @param skeletons The skeletons array to import into
  80773. * @param onError The callback when import fails
  80774. * @returns True if successful or false otherwise
  80775. */
  80776. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  80777. /**
  80778. * Load into a scene.
  80779. * @param scene The scene to load into
  80780. * @param data The data to import
  80781. * @param rootUrl The root url for scene and resources
  80782. * @param onError The callback when import fails
  80783. * @returns true if successful or false otherwise
  80784. */
  80785. load(scene: Scene, data: any, rootUrl: string): boolean;
  80786. /**
  80787. * Load into an asset container.
  80788. * @param scene The scene to load into
  80789. * @param data The data to import
  80790. * @param rootUrl The root url for scene and resources
  80791. * @param onError The callback when import fails
  80792. * @returns The loaded asset container
  80793. */
  80794. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  80795. private _isBinary;
  80796. private _parseBinary;
  80797. private _parseASCII;
  80798. }
  80799. }
  80800. declare module BABYLON {
  80801. /**
  80802. * Class for generating OBJ data from a Babylon scene.
  80803. */
  80804. export class OBJExport {
  80805. /**
  80806. * Exports the geometry of a Mesh array in .OBJ file format (text)
  80807. * @param mesh defines the list of meshes to serialize
  80808. * @param materials defines if materials should be exported
  80809. * @param matlibname defines the name of the associated mtl file
  80810. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  80811. * @returns the OBJ content
  80812. */
  80813. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  80814. /**
  80815. * Exports the material(s) of a mesh in .MTL file format (text)
  80816. * @param mesh defines the mesh to extract the material from
  80817. * @returns the mtl content
  80818. */
  80819. static MTL(mesh: Mesh): string;
  80820. }
  80821. }
  80822. declare module BABYLON {
  80823. /** @hidden */
  80824. export var __IGLTFExporterExtension: number;
  80825. /**
  80826. * Interface for extending the exporter
  80827. * @hidden
  80828. */
  80829. export interface IGLTFExporterExtension {
  80830. /**
  80831. * The name of this extension
  80832. */
  80833. readonly name: string;
  80834. /**
  80835. * Defines whether this extension is enabled
  80836. */
  80837. enabled: boolean;
  80838. /**
  80839. * Defines whether this extension is required
  80840. */
  80841. required: boolean;
  80842. }
  80843. }
  80844. declare module BABYLON.GLTF2.Exporter {
  80845. /** @hidden */
  80846. export var __IGLTFExporterExtensionV2: number;
  80847. /**
  80848. * Interface for a glTF exporter extension
  80849. * @hidden
  80850. */
  80851. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  80852. /**
  80853. * Define this method to modify the default behavior before exporting a texture
  80854. * @param context The context when loading the asset
  80855. * @param babylonTexture The Babylon.js texture
  80856. * @param mimeType The mime-type of the generated image
  80857. * @returns A promise that resolves with the exported texture
  80858. */
  80859. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  80860. /**
  80861. * Define this method to get notified when a texture info is created
  80862. * @param context The context when loading the asset
  80863. * @param textureInfo The glTF texture info
  80864. * @param babylonTexture The Babylon.js texture
  80865. */
  80866. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  80867. /**
  80868. * Define this method to modify the default behavior when exporting texture info
  80869. * @param context The context when loading the asset
  80870. * @param meshPrimitive glTF mesh primitive
  80871. * @param babylonSubMesh Babylon submesh
  80872. * @param binaryWriter glTF serializer binary writer instance
  80873. * @returns nullable IMeshPrimitive promise
  80874. */
  80875. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  80876. /**
  80877. * Define this method to modify the default behavior when exporting a node
  80878. * @param context The context when exporting the node
  80879. * @param node glTF node
  80880. * @param babylonNode BabylonJS node
  80881. * @returns nullable INode promise
  80882. */
  80883. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  80884. [key: number]: number;
  80885. }): Promise<Nullable<INode>>;
  80886. /**
  80887. * Define this method to modify the default behavior when exporting a material
  80888. * @param material glTF material
  80889. * @param babylonMaterial BabylonJS material
  80890. * @returns nullable IMaterial promise
  80891. */
  80892. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  80893. /**
  80894. * Define this method to return additional textures to export from a material
  80895. * @param material glTF material
  80896. * @param babylonMaterial BabylonJS material
  80897. * @returns List of textures
  80898. */
  80899. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  80900. /** Gets a boolean indicating that this extension was used */
  80901. wasUsed: boolean;
  80902. /** Gets a boolean indicating that this extension is required for the file to work */
  80903. required: boolean;
  80904. /**
  80905. * Called after the exporter state changes to EXPORTING
  80906. */
  80907. onExporting?(): void;
  80908. }
  80909. }
  80910. declare module BABYLON.GLTF2.Exporter {
  80911. /**
  80912. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  80913. * @hidden
  80914. */
  80915. export class _GLTFMaterialExporter {
  80916. /**
  80917. * Represents the dielectric specular values for R, G and B
  80918. */
  80919. private static readonly _DielectricSpecular;
  80920. /**
  80921. * Allows the maximum specular power to be defined for material calculations
  80922. */
  80923. private static readonly _MaxSpecularPower;
  80924. /**
  80925. * Mapping to store textures
  80926. */
  80927. private _textureMap;
  80928. /**
  80929. * Numeric tolerance value
  80930. */
  80931. private static readonly _Epsilon;
  80932. /**
  80933. * Reference to the glTF Exporter
  80934. */
  80935. private _exporter;
  80936. constructor(exporter: _Exporter);
  80937. /**
  80938. * Specifies if two colors are approximately equal in value
  80939. * @param color1 first color to compare to
  80940. * @param color2 second color to compare to
  80941. * @param epsilon threshold value
  80942. */
  80943. private static FuzzyEquals;
  80944. /**
  80945. * Gets the materials from a Babylon scene and converts them to glTF materials
  80946. * @param scene babylonjs scene
  80947. * @param mimeType texture mime type
  80948. * @param images array of images
  80949. * @param textures array of textures
  80950. * @param materials array of materials
  80951. * @param imageData mapping of texture names to base64 textures
  80952. * @param hasTextureCoords specifies if texture coordinates are present on the material
  80953. */
  80954. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  80955. /**
  80956. * Makes a copy of the glTF material without the texture parameters
  80957. * @param originalMaterial original glTF material
  80958. * @returns glTF material without texture parameters
  80959. */
  80960. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  80961. /**
  80962. * Specifies if the material has any texture parameters present
  80963. * @param material glTF Material
  80964. * @returns boolean specifying if texture parameters are present
  80965. */
  80966. _hasTexturesPresent(material: IMaterial): boolean;
  80967. /**
  80968. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  80969. * @param babylonStandardMaterial
  80970. * @returns glTF Metallic Roughness Material representation
  80971. */
  80972. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  80973. /**
  80974. * Computes the metallic factor
  80975. * @param diffuse diffused value
  80976. * @param specular specular value
  80977. * @param oneMinusSpecularStrength one minus the specular strength
  80978. * @returns metallic value
  80979. */
  80980. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  80981. /**
  80982. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  80983. * @param glTFMaterial glTF material
  80984. * @param babylonMaterial Babylon material
  80985. */
  80986. private static _SetAlphaMode;
  80987. /**
  80988. * Converts a Babylon Standard Material to a glTF Material
  80989. * @param babylonStandardMaterial BJS Standard Material
  80990. * @param mimeType mime type to use for the textures
  80991. * @param images array of glTF image interfaces
  80992. * @param textures array of glTF texture interfaces
  80993. * @param materials array of glTF material interfaces
  80994. * @param imageData map of image file name to data
  80995. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80996. */
  80997. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  80998. private _finishMaterial;
  80999. /**
  81000. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  81001. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  81002. * @param mimeType mime type to use for the textures
  81003. * @param images array of glTF image interfaces
  81004. * @param textures array of glTF texture interfaces
  81005. * @param materials array of glTF material interfaces
  81006. * @param imageData map of image file name to data
  81007. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81008. */
  81009. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  81010. /**
  81011. * Converts an image typed array buffer to a base64 image
  81012. * @param buffer typed array buffer
  81013. * @param width width of the image
  81014. * @param height height of the image
  81015. * @param mimeType mimetype of the image
  81016. * @returns base64 image string
  81017. */
  81018. private _createBase64FromCanvasAsync;
  81019. /**
  81020. * Generates a white texture based on the specified width and height
  81021. * @param width width of the texture in pixels
  81022. * @param height height of the texture in pixels
  81023. * @param scene babylonjs scene
  81024. * @returns white texture
  81025. */
  81026. private _createWhiteTexture;
  81027. /**
  81028. * 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
  81029. * @param texture1 first texture to resize
  81030. * @param texture2 second texture to resize
  81031. * @param scene babylonjs scene
  81032. * @returns resized textures or null
  81033. */
  81034. private _resizeTexturesToSameDimensions;
  81035. /**
  81036. * Converts an array of pixels to a Float32Array
  81037. * Throws an error if the pixel format is not supported
  81038. * @param pixels - array buffer containing pixel values
  81039. * @returns Float32 of pixels
  81040. */
  81041. private _convertPixelArrayToFloat32;
  81042. /**
  81043. * Convert Specular Glossiness Textures to Metallic Roughness
  81044. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  81045. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  81046. * @param diffuseTexture texture used to store diffuse information
  81047. * @param specularGlossinessTexture texture used to store specular and glossiness information
  81048. * @param factors specular glossiness material factors
  81049. * @param mimeType the mime type to use for the texture
  81050. * @returns pbr metallic roughness interface or null
  81051. */
  81052. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  81053. /**
  81054. * Converts specular glossiness material properties to metallic roughness
  81055. * @param specularGlossiness interface with specular glossiness material properties
  81056. * @returns interface with metallic roughness material properties
  81057. */
  81058. private _convertSpecularGlossinessToMetallicRoughness;
  81059. /**
  81060. * Calculates the surface reflectance, independent of lighting conditions
  81061. * @param color Color source to calculate brightness from
  81062. * @returns number representing the perceived brightness, or zero if color is undefined
  81063. */
  81064. private _getPerceivedBrightness;
  81065. /**
  81066. * Returns the maximum color component value
  81067. * @param color
  81068. * @returns maximum color component value, or zero if color is null or undefined
  81069. */
  81070. private _getMaxComponent;
  81071. /**
  81072. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  81073. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81074. * @param mimeType mime type to use for the textures
  81075. * @param images array of glTF image interfaces
  81076. * @param textures array of glTF texture interfaces
  81077. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  81078. * @param imageData map of image file name to data
  81079. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81080. * @returns glTF PBR Metallic Roughness factors
  81081. */
  81082. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  81083. private _getGLTFTextureSampler;
  81084. private _getGLTFTextureWrapMode;
  81085. private _getGLTFTextureWrapModesSampler;
  81086. /**
  81087. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  81088. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81089. * @param mimeType mime type to use for the textures
  81090. * @param images array of glTF image interfaces
  81091. * @param textures array of glTF texture interfaces
  81092. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  81093. * @param imageData map of image file name to data
  81094. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81095. * @returns glTF PBR Metallic Roughness factors
  81096. */
  81097. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  81098. /**
  81099. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  81100. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81101. * @param mimeType mime type to use for the textures
  81102. * @param images array of glTF image interfaces
  81103. * @param textures array of glTF texture interfaces
  81104. * @param materials array of glTF material interfaces
  81105. * @param imageData map of image file name to data
  81106. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81107. */
  81108. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  81109. private setMetallicRoughnessPbrMaterial;
  81110. private getPixelsFromTexture;
  81111. /**
  81112. * Extracts a texture from a Babylon texture into file data and glTF data
  81113. * @param babylonTexture Babylon texture to extract
  81114. * @param mimeType Mime Type of the babylonTexture
  81115. * @return glTF texture info, or null if the texture format is not supported
  81116. */
  81117. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  81118. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  81119. /**
  81120. * Builds a texture from base64 string
  81121. * @param base64Texture base64 texture string
  81122. * @param baseTextureName Name to use for the texture
  81123. * @param mimeType image mime type for the texture
  81124. * @param images array of images
  81125. * @param textures array of textures
  81126. * @param imageData map of image data
  81127. * @returns glTF texture info, or null if the texture format is not supported
  81128. */
  81129. private _getTextureInfoFromBase64;
  81130. }
  81131. }
  81132. declare module BABYLON {
  81133. /**
  81134. * Class for holding and downloading glTF file data
  81135. */
  81136. export class GLTFData {
  81137. /**
  81138. * Object which contains the file name as the key and its data as the value
  81139. */
  81140. glTFFiles: {
  81141. [fileName: string]: string | Blob;
  81142. };
  81143. /**
  81144. * Initializes the glTF file object
  81145. */
  81146. constructor();
  81147. /**
  81148. * Downloads the glTF data as files based on their names and data
  81149. */
  81150. downloadFiles(): void;
  81151. }
  81152. }
  81153. declare module BABYLON {
  81154. /**
  81155. * Holds a collection of exporter options and parameters
  81156. */
  81157. export interface IExportOptions {
  81158. /**
  81159. * Function which indicates whether a babylon node should be exported or not
  81160. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  81161. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  81162. */
  81163. shouldExportNode?(node: Node): boolean;
  81164. /**
  81165. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  81166. * @param metadata source metadata to read from
  81167. * @returns the data to store to glTF node extras
  81168. */
  81169. metadataSelector?(metadata: any): any;
  81170. /**
  81171. * The sample rate to bake animation curves
  81172. */
  81173. animationSampleRate?: number;
  81174. /**
  81175. * Begin serialization without waiting for the scene to be ready
  81176. */
  81177. exportWithoutWaitingForScene?: boolean;
  81178. /**
  81179. * Indicates if coordinate system swapping root nodes should be included in export
  81180. */
  81181. includeCoordinateSystemConversionNodes?: boolean;
  81182. }
  81183. /**
  81184. * Class for generating glTF data from a Babylon scene.
  81185. */
  81186. export class GLTF2Export {
  81187. /**
  81188. * Exports the geometry of the scene to .gltf file format asynchronously
  81189. * @param scene Babylon scene with scene hierarchy information
  81190. * @param filePrefix File prefix to use when generating the glTF file
  81191. * @param options Exporter options
  81192. * @returns Returns an object with a .gltf file and associates texture names
  81193. * as keys and their data and paths as values
  81194. */
  81195. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  81196. private static _PreExportAsync;
  81197. private static _PostExportAsync;
  81198. /**
  81199. * Exports the geometry of the scene to .glb file format asychronously
  81200. * @param scene Babylon scene with scene hierarchy information
  81201. * @param filePrefix File prefix to use when generating glb file
  81202. * @param options Exporter options
  81203. * @returns Returns an object with a .glb filename as key and data as value
  81204. */
  81205. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  81206. }
  81207. }
  81208. declare module BABYLON.GLTF2.Exporter {
  81209. /**
  81210. * @hidden
  81211. */
  81212. export class _GLTFUtilities {
  81213. /**
  81214. * Creates a buffer view based on the supplied arguments
  81215. * @param bufferIndex index value of the specified buffer
  81216. * @param byteOffset byte offset value
  81217. * @param byteLength byte length of the bufferView
  81218. * @param byteStride byte distance between conequential elements
  81219. * @param name name of the buffer view
  81220. * @returns bufferView for glTF
  81221. */
  81222. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  81223. /**
  81224. * Creates an accessor based on the supplied arguments
  81225. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  81226. * @param name The name of the accessor
  81227. * @param type The type of the accessor
  81228. * @param componentType The datatype of components in the attribute
  81229. * @param count The number of attributes referenced by this accessor
  81230. * @param byteOffset The offset relative to the start of the bufferView in bytes
  81231. * @param min Minimum value of each component in this attribute
  81232. * @param max Maximum value of each component in this attribute
  81233. * @returns accessor for glTF
  81234. */
  81235. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  81236. /**
  81237. * Calculates the minimum and maximum values of an array of position floats
  81238. * @param positions Positions array of a mesh
  81239. * @param vertexStart Starting vertex offset to calculate min and max values
  81240. * @param vertexCount Number of vertices to check for min and max values
  81241. * @returns min number array and max number array
  81242. */
  81243. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  81244. min: number[];
  81245. max: number[];
  81246. };
  81247. /**
  81248. * Converts a new right-handed Vector3
  81249. * @param vector vector3 array
  81250. * @returns right-handed Vector3
  81251. */
  81252. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  81253. /**
  81254. * Converts a Vector3 to right-handed
  81255. * @param vector Vector3 to convert to right-handed
  81256. */
  81257. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  81258. /**
  81259. * Converts a three element number array to right-handed
  81260. * @param vector number array to convert to right-handed
  81261. */
  81262. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  81263. /**
  81264. * Converts a new right-handed Vector3
  81265. * @param vector vector3 array
  81266. * @returns right-handed Vector3
  81267. */
  81268. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  81269. /**
  81270. * Converts a Vector3 to right-handed
  81271. * @param vector Vector3 to convert to right-handed
  81272. */
  81273. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  81274. /**
  81275. * Converts a three element number array to right-handed
  81276. * @param vector number array to convert to right-handed
  81277. */
  81278. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  81279. /**
  81280. * Converts a Vector4 to right-handed
  81281. * @param vector Vector4 to convert to right-handed
  81282. */
  81283. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  81284. /**
  81285. * Converts a Vector4 to right-handed
  81286. * @param vector Vector4 to convert to right-handed
  81287. */
  81288. static _GetRightHandedArray4FromRef(vector: number[]): void;
  81289. /**
  81290. * Converts a Quaternion to right-handed
  81291. * @param quaternion Source quaternion to convert to right-handed
  81292. */
  81293. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  81294. /**
  81295. * Converts a Quaternion to right-handed
  81296. * @param quaternion Source quaternion to convert to right-handed
  81297. */
  81298. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  81299. static _NormalizeTangentFromRef(tangent: Vector4): void;
  81300. }
  81301. }
  81302. declare module BABYLON.GLTF2.Exporter {
  81303. /**
  81304. * Converts Babylon Scene into glTF 2.0.
  81305. * @hidden
  81306. */
  81307. export class _Exporter {
  81308. /**
  81309. * Stores the glTF to export
  81310. */
  81311. _glTF: IGLTF;
  81312. /**
  81313. * Stores all generated buffer views, which represents views into the main glTF buffer data
  81314. */
  81315. _bufferViews: IBufferView[];
  81316. /**
  81317. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  81318. */
  81319. _accessors: IAccessor[];
  81320. /**
  81321. * Stores all the generated nodes, which contains transform and/or mesh information per node
  81322. */
  81323. _nodes: INode[];
  81324. /**
  81325. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  81326. */
  81327. private _scenes;
  81328. /**
  81329. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  81330. */
  81331. private _meshes;
  81332. /**
  81333. * Stores all the generated material information, which represents the appearance of each primitive
  81334. */
  81335. _materials: IMaterial[];
  81336. _materialMap: {
  81337. [materialID: number]: number;
  81338. };
  81339. /**
  81340. * Stores all the generated texture information, which is referenced by glTF materials
  81341. */
  81342. _textures: ITexture[];
  81343. /**
  81344. * Stores all the generated image information, which is referenced by glTF textures
  81345. */
  81346. _images: IImage[];
  81347. /**
  81348. * Stores all the texture samplers
  81349. */
  81350. _samplers: ISampler[];
  81351. /**
  81352. * Stores all the generated animation samplers, which is referenced by glTF animations
  81353. */
  81354. /**
  81355. * Stores the animations for glTF models
  81356. */
  81357. private _animations;
  81358. /**
  81359. * Stores the total amount of bytes stored in the glTF buffer
  81360. */
  81361. private _totalByteLength;
  81362. /**
  81363. * Stores a reference to the Babylon scene containing the source geometry and material information
  81364. */
  81365. _babylonScene: Scene;
  81366. /**
  81367. * Stores a map of the image data, where the key is the file name and the value
  81368. * is the image data
  81369. */
  81370. _imageData: {
  81371. [fileName: string]: {
  81372. data: Uint8Array;
  81373. mimeType: ImageMimeType;
  81374. };
  81375. };
  81376. /**
  81377. * Stores a map of the unique id of a node to its index in the node array
  81378. */
  81379. _nodeMap: {
  81380. [key: number]: number;
  81381. };
  81382. /**
  81383. * Specifies if the source Babylon scene was left handed, and needed conversion.
  81384. */
  81385. _convertToRightHandedSystem: boolean;
  81386. /**
  81387. * Specifies if a Babylon node should be converted to right-handed on export
  81388. */
  81389. _convertToRightHandedSystemMap: {
  81390. [nodeId: number]: boolean;
  81391. };
  81392. _includeCoordinateSystemConversionNodes: boolean;
  81393. /**
  81394. * Baked animation sample rate
  81395. */
  81396. private _animationSampleRate;
  81397. private _options;
  81398. private _localEngine;
  81399. _glTFMaterialExporter: _GLTFMaterialExporter;
  81400. private _extensions;
  81401. private static _ExtensionNames;
  81402. private static _ExtensionFactories;
  81403. private _applyExtension;
  81404. private _applyExtensions;
  81405. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  81406. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  81407. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  81408. [key: number]: number;
  81409. }): Promise<Nullable<INode>>;
  81410. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  81411. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  81412. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  81413. private _forEachExtensions;
  81414. private _extensionsOnExporting;
  81415. /**
  81416. * Load glTF serializer extensions
  81417. */
  81418. private _loadExtensions;
  81419. /**
  81420. * Creates a glTF Exporter instance, which can accept optional exporter options
  81421. * @param babylonScene Babylon scene object
  81422. * @param options Options to modify the behavior of the exporter
  81423. */
  81424. constructor(babylonScene: Scene, options?: IExportOptions);
  81425. dispose(): void;
  81426. /**
  81427. * Registers a glTF exporter extension
  81428. * @param name Name of the extension to export
  81429. * @param factory The factory function that creates the exporter extension
  81430. */
  81431. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  81432. /**
  81433. * Un-registers an exporter extension
  81434. * @param name The name fo the exporter extension
  81435. * @returns A boolean indicating whether the extension has been un-registered
  81436. */
  81437. static UnregisterExtension(name: string): boolean;
  81438. /**
  81439. * Lazy load a local engine
  81440. */
  81441. _getLocalEngine(): Engine;
  81442. private reorderIndicesBasedOnPrimitiveMode;
  81443. /**
  81444. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  81445. * clock-wise during export to glTF
  81446. * @param submesh BabylonJS submesh
  81447. * @param primitiveMode Primitive mode of the mesh
  81448. * @param sideOrientation the winding order of the submesh
  81449. * @param vertexBufferKind The type of vertex attribute
  81450. * @param meshAttributeArray The vertex attribute data
  81451. * @param byteOffset The offset to the binary data
  81452. * @param binaryWriter The binary data for the glTF file
  81453. * @param convertToRightHandedSystem Converts the values to right-handed
  81454. */
  81455. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  81456. /**
  81457. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  81458. * clock-wise during export to glTF
  81459. * @param submesh BabylonJS submesh
  81460. * @param primitiveMode Primitive mode of the mesh
  81461. * @param sideOrientation the winding order of the submesh
  81462. * @param vertexBufferKind The type of vertex attribute
  81463. * @param meshAttributeArray The vertex attribute data
  81464. * @param byteOffset The offset to the binary data
  81465. * @param binaryWriter The binary data for the glTF file
  81466. * @param convertToRightHandedSystem Converts the values to right-handed
  81467. */
  81468. private reorderTriangleFillMode;
  81469. /**
  81470. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  81471. * clock-wise during export to glTF
  81472. * @param submesh BabylonJS submesh
  81473. * @param primitiveMode Primitive mode of the mesh
  81474. * @param sideOrientation the winding order of the submesh
  81475. * @param vertexBufferKind The type of vertex attribute
  81476. * @param meshAttributeArray The vertex attribute data
  81477. * @param byteOffset The offset to the binary data
  81478. * @param binaryWriter The binary data for the glTF file
  81479. * @param convertToRightHandedSystem Converts the values to right-handed
  81480. */
  81481. private reorderTriangleStripDrawMode;
  81482. /**
  81483. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  81484. * clock-wise during export to glTF
  81485. * @param submesh BabylonJS submesh
  81486. * @param primitiveMode Primitive mode of the mesh
  81487. * @param sideOrientation the winding order of the submesh
  81488. * @param vertexBufferKind The type of vertex attribute
  81489. * @param meshAttributeArray The vertex attribute data
  81490. * @param byteOffset The offset to the binary data
  81491. * @param binaryWriter The binary data for the glTF file
  81492. * @param convertToRightHandedSystem Converts the values to right-handed
  81493. */
  81494. private reorderTriangleFanMode;
  81495. /**
  81496. * Writes the vertex attribute data to binary
  81497. * @param vertices The vertices to write to the binary writer
  81498. * @param byteOffset The offset into the binary writer to overwrite binary data
  81499. * @param vertexAttributeKind The vertex attribute type
  81500. * @param meshAttributeArray The vertex attribute data
  81501. * @param binaryWriter The writer containing the binary data
  81502. * @param convertToRightHandedSystem Converts the values to right-handed
  81503. */
  81504. private writeVertexAttributeData;
  81505. /**
  81506. * Writes mesh attribute data to a data buffer
  81507. * Returns the bytelength of the data
  81508. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  81509. * @param meshAttributeArray Array containing the attribute data
  81510. * @param binaryWriter The buffer to write the binary data to
  81511. * @param indices Used to specify the order of the vertex data
  81512. * @param convertToRightHandedSystem Converts the values to right-handed
  81513. */
  81514. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  81515. /**
  81516. * Generates glTF json data
  81517. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  81518. * @param glTFPrefix Text to use when prefixing a glTF file
  81519. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  81520. * @returns json data as string
  81521. */
  81522. private generateJSON;
  81523. /**
  81524. * Generates data for .gltf and .bin files based on the glTF prefix string
  81525. * @param glTFPrefix Text to use when prefixing a glTF file
  81526. * @param dispose Dispose the exporter
  81527. * @returns GLTFData with glTF file data
  81528. */
  81529. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  81530. /**
  81531. * Creates a binary buffer for glTF
  81532. * @returns array buffer for binary data
  81533. */
  81534. private _generateBinaryAsync;
  81535. /**
  81536. * Pads the number to a multiple of 4
  81537. * @param num number to pad
  81538. * @returns padded number
  81539. */
  81540. private _getPadding;
  81541. /**
  81542. * @hidden
  81543. */
  81544. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  81545. /**
  81546. * Sets the TRS for each node
  81547. * @param node glTF Node for storing the transformation data
  81548. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  81549. * @param convertToRightHandedSystem Converts the values to right-handed
  81550. */
  81551. private setNodeTransformation;
  81552. private getVertexBufferFromMesh;
  81553. /**
  81554. * Creates a bufferview based on the vertices type for the Babylon mesh
  81555. * @param kind Indicates the type of vertices data
  81556. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  81557. * @param binaryWriter The buffer to write the bufferview data to
  81558. * @param convertToRightHandedSystem Converts the values to right-handed
  81559. */
  81560. private createBufferViewKind;
  81561. /**
  81562. * The primitive mode of the Babylon mesh
  81563. * @param babylonMesh The BabylonJS mesh
  81564. */
  81565. private getMeshPrimitiveMode;
  81566. /**
  81567. * Sets the primitive mode of the glTF mesh primitive
  81568. * @param meshPrimitive glTF mesh primitive
  81569. * @param primitiveMode The primitive mode
  81570. */
  81571. private setPrimitiveMode;
  81572. /**
  81573. * Sets the vertex attribute accessor based of the glTF mesh primitive
  81574. * @param meshPrimitive glTF mesh primitive
  81575. * @param attributeKind vertex attribute
  81576. * @returns boolean specifying if uv coordinates are present
  81577. */
  81578. private setAttributeKind;
  81579. /**
  81580. * Sets data for the primitive attributes of each submesh
  81581. * @param mesh glTF Mesh object to store the primitive attribute information
  81582. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  81583. * @param binaryWriter Buffer to write the attribute data to
  81584. * @param convertToRightHandedSystem Converts the values to right-handed
  81585. */
  81586. private setPrimitiveAttributesAsync;
  81587. /**
  81588. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  81589. * @param node The node to check
  81590. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  81591. */
  81592. private isBabylonCoordinateSystemConvertingNode;
  81593. /**
  81594. * Creates a glTF scene based on the array of meshes
  81595. * Returns the the total byte offset
  81596. * @param babylonScene Babylon scene to get the mesh data from
  81597. * @param binaryWriter Buffer to write binary data to
  81598. */
  81599. private createSceneAsync;
  81600. /**
  81601. * Creates a mapping of Node unique id to node index and handles animations
  81602. * @param babylonScene Babylon Scene
  81603. * @param nodes Babylon transform nodes
  81604. * @param binaryWriter Buffer to write binary data to
  81605. * @returns Node mapping of unique id to index
  81606. */
  81607. private createNodeMapAndAnimationsAsync;
  81608. /**
  81609. * Creates a glTF node from a Babylon mesh
  81610. * @param babylonMesh Source Babylon mesh
  81611. * @param binaryWriter Buffer for storing geometry data
  81612. * @param convertToRightHandedSystem Converts the values to right-handed
  81613. * @param nodeMap Node mapping of unique id to glTF node index
  81614. * @returns glTF node
  81615. */
  81616. private createNodeAsync;
  81617. }
  81618. /**
  81619. * @hidden
  81620. *
  81621. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  81622. */
  81623. export class _BinaryWriter {
  81624. /**
  81625. * Array buffer which stores all binary data
  81626. */
  81627. private _arrayBuffer;
  81628. /**
  81629. * View of the array buffer
  81630. */
  81631. private _dataView;
  81632. /**
  81633. * byte offset of data in array buffer
  81634. */
  81635. private _byteOffset;
  81636. /**
  81637. * Initialize binary writer with an initial byte length
  81638. * @param byteLength Initial byte length of the array buffer
  81639. */
  81640. constructor(byteLength: number);
  81641. /**
  81642. * Resize the array buffer to the specified byte length
  81643. * @param byteLength
  81644. */
  81645. private resizeBuffer;
  81646. /**
  81647. * Get an array buffer with the length of the byte offset
  81648. * @returns ArrayBuffer resized to the byte offset
  81649. */
  81650. getArrayBuffer(): ArrayBuffer;
  81651. /**
  81652. * Get the byte offset of the array buffer
  81653. * @returns byte offset
  81654. */
  81655. getByteOffset(): number;
  81656. /**
  81657. * Stores an UInt8 in the array buffer
  81658. * @param entry
  81659. * @param byteOffset If defined, specifies where to set the value as an offset.
  81660. */
  81661. setUInt8(entry: number, byteOffset?: number): void;
  81662. /**
  81663. * Gets an UInt32 in the array buffer
  81664. * @param entry
  81665. * @param byteOffset If defined, specifies where to set the value as an offset.
  81666. */
  81667. getUInt32(byteOffset: number): number;
  81668. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  81669. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  81670. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  81671. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  81672. /**
  81673. * Stores a Float32 in the array buffer
  81674. * @param entry
  81675. */
  81676. setFloat32(entry: number, byteOffset?: number): void;
  81677. /**
  81678. * Stores an UInt32 in the array buffer
  81679. * @param entry
  81680. * @param byteOffset If defined, specifies where to set the value as an offset.
  81681. */
  81682. setUInt32(entry: number, byteOffset?: number): void;
  81683. }
  81684. }
  81685. declare module BABYLON.GLTF2.Exporter {
  81686. /**
  81687. * @hidden
  81688. * Interface to store animation data.
  81689. */
  81690. export interface _IAnimationData {
  81691. /**
  81692. * Keyframe data.
  81693. */
  81694. inputs: number[];
  81695. /**
  81696. * Value data.
  81697. */
  81698. outputs: number[][];
  81699. /**
  81700. * Animation interpolation data.
  81701. */
  81702. samplerInterpolation: AnimationSamplerInterpolation;
  81703. /**
  81704. * Minimum keyframe value.
  81705. */
  81706. inputsMin: number;
  81707. /**
  81708. * Maximum keyframe value.
  81709. */
  81710. inputsMax: number;
  81711. }
  81712. /**
  81713. * @hidden
  81714. */
  81715. export interface _IAnimationInfo {
  81716. /**
  81717. * The target channel for the animation
  81718. */
  81719. animationChannelTargetPath: AnimationChannelTargetPath;
  81720. /**
  81721. * The glTF accessor type for the data.
  81722. */
  81723. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  81724. /**
  81725. * Specifies if quaternions should be used.
  81726. */
  81727. useQuaternion: boolean;
  81728. }
  81729. /**
  81730. * @hidden
  81731. * Utility class for generating glTF animation data from BabylonJS.
  81732. */
  81733. export class _GLTFAnimation {
  81734. /**
  81735. * @ignore
  81736. *
  81737. * Creates glTF channel animation from BabylonJS animation.
  81738. * @param babylonTransformNode - BabylonJS mesh.
  81739. * @param animation - animation.
  81740. * @param animationChannelTargetPath - The target animation channel.
  81741. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  81742. * @param useQuaternion - Specifies if quaternions are used.
  81743. * @returns nullable IAnimationData
  81744. */
  81745. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  81746. private static _DeduceAnimationInfo;
  81747. /**
  81748. * @ignore
  81749. * Create node animations from the transform node animations
  81750. * @param babylonNode
  81751. * @param runtimeGLTFAnimation
  81752. * @param idleGLTFAnimations
  81753. * @param nodeMap
  81754. * @param nodes
  81755. * @param binaryWriter
  81756. * @param bufferViews
  81757. * @param accessors
  81758. * @param convertToRightHandedSystem
  81759. * @param animationSampleRate
  81760. */
  81761. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  81762. [key: number]: number;
  81763. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  81764. /**
  81765. * @ignore
  81766. * Create node animations from the animation groups
  81767. * @param babylonScene
  81768. * @param glTFAnimations
  81769. * @param nodeMap
  81770. * @param nodes
  81771. * @param binaryWriter
  81772. * @param bufferViews
  81773. * @param accessors
  81774. * @param convertToRightHandedSystemMap
  81775. * @param animationSampleRate
  81776. */
  81777. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  81778. [key: number]: number;
  81779. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  81780. [nodeId: number]: boolean;
  81781. }, animationSampleRate: number): void;
  81782. private static AddAnimation;
  81783. /**
  81784. * Create a baked animation
  81785. * @param babylonTransformNode BabylonJS mesh
  81786. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  81787. * @param animationChannelTargetPath animation target channel
  81788. * @param minFrame minimum animation frame
  81789. * @param maxFrame maximum animation frame
  81790. * @param fps frames per second of the animation
  81791. * @param inputs input key frames of the animation
  81792. * @param outputs output key frame data of the animation
  81793. * @param convertToRightHandedSystem converts the values to right-handed
  81794. * @param useQuaternion specifies if quaternions should be used
  81795. */
  81796. private static _CreateBakedAnimation;
  81797. private static _ConvertFactorToVector3OrQuaternion;
  81798. private static _SetInterpolatedValue;
  81799. /**
  81800. * Creates linear animation from the animation key frames
  81801. * @param babylonTransformNode BabylonJS mesh
  81802. * @param animation BabylonJS animation
  81803. * @param animationChannelTargetPath The target animation channel
  81804. * @param frameDelta The difference between the last and first frame of the animation
  81805. * @param inputs Array to store the key frame times
  81806. * @param outputs Array to store the key frame data
  81807. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  81808. * @param useQuaternion Specifies if quaternions are used in the animation
  81809. */
  81810. private static _CreateLinearOrStepAnimation;
  81811. /**
  81812. * Creates cubic spline animation from the animation key frames
  81813. * @param babylonTransformNode BabylonJS mesh
  81814. * @param animation BabylonJS animation
  81815. * @param animationChannelTargetPath The target animation channel
  81816. * @param frameDelta The difference between the last and first frame of the animation
  81817. * @param inputs Array to store the key frame times
  81818. * @param outputs Array to store the key frame data
  81819. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  81820. * @param useQuaternion Specifies if quaternions are used in the animation
  81821. */
  81822. private static _CreateCubicSplineAnimation;
  81823. private static _GetBasePositionRotationOrScale;
  81824. /**
  81825. * Adds a key frame value
  81826. * @param keyFrame
  81827. * @param animation
  81828. * @param outputs
  81829. * @param animationChannelTargetPath
  81830. * @param basePositionRotationOrScale
  81831. * @param convertToRightHandedSystem
  81832. * @param useQuaternion
  81833. */
  81834. private static _AddKeyframeValue;
  81835. /**
  81836. * Determine the interpolation based on the key frames
  81837. * @param keyFrames
  81838. * @param animationChannelTargetPath
  81839. * @param useQuaternion
  81840. */
  81841. private static _DeduceInterpolation;
  81842. /**
  81843. * Adds an input tangent or output tangent to the output data
  81844. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  81845. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  81846. * @param outputs The animation data by keyframe
  81847. * @param animationChannelTargetPath The target animation channel
  81848. * @param interpolation The interpolation type
  81849. * @param keyFrame The key frame with the animation data
  81850. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  81851. * @param useQuaternion Specifies if quaternions are used
  81852. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  81853. */
  81854. private static AddSplineTangent;
  81855. /**
  81856. * Get the minimum and maximum key frames' frame values
  81857. * @param keyFrames animation key frames
  81858. * @returns the minimum and maximum key frame value
  81859. */
  81860. private static calculateMinMaxKeyFrames;
  81861. }
  81862. }
  81863. declare module BABYLON.GLTF2.Exporter {
  81864. /** @hidden */
  81865. export var textureTransformPixelShader: {
  81866. name: string;
  81867. shader: string;
  81868. };
  81869. }
  81870. declare module BABYLON.GLTF2.Exporter.Extensions {
  81871. /**
  81872. * @hidden
  81873. */
  81874. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  81875. private _recordedTextures;
  81876. /** Name of this extension */
  81877. readonly name: string;
  81878. /** Defines whether this extension is enabled */
  81879. enabled: boolean;
  81880. /** Defines whether this extension is required */
  81881. required: boolean;
  81882. /** Reference to the glTF exporter */
  81883. private _wasUsed;
  81884. constructor(exporter: _Exporter);
  81885. dispose(): void;
  81886. /** @hidden */
  81887. get wasUsed(): boolean;
  81888. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  81889. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  81890. /**
  81891. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  81892. * @param babylonTexture
  81893. * @param offset
  81894. * @param rotation
  81895. * @param scale
  81896. * @param scene
  81897. */
  81898. private _textureTransformTextureAsync;
  81899. }
  81900. }
  81901. declare module BABYLON.GLTF2.Exporter.Extensions {
  81902. /**
  81903. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  81904. */
  81905. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  81906. /** The name of this extension. */
  81907. readonly name: string;
  81908. /** Defines whether this extension is enabled. */
  81909. enabled: boolean;
  81910. /** Defines whether this extension is required */
  81911. required: boolean;
  81912. /** Reference to the glTF exporter */
  81913. private _exporter;
  81914. private _lights;
  81915. /** @hidden */
  81916. constructor(exporter: _Exporter);
  81917. /** @hidden */
  81918. dispose(): void;
  81919. /** @hidden */
  81920. get wasUsed(): boolean;
  81921. /** @hidden */
  81922. onExporting(): void;
  81923. /**
  81924. * Define this method to modify the default behavior when exporting a node
  81925. * @param context The context when exporting the node
  81926. * @param node glTF node
  81927. * @param babylonNode BabylonJS node
  81928. * @param nodeMap Node mapping of unique id to glTF node index
  81929. * @returns nullable INode promise
  81930. */
  81931. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  81932. [key: number]: number;
  81933. }): Promise<Nullable<INode>>;
  81934. }
  81935. }
  81936. declare module BABYLON.GLTF2.Exporter.Extensions {
  81937. /**
  81938. * @hidden
  81939. */
  81940. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  81941. /** Name of this extension */
  81942. readonly name: string;
  81943. /** Defines whether this extension is enabled */
  81944. enabled: boolean;
  81945. /** Defines whether this extension is required */
  81946. required: boolean;
  81947. /** Reference to the glTF exporter */
  81948. private _textureInfos;
  81949. private _exportedTextures;
  81950. private _wasUsed;
  81951. constructor(exporter: _Exporter);
  81952. dispose(): void;
  81953. /** @hidden */
  81954. get wasUsed(): boolean;
  81955. private _getTextureIndex;
  81956. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  81957. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  81958. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  81959. }
  81960. }
  81961. declare module BABYLON {
  81962. /**
  81963. * Class for generating STL data from a Babylon scene.
  81964. */
  81965. export class STLExport {
  81966. /**
  81967. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  81968. * @param meshes list defines the mesh to serialize
  81969. * @param download triggers the automatic download of the file.
  81970. * @param fileName changes the downloads fileName.
  81971. * @param binary changes the STL to a binary type.
  81972. * @param isLittleEndian toggle for binary type exporter.
  81973. * @returns the STL as UTF8 string
  81974. */
  81975. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  81976. }
  81977. }
  81978. declare module "babylonjs-gltf2interface" {
  81979. export = BABYLON.GLTF2;
  81980. }
  81981. /**
  81982. * Module for glTF 2.0 Interface
  81983. */
  81984. declare module BABYLON.GLTF2 {
  81985. /**
  81986. * The datatype of the components in the attribute
  81987. */
  81988. const enum AccessorComponentType {
  81989. /**
  81990. * Byte
  81991. */
  81992. BYTE = 5120,
  81993. /**
  81994. * Unsigned Byte
  81995. */
  81996. UNSIGNED_BYTE = 5121,
  81997. /**
  81998. * Short
  81999. */
  82000. SHORT = 5122,
  82001. /**
  82002. * Unsigned Short
  82003. */
  82004. UNSIGNED_SHORT = 5123,
  82005. /**
  82006. * Unsigned Int
  82007. */
  82008. UNSIGNED_INT = 5125,
  82009. /**
  82010. * Float
  82011. */
  82012. FLOAT = 5126,
  82013. }
  82014. /**
  82015. * Specifies if the attirbute is a scalar, vector, or matrix
  82016. */
  82017. const enum AccessorType {
  82018. /**
  82019. * Scalar
  82020. */
  82021. SCALAR = "SCALAR",
  82022. /**
  82023. * Vector2
  82024. */
  82025. VEC2 = "VEC2",
  82026. /**
  82027. * Vector3
  82028. */
  82029. VEC3 = "VEC3",
  82030. /**
  82031. * Vector4
  82032. */
  82033. VEC4 = "VEC4",
  82034. /**
  82035. * Matrix2x2
  82036. */
  82037. MAT2 = "MAT2",
  82038. /**
  82039. * Matrix3x3
  82040. */
  82041. MAT3 = "MAT3",
  82042. /**
  82043. * Matrix4x4
  82044. */
  82045. MAT4 = "MAT4",
  82046. }
  82047. /**
  82048. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  82049. */
  82050. const enum AnimationChannelTargetPath {
  82051. /**
  82052. * Translation
  82053. */
  82054. TRANSLATION = "translation",
  82055. /**
  82056. * Rotation
  82057. */
  82058. ROTATION = "rotation",
  82059. /**
  82060. * Scale
  82061. */
  82062. SCALE = "scale",
  82063. /**
  82064. * Weights
  82065. */
  82066. WEIGHTS = "weights",
  82067. }
  82068. /**
  82069. * Interpolation algorithm
  82070. */
  82071. const enum AnimationSamplerInterpolation {
  82072. /**
  82073. * The animated values are linearly interpolated between keyframes
  82074. */
  82075. LINEAR = "LINEAR",
  82076. /**
  82077. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  82078. */
  82079. STEP = "STEP",
  82080. /**
  82081. * The animation's interpolation is computed using a cubic spline with specified tangents
  82082. */
  82083. CUBICSPLINE = "CUBICSPLINE",
  82084. }
  82085. /**
  82086. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  82087. */
  82088. const enum CameraType {
  82089. /**
  82090. * A perspective camera containing properties to create a perspective projection matrix
  82091. */
  82092. PERSPECTIVE = "perspective",
  82093. /**
  82094. * An orthographic camera containing properties to create an orthographic projection matrix
  82095. */
  82096. ORTHOGRAPHIC = "orthographic",
  82097. }
  82098. /**
  82099. * The mime-type of the image
  82100. */
  82101. const enum ImageMimeType {
  82102. /**
  82103. * JPEG Mime-type
  82104. */
  82105. JPEG = "image/jpeg",
  82106. /**
  82107. * PNG Mime-type
  82108. */
  82109. PNG = "image/png",
  82110. }
  82111. /**
  82112. * The alpha rendering mode of the material
  82113. */
  82114. const enum MaterialAlphaMode {
  82115. /**
  82116. * The alpha value is ignored and the rendered output is fully opaque
  82117. */
  82118. OPAQUE = "OPAQUE",
  82119. /**
  82120. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  82121. */
  82122. MASK = "MASK",
  82123. /**
  82124. * 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)
  82125. */
  82126. BLEND = "BLEND",
  82127. }
  82128. /**
  82129. * The type of the primitives to render
  82130. */
  82131. const enum MeshPrimitiveMode {
  82132. /**
  82133. * Points
  82134. */
  82135. POINTS = 0,
  82136. /**
  82137. * Lines
  82138. */
  82139. LINES = 1,
  82140. /**
  82141. * Line Loop
  82142. */
  82143. LINE_LOOP = 2,
  82144. /**
  82145. * Line Strip
  82146. */
  82147. LINE_STRIP = 3,
  82148. /**
  82149. * Triangles
  82150. */
  82151. TRIANGLES = 4,
  82152. /**
  82153. * Triangle Strip
  82154. */
  82155. TRIANGLE_STRIP = 5,
  82156. /**
  82157. * Triangle Fan
  82158. */
  82159. TRIANGLE_FAN = 6,
  82160. }
  82161. /**
  82162. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  82163. */
  82164. const enum TextureMagFilter {
  82165. /**
  82166. * Nearest
  82167. */
  82168. NEAREST = 9728,
  82169. /**
  82170. * Linear
  82171. */
  82172. LINEAR = 9729,
  82173. }
  82174. /**
  82175. * Minification filter. All valid values correspond to WebGL enums
  82176. */
  82177. const enum TextureMinFilter {
  82178. /**
  82179. * Nearest
  82180. */
  82181. NEAREST = 9728,
  82182. /**
  82183. * Linear
  82184. */
  82185. LINEAR = 9729,
  82186. /**
  82187. * Nearest Mip-Map Nearest
  82188. */
  82189. NEAREST_MIPMAP_NEAREST = 9984,
  82190. /**
  82191. * Linear Mipmap Nearest
  82192. */
  82193. LINEAR_MIPMAP_NEAREST = 9985,
  82194. /**
  82195. * Nearest Mipmap Linear
  82196. */
  82197. NEAREST_MIPMAP_LINEAR = 9986,
  82198. /**
  82199. * Linear Mipmap Linear
  82200. */
  82201. LINEAR_MIPMAP_LINEAR = 9987,
  82202. }
  82203. /**
  82204. * S (U) wrapping mode. All valid values correspond to WebGL enums
  82205. */
  82206. const enum TextureWrapMode {
  82207. /**
  82208. * Clamp to Edge
  82209. */
  82210. CLAMP_TO_EDGE = 33071,
  82211. /**
  82212. * Mirrored Repeat
  82213. */
  82214. MIRRORED_REPEAT = 33648,
  82215. /**
  82216. * Repeat
  82217. */
  82218. REPEAT = 10497,
  82219. }
  82220. /**
  82221. * glTF Property
  82222. */
  82223. interface IProperty {
  82224. /**
  82225. * Dictionary object with extension-specific objects
  82226. */
  82227. extensions?: {
  82228. [key: string]: any;
  82229. };
  82230. /**
  82231. * Application-Specific data
  82232. */
  82233. extras?: any;
  82234. }
  82235. /**
  82236. * glTF Child of Root Property
  82237. */
  82238. interface IChildRootProperty extends IProperty {
  82239. /**
  82240. * The user-defined name of this object
  82241. */
  82242. name?: string;
  82243. }
  82244. /**
  82245. * Indices of those attributes that deviate from their initialization value
  82246. */
  82247. interface IAccessorSparseIndices extends IProperty {
  82248. /**
  82249. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  82250. */
  82251. bufferView: number;
  82252. /**
  82253. * The offset relative to the start of the bufferView in bytes. Must be aligned
  82254. */
  82255. byteOffset?: number;
  82256. /**
  82257. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  82258. */
  82259. componentType: AccessorComponentType;
  82260. }
  82261. /**
  82262. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  82263. */
  82264. interface IAccessorSparseValues extends IProperty {
  82265. /**
  82266. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  82267. */
  82268. bufferView: number;
  82269. /**
  82270. * The offset relative to the start of the bufferView in bytes. Must be aligned
  82271. */
  82272. byteOffset?: number;
  82273. }
  82274. /**
  82275. * Sparse storage of attributes that deviate from their initialization value
  82276. */
  82277. interface IAccessorSparse extends IProperty {
  82278. /**
  82279. * The number of attributes encoded in this sparse accessor
  82280. */
  82281. count: number;
  82282. /**
  82283. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  82284. */
  82285. indices: IAccessorSparseIndices;
  82286. /**
  82287. * 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
  82288. */
  82289. values: IAccessorSparseValues;
  82290. }
  82291. /**
  82292. * 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
  82293. */
  82294. interface IAccessor extends IChildRootProperty {
  82295. /**
  82296. * The index of the bufferview
  82297. */
  82298. bufferView?: number;
  82299. /**
  82300. * The offset relative to the start of the bufferView in bytes
  82301. */
  82302. byteOffset?: number;
  82303. /**
  82304. * The datatype of components in the attribute
  82305. */
  82306. componentType: AccessorComponentType;
  82307. /**
  82308. * Specifies whether integer data values should be normalized
  82309. */
  82310. normalized?: boolean;
  82311. /**
  82312. * The number of attributes referenced by this accessor
  82313. */
  82314. count: number;
  82315. /**
  82316. * Specifies if the attribute is a scalar, vector, or matrix
  82317. */
  82318. type: AccessorType;
  82319. /**
  82320. * Maximum value of each component in this attribute
  82321. */
  82322. max?: number[];
  82323. /**
  82324. * Minimum value of each component in this attribute
  82325. */
  82326. min?: number[];
  82327. /**
  82328. * Sparse storage of attributes that deviate from their initialization value
  82329. */
  82330. sparse?: IAccessorSparse;
  82331. }
  82332. /**
  82333. * Targets an animation's sampler at a node's property
  82334. */
  82335. interface IAnimationChannel extends IProperty {
  82336. /**
  82337. * The index of a sampler in this animation used to compute the value for the target
  82338. */
  82339. sampler: number;
  82340. /**
  82341. * The index of the node and TRS property to target
  82342. */
  82343. target: IAnimationChannelTarget;
  82344. }
  82345. /**
  82346. * The index of the node and TRS property that an animation channel targets
  82347. */
  82348. interface IAnimationChannelTarget extends IProperty {
  82349. /**
  82350. * The index of the node to target
  82351. */
  82352. node: number;
  82353. /**
  82354. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  82355. */
  82356. path: AnimationChannelTargetPath;
  82357. }
  82358. /**
  82359. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  82360. */
  82361. interface IAnimationSampler extends IProperty {
  82362. /**
  82363. * The index of an accessor containing keyframe input values, e.g., time
  82364. */
  82365. input: number;
  82366. /**
  82367. * Interpolation algorithm
  82368. */
  82369. interpolation?: AnimationSamplerInterpolation;
  82370. /**
  82371. * The index of an accessor, containing keyframe output values
  82372. */
  82373. output: number;
  82374. }
  82375. /**
  82376. * A keyframe animation
  82377. */
  82378. interface IAnimation extends IChildRootProperty {
  82379. /**
  82380. * An array of channels, each of which targets an animation's sampler at a node's property
  82381. */
  82382. channels: IAnimationChannel[];
  82383. /**
  82384. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  82385. */
  82386. samplers: IAnimationSampler[];
  82387. }
  82388. /**
  82389. * Metadata about the glTF asset
  82390. */
  82391. interface IAsset extends IChildRootProperty {
  82392. /**
  82393. * A copyright message suitable for display to credit the content creator
  82394. */
  82395. copyright?: string;
  82396. /**
  82397. * Tool that generated this glTF model. Useful for debugging
  82398. */
  82399. generator?: string;
  82400. /**
  82401. * The glTF version that this asset targets
  82402. */
  82403. version: string;
  82404. /**
  82405. * The minimum glTF version that this asset targets
  82406. */
  82407. minVersion?: string;
  82408. }
  82409. /**
  82410. * A buffer points to binary geometry, animation, or skins
  82411. */
  82412. interface IBuffer extends IChildRootProperty {
  82413. /**
  82414. * 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
  82415. */
  82416. uri?: string;
  82417. /**
  82418. * The length of the buffer in bytes
  82419. */
  82420. byteLength: number;
  82421. }
  82422. /**
  82423. * A view into a buffer generally representing a subset of the buffer
  82424. */
  82425. interface IBufferView extends IChildRootProperty {
  82426. /**
  82427. * The index of the buffer
  82428. */
  82429. buffer: number;
  82430. /**
  82431. * The offset into the buffer in bytes
  82432. */
  82433. byteOffset?: number;
  82434. /**
  82435. * The lenth of the bufferView in bytes
  82436. */
  82437. byteLength: number;
  82438. /**
  82439. * The stride, in bytes
  82440. */
  82441. byteStride?: number;
  82442. }
  82443. /**
  82444. * An orthographic camera containing properties to create an orthographic projection matrix
  82445. */
  82446. interface ICameraOrthographic extends IProperty {
  82447. /**
  82448. * The floating-point horizontal magnification of the view. Must not be zero
  82449. */
  82450. xmag: number;
  82451. /**
  82452. * The floating-point vertical magnification of the view. Must not be zero
  82453. */
  82454. ymag: number;
  82455. /**
  82456. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  82457. */
  82458. zfar: number;
  82459. /**
  82460. * The floating-point distance to the near clipping plane
  82461. */
  82462. znear: number;
  82463. }
  82464. /**
  82465. * A perspective camera containing properties to create a perspective projection matrix
  82466. */
  82467. interface ICameraPerspective extends IProperty {
  82468. /**
  82469. * The floating-point aspect ratio of the field of view
  82470. */
  82471. aspectRatio?: number;
  82472. /**
  82473. * The floating-point vertical field of view in radians
  82474. */
  82475. yfov: number;
  82476. /**
  82477. * The floating-point distance to the far clipping plane
  82478. */
  82479. zfar?: number;
  82480. /**
  82481. * The floating-point distance to the near clipping plane
  82482. */
  82483. znear: number;
  82484. }
  82485. /**
  82486. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  82487. */
  82488. interface ICamera extends IChildRootProperty {
  82489. /**
  82490. * An orthographic camera containing properties to create an orthographic projection matrix
  82491. */
  82492. orthographic?: ICameraOrthographic;
  82493. /**
  82494. * A perspective camera containing properties to create a perspective projection matrix
  82495. */
  82496. perspective?: ICameraPerspective;
  82497. /**
  82498. * Specifies if the camera uses a perspective or orthographic projection
  82499. */
  82500. type: CameraType;
  82501. }
  82502. /**
  82503. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  82504. */
  82505. interface IImage extends IChildRootProperty {
  82506. /**
  82507. * 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
  82508. */
  82509. uri?: string;
  82510. /**
  82511. * The image's MIME type
  82512. */
  82513. mimeType?: ImageMimeType;
  82514. /**
  82515. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  82516. */
  82517. bufferView?: number;
  82518. }
  82519. /**
  82520. * Material Normal Texture Info
  82521. */
  82522. interface IMaterialNormalTextureInfo extends ITextureInfo {
  82523. /**
  82524. * The scalar multiplier applied to each normal vector of the normal texture
  82525. */
  82526. scale?: number;
  82527. }
  82528. /**
  82529. * Material Occlusion Texture Info
  82530. */
  82531. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  82532. /**
  82533. * A scalar multiplier controlling the amount of occlusion applied
  82534. */
  82535. strength?: number;
  82536. }
  82537. /**
  82538. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  82539. */
  82540. interface IMaterialPbrMetallicRoughness {
  82541. /**
  82542. * The material's base color factor
  82543. */
  82544. baseColorFactor?: number[];
  82545. /**
  82546. * The base color texture
  82547. */
  82548. baseColorTexture?: ITextureInfo;
  82549. /**
  82550. * The metalness of the material
  82551. */
  82552. metallicFactor?: number;
  82553. /**
  82554. * The roughness of the material
  82555. */
  82556. roughnessFactor?: number;
  82557. /**
  82558. * The metallic-roughness texture
  82559. */
  82560. metallicRoughnessTexture?: ITextureInfo;
  82561. }
  82562. /**
  82563. * The material appearance of a primitive
  82564. */
  82565. interface IMaterial extends IChildRootProperty {
  82566. /**
  82567. * 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
  82568. */
  82569. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  82570. /**
  82571. * The normal map texture
  82572. */
  82573. normalTexture?: IMaterialNormalTextureInfo;
  82574. /**
  82575. * The occlusion map texture
  82576. */
  82577. occlusionTexture?: IMaterialOcclusionTextureInfo;
  82578. /**
  82579. * The emissive map texture
  82580. */
  82581. emissiveTexture?: ITextureInfo;
  82582. /**
  82583. * 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
  82584. */
  82585. emissiveFactor?: number[];
  82586. /**
  82587. * The alpha rendering mode of the material
  82588. */
  82589. alphaMode?: MaterialAlphaMode;
  82590. /**
  82591. * The alpha cutoff value of the material
  82592. */
  82593. alphaCutoff?: number;
  82594. /**
  82595. * Specifies whether the material is double sided
  82596. */
  82597. doubleSided?: boolean;
  82598. }
  82599. /**
  82600. * Geometry to be rendered with the given material
  82601. */
  82602. interface IMeshPrimitive extends IProperty {
  82603. /**
  82604. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  82605. */
  82606. attributes: {
  82607. [name: string]: number;
  82608. };
  82609. /**
  82610. * The index of the accessor that contains the indices
  82611. */
  82612. indices?: number;
  82613. /**
  82614. * The index of the material to apply to this primitive when rendering
  82615. */
  82616. material?: number;
  82617. /**
  82618. * The type of primitives to render. All valid values correspond to WebGL enums
  82619. */
  82620. mode?: MeshPrimitiveMode;
  82621. /**
  82622. * 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
  82623. */
  82624. targets?: {
  82625. [name: string]: number;
  82626. }[];
  82627. }
  82628. /**
  82629. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  82630. */
  82631. interface IMesh extends IChildRootProperty {
  82632. /**
  82633. * An array of primitives, each defining geometry to be rendered with a material
  82634. */
  82635. primitives: IMeshPrimitive[];
  82636. /**
  82637. * Array of weights to be applied to the Morph Targets
  82638. */
  82639. weights?: number[];
  82640. }
  82641. /**
  82642. * A node in the node hierarchy
  82643. */
  82644. interface INode extends IChildRootProperty {
  82645. /**
  82646. * The index of the camera referenced by this node
  82647. */
  82648. camera?: number;
  82649. /**
  82650. * The indices of this node's children
  82651. */
  82652. children?: number[];
  82653. /**
  82654. * The index of the skin referenced by this node
  82655. */
  82656. skin?: number;
  82657. /**
  82658. * A floating-point 4x4 transformation matrix stored in column-major order
  82659. */
  82660. matrix?: number[];
  82661. /**
  82662. * The index of the mesh in this node
  82663. */
  82664. mesh?: number;
  82665. /**
  82666. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  82667. */
  82668. rotation?: number[];
  82669. /**
  82670. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  82671. */
  82672. scale?: number[];
  82673. /**
  82674. * The node's translation along the x, y, and z axes
  82675. */
  82676. translation?: number[];
  82677. /**
  82678. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  82679. */
  82680. weights?: number[];
  82681. }
  82682. /**
  82683. * Texture sampler properties for filtering and wrapping modes
  82684. */
  82685. interface ISampler extends IChildRootProperty {
  82686. /**
  82687. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  82688. */
  82689. magFilter?: TextureMagFilter;
  82690. /**
  82691. * Minification filter. All valid values correspond to WebGL enums
  82692. */
  82693. minFilter?: TextureMinFilter;
  82694. /**
  82695. * S (U) wrapping mode. All valid values correspond to WebGL enums
  82696. */
  82697. wrapS?: TextureWrapMode;
  82698. /**
  82699. * T (V) wrapping mode. All valid values correspond to WebGL enums
  82700. */
  82701. wrapT?: TextureWrapMode;
  82702. }
  82703. /**
  82704. * The root nodes of a scene
  82705. */
  82706. interface IScene extends IChildRootProperty {
  82707. /**
  82708. * The indices of each root node
  82709. */
  82710. nodes: number[];
  82711. }
  82712. /**
  82713. * Joints and matrices defining a skin
  82714. */
  82715. interface ISkin extends IChildRootProperty {
  82716. /**
  82717. * 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
  82718. */
  82719. inverseBindMatrices?: number;
  82720. /**
  82721. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  82722. */
  82723. skeleton?: number;
  82724. /**
  82725. * 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)
  82726. */
  82727. joints: number[];
  82728. }
  82729. /**
  82730. * A texture and its sampler
  82731. */
  82732. interface ITexture extends IChildRootProperty {
  82733. /**
  82734. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  82735. */
  82736. sampler?: number;
  82737. /**
  82738. * The index of the image used by this texture
  82739. */
  82740. source: number;
  82741. }
  82742. /**
  82743. * Reference to a texture
  82744. */
  82745. interface ITextureInfo extends IProperty {
  82746. /**
  82747. * The index of the texture
  82748. */
  82749. index: number;
  82750. /**
  82751. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  82752. */
  82753. texCoord?: number;
  82754. }
  82755. /**
  82756. * The root object for a glTF asset
  82757. */
  82758. interface IGLTF extends IProperty {
  82759. /**
  82760. * An array of accessors. An accessor is a typed view into a bufferView
  82761. */
  82762. accessors?: IAccessor[];
  82763. /**
  82764. * An array of keyframe animations
  82765. */
  82766. animations?: IAnimation[];
  82767. /**
  82768. * Metadata about the glTF asset
  82769. */
  82770. asset: IAsset;
  82771. /**
  82772. * An array of buffers. A buffer points to binary geometry, animation, or skins
  82773. */
  82774. buffers?: IBuffer[];
  82775. /**
  82776. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  82777. */
  82778. bufferViews?: IBufferView[];
  82779. /**
  82780. * An array of cameras
  82781. */
  82782. cameras?: ICamera[];
  82783. /**
  82784. * Names of glTF extensions used somewhere in this asset
  82785. */
  82786. extensionsUsed?: string[];
  82787. /**
  82788. * Names of glTF extensions required to properly load this asset
  82789. */
  82790. extensionsRequired?: string[];
  82791. /**
  82792. * An array of images. An image defines data used to create a texture
  82793. */
  82794. images?: IImage[];
  82795. /**
  82796. * An array of materials. A material defines the appearance of a primitive
  82797. */
  82798. materials?: IMaterial[];
  82799. /**
  82800. * An array of meshes. A mesh is a set of primitives to be rendered
  82801. */
  82802. meshes?: IMesh[];
  82803. /**
  82804. * An array of nodes
  82805. */
  82806. nodes?: INode[];
  82807. /**
  82808. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  82809. */
  82810. samplers?: ISampler[];
  82811. /**
  82812. * The index of the default scene
  82813. */
  82814. scene?: number;
  82815. /**
  82816. * An array of scenes
  82817. */
  82818. scenes?: IScene[];
  82819. /**
  82820. * An array of skins. A skin is defined by joints and matrices
  82821. */
  82822. skins?: ISkin[];
  82823. /**
  82824. * An array of textures
  82825. */
  82826. textures?: ITexture[];
  82827. }
  82828. /**
  82829. * The glTF validation results
  82830. * @ignore
  82831. */
  82832. interface IGLTFValidationResults {
  82833. info: {
  82834. generator: string;
  82835. hasAnimations: boolean;
  82836. hasDefaultScene: boolean;
  82837. hasMaterials: boolean;
  82838. hasMorphTargets: boolean;
  82839. hasSkins: boolean;
  82840. hasTextures: boolean;
  82841. maxAttributesUsed: number;
  82842. primitivesCount: number
  82843. };
  82844. issues: {
  82845. messages: Array<string>;
  82846. numErrors: number;
  82847. numHints: number;
  82848. numInfos: number;
  82849. numWarnings: number;
  82850. truncated: boolean
  82851. };
  82852. mimeType: string;
  82853. uri: string;
  82854. validatedAt: string;
  82855. validatorVersion: string;
  82856. }
  82857. /**
  82858. * The glTF validation options
  82859. */
  82860. interface IGLTFValidationOptions {
  82861. /** Uri to use */
  82862. uri?: string;
  82863. /** Function used to load external resources */
  82864. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  82865. /** Boolean indicating that we need to validate accessor data */
  82866. validateAccessorData?: boolean;
  82867. /** max number of issues allowed */
  82868. maxIssues?: number;
  82869. /** Ignored issues */
  82870. ignoredIssues?: Array<string>;
  82871. /** Value to override severy settings */
  82872. severityOverrides?: Object;
  82873. }
  82874. /**
  82875. * The glTF validator object
  82876. * @ignore
  82877. */
  82878. interface IGLTFValidator {
  82879. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  82880. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  82881. }
  82882. }
  82883. declare module BABYLON {
  82884. /** @hidden */
  82885. export var cellPixelShader: {
  82886. name: string;
  82887. shader: string;
  82888. };
  82889. }
  82890. declare module BABYLON {
  82891. /** @hidden */
  82892. export var cellVertexShader: {
  82893. name: string;
  82894. shader: string;
  82895. };
  82896. }
  82897. declare module BABYLON {
  82898. export class CellMaterial extends BABYLON.PushMaterial {
  82899. private _diffuseTexture;
  82900. diffuseTexture: BABYLON.BaseTexture;
  82901. diffuseColor: BABYLON.Color3;
  82902. _computeHighLevel: boolean;
  82903. computeHighLevel: boolean;
  82904. private _disableLighting;
  82905. disableLighting: boolean;
  82906. private _maxSimultaneousLights;
  82907. maxSimultaneousLights: number;
  82908. constructor(name: string, scene: BABYLON.Scene);
  82909. needAlphaBlending(): boolean;
  82910. needAlphaTesting(): boolean;
  82911. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82912. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82913. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82914. getAnimatables(): BABYLON.IAnimatable[];
  82915. getActiveTextures(): BABYLON.BaseTexture[];
  82916. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82917. dispose(forceDisposeEffect?: boolean): void;
  82918. getClassName(): string;
  82919. clone(name: string): CellMaterial;
  82920. serialize(): any;
  82921. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  82922. }
  82923. }
  82924. declare module BABYLON {
  82925. export class CustomShaderStructure {
  82926. FragmentStore: string;
  82927. VertexStore: string;
  82928. constructor();
  82929. }
  82930. export class ShaderSpecialParts {
  82931. constructor();
  82932. Fragment_Begin: string;
  82933. Fragment_Definitions: string;
  82934. Fragment_MainBegin: string;
  82935. Fragment_Custom_Diffuse: string;
  82936. Fragment_Before_Lights: string;
  82937. Fragment_Before_Fog: string;
  82938. Fragment_Custom_Alpha: string;
  82939. Fragment_Before_FragColor: string;
  82940. Vertex_Begin: string;
  82941. Vertex_Definitions: string;
  82942. Vertex_MainBegin: string;
  82943. Vertex_Before_PositionUpdated: string;
  82944. Vertex_Before_NormalUpdated: string;
  82945. Vertex_After_WorldPosComputed: string;
  82946. Vertex_MainEnd: string;
  82947. }
  82948. export class CustomMaterial extends BABYLON.StandardMaterial {
  82949. static ShaderIndexer: number;
  82950. CustomParts: ShaderSpecialParts;
  82951. _isCreatedShader: boolean;
  82952. _createdShaderName: string;
  82953. _customUniform: string[];
  82954. _newUniforms: string[];
  82955. _newUniformInstances: {
  82956. [name: string]: any;
  82957. };
  82958. _newSamplerInstances: {
  82959. [name: string]: BABYLON.Texture;
  82960. };
  82961. _customAttributes: string[];
  82962. FragmentShader: string;
  82963. VertexShader: string;
  82964. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  82965. ReviewUniform(name: string, arr: string[]): string[];
  82966. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  82967. constructor(name: string, scene: BABYLON.Scene);
  82968. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  82969. AddAttribute(name: string): CustomMaterial;
  82970. Fragment_Begin(shaderPart: string): CustomMaterial;
  82971. Fragment_Definitions(shaderPart: string): CustomMaterial;
  82972. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  82973. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  82974. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  82975. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  82976. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  82977. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  82978. Vertex_Begin(shaderPart: string): CustomMaterial;
  82979. Vertex_Definitions(shaderPart: string): CustomMaterial;
  82980. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  82981. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  82982. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  82983. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  82984. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  82985. }
  82986. }
  82987. declare module BABYLON {
  82988. export class ShaderAlebdoParts {
  82989. constructor();
  82990. Fragment_Begin: string;
  82991. Fragment_Definitions: string;
  82992. Fragment_MainBegin: string;
  82993. Fragment_Custom_Albedo: string;
  82994. Fragment_Before_Lights: string;
  82995. Fragment_Custom_MetallicRoughness: string;
  82996. Fragment_Custom_MicroSurface: string;
  82997. Fragment_Before_Fog: string;
  82998. Fragment_Custom_Alpha: string;
  82999. Fragment_Before_FragColor: string;
  83000. Vertex_Begin: string;
  83001. Vertex_Definitions: string;
  83002. Vertex_MainBegin: string;
  83003. Vertex_Before_PositionUpdated: string;
  83004. Vertex_Before_NormalUpdated: string;
  83005. Vertex_After_WorldPosComputed: string;
  83006. Vertex_MainEnd: string;
  83007. }
  83008. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  83009. static ShaderIndexer: number;
  83010. CustomParts: ShaderAlebdoParts;
  83011. _isCreatedShader: boolean;
  83012. _createdShaderName: string;
  83013. _customUniform: string[];
  83014. _newUniforms: string[];
  83015. _newUniformInstances: {
  83016. [name: string]: any;
  83017. };
  83018. _newSamplerInstances: {
  83019. [name: string]: BABYLON.Texture;
  83020. };
  83021. _customAttributes: string[];
  83022. FragmentShader: string;
  83023. VertexShader: string;
  83024. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  83025. ReviewUniform(name: string, arr: string[]): string[];
  83026. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  83027. constructor(name: string, scene: BABYLON.Scene);
  83028. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  83029. AddAttribute(name: string): PBRCustomMaterial;
  83030. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  83031. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  83032. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  83033. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  83034. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  83035. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  83036. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  83037. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  83038. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  83039. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  83040. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  83041. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  83042. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  83043. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  83044. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  83045. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  83046. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  83047. }
  83048. }
  83049. declare module BABYLON {
  83050. /** @hidden */
  83051. export var firePixelShader: {
  83052. name: string;
  83053. shader: string;
  83054. };
  83055. }
  83056. declare module BABYLON {
  83057. /** @hidden */
  83058. export var fireVertexShader: {
  83059. name: string;
  83060. shader: string;
  83061. };
  83062. }
  83063. declare module BABYLON {
  83064. export class FireMaterial extends BABYLON.PushMaterial {
  83065. private _diffuseTexture;
  83066. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  83067. private _distortionTexture;
  83068. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  83069. private _opacityTexture;
  83070. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  83071. diffuseColor: BABYLON.Color3;
  83072. speed: number;
  83073. private _scaledDiffuse;
  83074. private _lastTime;
  83075. constructor(name: string, scene: BABYLON.Scene);
  83076. needAlphaBlending(): boolean;
  83077. needAlphaTesting(): boolean;
  83078. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83079. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83080. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83081. getAnimatables(): BABYLON.IAnimatable[];
  83082. getActiveTextures(): BABYLON.BaseTexture[];
  83083. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83084. getClassName(): string;
  83085. dispose(forceDisposeEffect?: boolean): void;
  83086. clone(name: string): FireMaterial;
  83087. serialize(): any;
  83088. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  83089. }
  83090. }
  83091. declare module BABYLON {
  83092. /** @hidden */
  83093. export var furPixelShader: {
  83094. name: string;
  83095. shader: string;
  83096. };
  83097. }
  83098. declare module BABYLON {
  83099. /** @hidden */
  83100. export var furVertexShader: {
  83101. name: string;
  83102. shader: string;
  83103. };
  83104. }
  83105. declare module BABYLON {
  83106. export class FurMaterial extends BABYLON.PushMaterial {
  83107. private _diffuseTexture;
  83108. diffuseTexture: BABYLON.BaseTexture;
  83109. private _heightTexture;
  83110. heightTexture: BABYLON.BaseTexture;
  83111. diffuseColor: BABYLON.Color3;
  83112. furLength: number;
  83113. furAngle: number;
  83114. furColor: BABYLON.Color3;
  83115. furOffset: number;
  83116. furSpacing: number;
  83117. furGravity: BABYLON.Vector3;
  83118. furSpeed: number;
  83119. furDensity: number;
  83120. furOcclusion: number;
  83121. furTexture: BABYLON.DynamicTexture;
  83122. private _disableLighting;
  83123. disableLighting: boolean;
  83124. private _maxSimultaneousLights;
  83125. maxSimultaneousLights: number;
  83126. highLevelFur: boolean;
  83127. _meshes: BABYLON.AbstractMesh[];
  83128. private _furTime;
  83129. constructor(name: string, scene: BABYLON.Scene);
  83130. get furTime(): number;
  83131. set furTime(furTime: number);
  83132. needAlphaBlending(): boolean;
  83133. needAlphaTesting(): boolean;
  83134. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83135. updateFur(): void;
  83136. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83137. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83138. getAnimatables(): BABYLON.IAnimatable[];
  83139. getActiveTextures(): BABYLON.BaseTexture[];
  83140. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83141. dispose(forceDisposeEffect?: boolean): void;
  83142. clone(name: string): FurMaterial;
  83143. serialize(): any;
  83144. getClassName(): string;
  83145. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  83146. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  83147. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  83148. }
  83149. }
  83150. declare module BABYLON {
  83151. /** @hidden */
  83152. export var gradientPixelShader: {
  83153. name: string;
  83154. shader: string;
  83155. };
  83156. }
  83157. declare module BABYLON {
  83158. /** @hidden */
  83159. export var gradientVertexShader: {
  83160. name: string;
  83161. shader: string;
  83162. };
  83163. }
  83164. declare module BABYLON {
  83165. export class GradientMaterial extends BABYLON.PushMaterial {
  83166. private _maxSimultaneousLights;
  83167. maxSimultaneousLights: number;
  83168. topColor: BABYLON.Color3;
  83169. topColorAlpha: number;
  83170. bottomColor: BABYLON.Color3;
  83171. bottomColorAlpha: number;
  83172. offset: number;
  83173. scale: number;
  83174. smoothness: number;
  83175. private _disableLighting;
  83176. disableLighting: boolean;
  83177. constructor(name: string, scene: BABYLON.Scene);
  83178. needAlphaBlending(): boolean;
  83179. needAlphaTesting(): boolean;
  83180. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83181. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83182. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83183. getAnimatables(): BABYLON.IAnimatable[];
  83184. dispose(forceDisposeEffect?: boolean): void;
  83185. clone(name: string): GradientMaterial;
  83186. serialize(): any;
  83187. getClassName(): string;
  83188. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  83189. }
  83190. }
  83191. declare module BABYLON {
  83192. /** @hidden */
  83193. export var gridPixelShader: {
  83194. name: string;
  83195. shader: string;
  83196. };
  83197. }
  83198. declare module BABYLON {
  83199. /** @hidden */
  83200. export var gridVertexShader: {
  83201. name: string;
  83202. shader: string;
  83203. };
  83204. }
  83205. declare module BABYLON {
  83206. /**
  83207. * The grid materials allows you to wrap any shape with a grid.
  83208. * Colors are customizable.
  83209. */
  83210. export class GridMaterial extends BABYLON.PushMaterial {
  83211. /**
  83212. * Main color of the grid (e.g. between lines)
  83213. */
  83214. mainColor: BABYLON.Color3;
  83215. /**
  83216. * Color of the grid lines.
  83217. */
  83218. lineColor: BABYLON.Color3;
  83219. /**
  83220. * The scale of the grid compared to unit.
  83221. */
  83222. gridRatio: number;
  83223. /**
  83224. * Allows setting an offset for the grid lines.
  83225. */
  83226. gridOffset: BABYLON.Vector3;
  83227. /**
  83228. * The frequency of thicker lines.
  83229. */
  83230. majorUnitFrequency: number;
  83231. /**
  83232. * The visibility of minor units in the grid.
  83233. */
  83234. minorUnitVisibility: number;
  83235. /**
  83236. * The grid opacity outside of the lines.
  83237. */
  83238. opacity: number;
  83239. /**
  83240. * Determine RBG output is premultiplied by alpha value.
  83241. */
  83242. preMultiplyAlpha: boolean;
  83243. private _opacityTexture;
  83244. opacityTexture: BABYLON.BaseTexture;
  83245. private _gridControl;
  83246. /**
  83247. * constructor
  83248. * @param name The name given to the material in order to identify it afterwards.
  83249. * @param scene The scene the material is used in.
  83250. */
  83251. constructor(name: string, scene: BABYLON.Scene);
  83252. /**
  83253. * Returns wehter or not the grid requires alpha blending.
  83254. */
  83255. needAlphaBlending(): boolean;
  83256. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  83257. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83258. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83259. /**
  83260. * Dispose the material and its associated resources.
  83261. * @param forceDisposeEffect will also dispose the used effect when true
  83262. */
  83263. dispose(forceDisposeEffect?: boolean): void;
  83264. clone(name: string): GridMaterial;
  83265. serialize(): any;
  83266. getClassName(): string;
  83267. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  83268. }
  83269. }
  83270. declare module BABYLON {
  83271. /** @hidden */
  83272. export var lavaPixelShader: {
  83273. name: string;
  83274. shader: string;
  83275. };
  83276. }
  83277. declare module BABYLON {
  83278. /** @hidden */
  83279. export var lavaVertexShader: {
  83280. name: string;
  83281. shader: string;
  83282. };
  83283. }
  83284. declare module BABYLON {
  83285. export class LavaMaterial extends BABYLON.PushMaterial {
  83286. private _diffuseTexture;
  83287. diffuseTexture: BABYLON.BaseTexture;
  83288. noiseTexture: BABYLON.BaseTexture;
  83289. fogColor: BABYLON.Color3;
  83290. speed: number;
  83291. movingSpeed: number;
  83292. lowFrequencySpeed: number;
  83293. fogDensity: number;
  83294. private _lastTime;
  83295. diffuseColor: BABYLON.Color3;
  83296. private _disableLighting;
  83297. disableLighting: boolean;
  83298. private _unlit;
  83299. unlit: boolean;
  83300. private _maxSimultaneousLights;
  83301. maxSimultaneousLights: number;
  83302. private _scaledDiffuse;
  83303. constructor(name: string, scene: BABYLON.Scene);
  83304. needAlphaBlending(): boolean;
  83305. needAlphaTesting(): boolean;
  83306. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83307. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83308. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83309. getAnimatables(): BABYLON.IAnimatable[];
  83310. getActiveTextures(): BABYLON.BaseTexture[];
  83311. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83312. dispose(forceDisposeEffect?: boolean): void;
  83313. clone(name: string): LavaMaterial;
  83314. serialize(): any;
  83315. getClassName(): string;
  83316. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  83317. }
  83318. }
  83319. declare module BABYLON {
  83320. /** @hidden */
  83321. export var mixPixelShader: {
  83322. name: string;
  83323. shader: string;
  83324. };
  83325. }
  83326. declare module BABYLON {
  83327. /** @hidden */
  83328. export var mixVertexShader: {
  83329. name: string;
  83330. shader: string;
  83331. };
  83332. }
  83333. declare module BABYLON {
  83334. export class MixMaterial extends BABYLON.PushMaterial {
  83335. /**
  83336. * Mix textures
  83337. */
  83338. private _mixTexture1;
  83339. mixTexture1: BABYLON.BaseTexture;
  83340. private _mixTexture2;
  83341. mixTexture2: BABYLON.BaseTexture;
  83342. /**
  83343. * Diffuse textures
  83344. */
  83345. private _diffuseTexture1;
  83346. diffuseTexture1: BABYLON.Texture;
  83347. private _diffuseTexture2;
  83348. diffuseTexture2: BABYLON.Texture;
  83349. private _diffuseTexture3;
  83350. diffuseTexture3: BABYLON.Texture;
  83351. private _diffuseTexture4;
  83352. diffuseTexture4: BABYLON.Texture;
  83353. private _diffuseTexture5;
  83354. diffuseTexture5: BABYLON.Texture;
  83355. private _diffuseTexture6;
  83356. diffuseTexture6: BABYLON.Texture;
  83357. private _diffuseTexture7;
  83358. diffuseTexture7: BABYLON.Texture;
  83359. private _diffuseTexture8;
  83360. diffuseTexture8: BABYLON.Texture;
  83361. /**
  83362. * Uniforms
  83363. */
  83364. diffuseColor: BABYLON.Color3;
  83365. specularColor: BABYLON.Color3;
  83366. specularPower: number;
  83367. private _disableLighting;
  83368. disableLighting: boolean;
  83369. private _maxSimultaneousLights;
  83370. maxSimultaneousLights: number;
  83371. constructor(name: string, scene: BABYLON.Scene);
  83372. needAlphaBlending(): boolean;
  83373. needAlphaTesting(): boolean;
  83374. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83375. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83376. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83377. getAnimatables(): BABYLON.IAnimatable[];
  83378. getActiveTextures(): BABYLON.BaseTexture[];
  83379. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83380. dispose(forceDisposeEffect?: boolean): void;
  83381. clone(name: string): MixMaterial;
  83382. serialize(): any;
  83383. getClassName(): string;
  83384. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  83385. }
  83386. }
  83387. declare module BABYLON {
  83388. /** @hidden */
  83389. export var normalPixelShader: {
  83390. name: string;
  83391. shader: string;
  83392. };
  83393. }
  83394. declare module BABYLON {
  83395. /** @hidden */
  83396. export var normalVertexShader: {
  83397. name: string;
  83398. shader: string;
  83399. };
  83400. }
  83401. declare module BABYLON {
  83402. export class NormalMaterial extends BABYLON.PushMaterial {
  83403. private _diffuseTexture;
  83404. diffuseTexture: BABYLON.BaseTexture;
  83405. diffuseColor: BABYLON.Color3;
  83406. private _disableLighting;
  83407. disableLighting: boolean;
  83408. private _maxSimultaneousLights;
  83409. maxSimultaneousLights: number;
  83410. constructor(name: string, scene: BABYLON.Scene);
  83411. needAlphaBlending(): boolean;
  83412. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  83413. needAlphaTesting(): boolean;
  83414. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83415. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83416. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83417. getAnimatables(): BABYLON.IAnimatable[];
  83418. getActiveTextures(): BABYLON.BaseTexture[];
  83419. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83420. dispose(forceDisposeEffect?: boolean): void;
  83421. clone(name: string): NormalMaterial;
  83422. serialize(): any;
  83423. getClassName(): string;
  83424. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  83425. }
  83426. }
  83427. declare module BABYLON {
  83428. /** @hidden */
  83429. export var shadowOnlyPixelShader: {
  83430. name: string;
  83431. shader: string;
  83432. };
  83433. }
  83434. declare module BABYLON {
  83435. /** @hidden */
  83436. export var shadowOnlyVertexShader: {
  83437. name: string;
  83438. shader: string;
  83439. };
  83440. }
  83441. declare module BABYLON {
  83442. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  83443. private _activeLight;
  83444. private _needAlphaBlending;
  83445. constructor(name: string, scene: BABYLON.Scene);
  83446. shadowColor: BABYLON.Color3;
  83447. needAlphaBlending(): boolean;
  83448. needAlphaTesting(): boolean;
  83449. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83450. get activeLight(): BABYLON.IShadowLight;
  83451. set activeLight(light: BABYLON.IShadowLight);
  83452. private _getFirstShadowLightForMesh;
  83453. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83454. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83455. clone(name: string): ShadowOnlyMaterial;
  83456. serialize(): any;
  83457. getClassName(): string;
  83458. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  83459. }
  83460. }
  83461. declare module BABYLON {
  83462. /** @hidden */
  83463. export var simplePixelShader: {
  83464. name: string;
  83465. shader: string;
  83466. };
  83467. }
  83468. declare module BABYLON {
  83469. /** @hidden */
  83470. export var simpleVertexShader: {
  83471. name: string;
  83472. shader: string;
  83473. };
  83474. }
  83475. declare module BABYLON {
  83476. export class SimpleMaterial extends BABYLON.PushMaterial {
  83477. private _diffuseTexture;
  83478. diffuseTexture: BABYLON.BaseTexture;
  83479. diffuseColor: BABYLON.Color3;
  83480. private _disableLighting;
  83481. disableLighting: boolean;
  83482. private _maxSimultaneousLights;
  83483. maxSimultaneousLights: number;
  83484. constructor(name: string, scene: BABYLON.Scene);
  83485. needAlphaBlending(): boolean;
  83486. needAlphaTesting(): boolean;
  83487. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83488. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83489. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83490. getAnimatables(): BABYLON.IAnimatable[];
  83491. getActiveTextures(): BABYLON.BaseTexture[];
  83492. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83493. dispose(forceDisposeEffect?: boolean): void;
  83494. clone(name: string): SimpleMaterial;
  83495. serialize(): any;
  83496. getClassName(): string;
  83497. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  83498. }
  83499. }
  83500. declare module BABYLON {
  83501. /** @hidden */
  83502. export var skyPixelShader: {
  83503. name: string;
  83504. shader: string;
  83505. };
  83506. }
  83507. declare module BABYLON {
  83508. /** @hidden */
  83509. export var skyVertexShader: {
  83510. name: string;
  83511. shader: string;
  83512. };
  83513. }
  83514. declare module BABYLON {
  83515. /**
  83516. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  83517. * @see https://doc.babylonjs.com/extensions/sky
  83518. */
  83519. export class SkyMaterial extends BABYLON.PushMaterial {
  83520. /**
  83521. * Defines the overall luminance of sky in interval ]0, 1[.
  83522. */
  83523. luminance: number;
  83524. /**
  83525. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  83526. */
  83527. turbidity: number;
  83528. /**
  83529. * Defines the sky appearance (light intensity).
  83530. */
  83531. rayleigh: number;
  83532. /**
  83533. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  83534. */
  83535. mieCoefficient: number;
  83536. /**
  83537. * Defines the amount of haze particles following the Mie scattering theory.
  83538. */
  83539. mieDirectionalG: number;
  83540. /**
  83541. * Defines the distance of the sun according to the active scene camera.
  83542. */
  83543. distance: number;
  83544. /**
  83545. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  83546. * "inclined".
  83547. */
  83548. inclination: number;
  83549. /**
  83550. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  83551. * an object direction and a reference direction.
  83552. */
  83553. azimuth: number;
  83554. /**
  83555. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  83556. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  83557. */
  83558. sunPosition: BABYLON.Vector3;
  83559. /**
  83560. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  83561. * .sunPosition property.
  83562. */
  83563. useSunPosition: boolean;
  83564. /**
  83565. * Defines an offset vector used to get a horizon offset.
  83566. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  83567. */
  83568. cameraOffset: BABYLON.Vector3;
  83569. private _cameraPosition;
  83570. /**
  83571. * Instantiates a new sky material.
  83572. * This material allows to create dynamic and texture free
  83573. * effects for skyboxes by taking care of the atmosphere state.
  83574. * @see https://doc.babylonjs.com/extensions/sky
  83575. * @param name Define the name of the material in the scene
  83576. * @param scene Define the scene the material belong to
  83577. */
  83578. constructor(name: string, scene: BABYLON.Scene);
  83579. /**
  83580. * Specifies if the material will require alpha blending
  83581. * @returns a boolean specifying if alpha blending is needed
  83582. */
  83583. needAlphaBlending(): boolean;
  83584. /**
  83585. * Specifies if this material should be rendered in alpha test mode
  83586. * @returns false as the sky material doesn't need alpha testing.
  83587. */
  83588. needAlphaTesting(): boolean;
  83589. /**
  83590. * Get the texture used for alpha test purpose.
  83591. * @returns null as the sky material has no texture.
  83592. */
  83593. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83594. /**
  83595. * Get if the submesh is ready to be used and all its information available.
  83596. * Child classes can use it to update shaders
  83597. * @param mesh defines the mesh to check
  83598. * @param subMesh defines which submesh to check
  83599. * @param useInstances specifies that instances should be used
  83600. * @returns a boolean indicating that the submesh is ready or not
  83601. */
  83602. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83603. /**
  83604. * Binds the submesh to this material by preparing the effect and shader to draw
  83605. * @param world defines the world transformation matrix
  83606. * @param mesh defines the mesh containing the submesh
  83607. * @param subMesh defines the submesh to bind the material to
  83608. */
  83609. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83610. /**
  83611. * Get the list of animatables in the material.
  83612. * @returns the list of animatables object used in the material
  83613. */
  83614. getAnimatables(): BABYLON.IAnimatable[];
  83615. /**
  83616. * Disposes the material
  83617. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  83618. */
  83619. dispose(forceDisposeEffect?: boolean): void;
  83620. /**
  83621. * Makes a duplicate of the material, and gives it a new name
  83622. * @param name defines the new name for the duplicated material
  83623. * @returns the cloned material
  83624. */
  83625. clone(name: string): SkyMaterial;
  83626. /**
  83627. * Serializes this material in a JSON representation
  83628. * @returns the serialized material object
  83629. */
  83630. serialize(): any;
  83631. /**
  83632. * Gets the current class name of the material e.g. "SkyMaterial"
  83633. * Mainly use in serialization.
  83634. * @returns the class name
  83635. */
  83636. getClassName(): string;
  83637. /**
  83638. * Creates a sky material from parsed material data
  83639. * @param source defines the JSON representation of the material
  83640. * @param scene defines the hosting scene
  83641. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  83642. * @returns a new sky material
  83643. */
  83644. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  83645. }
  83646. }
  83647. declare module BABYLON {
  83648. /** @hidden */
  83649. export var terrainPixelShader: {
  83650. name: string;
  83651. shader: string;
  83652. };
  83653. }
  83654. declare module BABYLON {
  83655. /** @hidden */
  83656. export var terrainVertexShader: {
  83657. name: string;
  83658. shader: string;
  83659. };
  83660. }
  83661. declare module BABYLON {
  83662. export class TerrainMaterial extends BABYLON.PushMaterial {
  83663. private _mixTexture;
  83664. mixTexture: BABYLON.BaseTexture;
  83665. private _diffuseTexture1;
  83666. diffuseTexture1: BABYLON.Texture;
  83667. private _diffuseTexture2;
  83668. diffuseTexture2: BABYLON.Texture;
  83669. private _diffuseTexture3;
  83670. diffuseTexture3: BABYLON.Texture;
  83671. private _bumpTexture1;
  83672. bumpTexture1: BABYLON.Texture;
  83673. private _bumpTexture2;
  83674. bumpTexture2: BABYLON.Texture;
  83675. private _bumpTexture3;
  83676. bumpTexture3: BABYLON.Texture;
  83677. diffuseColor: BABYLON.Color3;
  83678. specularColor: BABYLON.Color3;
  83679. specularPower: number;
  83680. private _disableLighting;
  83681. disableLighting: boolean;
  83682. private _maxSimultaneousLights;
  83683. maxSimultaneousLights: number;
  83684. constructor(name: string, scene: BABYLON.Scene);
  83685. needAlphaBlending(): boolean;
  83686. needAlphaTesting(): boolean;
  83687. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83688. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83689. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83690. getAnimatables(): BABYLON.IAnimatable[];
  83691. getActiveTextures(): BABYLON.BaseTexture[];
  83692. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83693. dispose(forceDisposeEffect?: boolean): void;
  83694. clone(name: string): TerrainMaterial;
  83695. serialize(): any;
  83696. getClassName(): string;
  83697. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  83698. }
  83699. }
  83700. declare module BABYLON {
  83701. /** @hidden */
  83702. export var triplanarPixelShader: {
  83703. name: string;
  83704. shader: string;
  83705. };
  83706. }
  83707. declare module BABYLON {
  83708. /** @hidden */
  83709. export var triplanarVertexShader: {
  83710. name: string;
  83711. shader: string;
  83712. };
  83713. }
  83714. declare module BABYLON {
  83715. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  83716. mixTexture: BABYLON.BaseTexture;
  83717. private _diffuseTextureX;
  83718. diffuseTextureX: BABYLON.BaseTexture;
  83719. private _diffuseTextureY;
  83720. diffuseTextureY: BABYLON.BaseTexture;
  83721. private _diffuseTextureZ;
  83722. diffuseTextureZ: BABYLON.BaseTexture;
  83723. private _normalTextureX;
  83724. normalTextureX: BABYLON.BaseTexture;
  83725. private _normalTextureY;
  83726. normalTextureY: BABYLON.BaseTexture;
  83727. private _normalTextureZ;
  83728. normalTextureZ: BABYLON.BaseTexture;
  83729. tileSize: number;
  83730. diffuseColor: BABYLON.Color3;
  83731. specularColor: BABYLON.Color3;
  83732. specularPower: number;
  83733. private _disableLighting;
  83734. disableLighting: boolean;
  83735. private _maxSimultaneousLights;
  83736. maxSimultaneousLights: number;
  83737. constructor(name: string, scene: BABYLON.Scene);
  83738. needAlphaBlending(): boolean;
  83739. needAlphaTesting(): boolean;
  83740. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83741. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83742. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83743. getAnimatables(): BABYLON.IAnimatable[];
  83744. getActiveTextures(): BABYLON.BaseTexture[];
  83745. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83746. dispose(forceDisposeEffect?: boolean): void;
  83747. clone(name: string): TriPlanarMaterial;
  83748. serialize(): any;
  83749. getClassName(): string;
  83750. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  83751. }
  83752. }
  83753. declare module BABYLON {
  83754. /** @hidden */
  83755. export var waterPixelShader: {
  83756. name: string;
  83757. shader: string;
  83758. };
  83759. }
  83760. declare module BABYLON {
  83761. /** @hidden */
  83762. export var waterVertexShader: {
  83763. name: string;
  83764. shader: string;
  83765. };
  83766. }
  83767. declare module BABYLON {
  83768. export class WaterMaterial extends BABYLON.PushMaterial {
  83769. renderTargetSize: BABYLON.Vector2;
  83770. private _bumpTexture;
  83771. bumpTexture: BABYLON.BaseTexture;
  83772. diffuseColor: BABYLON.Color3;
  83773. specularColor: BABYLON.Color3;
  83774. specularPower: number;
  83775. private _disableLighting;
  83776. disableLighting: boolean;
  83777. private _maxSimultaneousLights;
  83778. maxSimultaneousLights: number;
  83779. /**
  83780. * @param {number}: Represents the wind force
  83781. */
  83782. windForce: number;
  83783. /**
  83784. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  83785. */
  83786. windDirection: BABYLON.Vector2;
  83787. /**
  83788. * @param {number}: Wave height, represents the height of the waves
  83789. */
  83790. waveHeight: number;
  83791. /**
  83792. * @param {number}: Bump height, represents the bump height related to the bump map
  83793. */
  83794. bumpHeight: number;
  83795. /**
  83796. * @param {boolean}: Add a smaller moving bump to less steady waves.
  83797. */
  83798. private _bumpSuperimpose;
  83799. bumpSuperimpose: boolean;
  83800. /**
  83801. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  83802. */
  83803. private _fresnelSeparate;
  83804. fresnelSeparate: boolean;
  83805. /**
  83806. * @param {boolean}: bump Waves modify the reflection.
  83807. */
  83808. private _bumpAffectsReflection;
  83809. bumpAffectsReflection: boolean;
  83810. /**
  83811. * @param {number}: The water color blended with the refraction (near)
  83812. */
  83813. waterColor: BABYLON.Color3;
  83814. /**
  83815. * @param {number}: The blend factor related to the water color
  83816. */
  83817. colorBlendFactor: number;
  83818. /**
  83819. * @param {number}: The water color blended with the reflection (far)
  83820. */
  83821. waterColor2: BABYLON.Color3;
  83822. /**
  83823. * @param {number}: The blend factor related to the water color (reflection, far)
  83824. */
  83825. colorBlendFactor2: number;
  83826. /**
  83827. * @param {number}: Represents the maximum length of a wave
  83828. */
  83829. waveLength: number;
  83830. /**
  83831. * @param {number}: Defines the waves speed
  83832. */
  83833. waveSpeed: number;
  83834. /**
  83835. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  83836. * will avoid calculating useless pixels in the pixel shader of the water material.
  83837. */
  83838. disableClipPlane: boolean;
  83839. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  83840. private _mesh;
  83841. private _refractionRTT;
  83842. private _reflectionRTT;
  83843. private _reflectionTransform;
  83844. private _lastTime;
  83845. private _lastDeltaTime;
  83846. private _useLogarithmicDepth;
  83847. private _waitingRenderList;
  83848. private _imageProcessingConfiguration;
  83849. private _imageProcessingObserver;
  83850. /**
  83851. * Gets a boolean indicating that current material needs to register RTT
  83852. */
  83853. get hasRenderTargetTextures(): boolean;
  83854. /**
  83855. * Constructor
  83856. */
  83857. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  83858. get useLogarithmicDepth(): boolean;
  83859. set useLogarithmicDepth(value: boolean);
  83860. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  83861. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  83862. addToRenderList(node: any): void;
  83863. enableRenderTargets(enable: boolean): void;
  83864. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  83865. get renderTargetsEnabled(): boolean;
  83866. needAlphaBlending(): boolean;
  83867. needAlphaTesting(): boolean;
  83868. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83869. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83870. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83871. private _createRenderTargets;
  83872. getAnimatables(): BABYLON.IAnimatable[];
  83873. getActiveTextures(): BABYLON.BaseTexture[];
  83874. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83875. dispose(forceDisposeEffect?: boolean): void;
  83876. clone(name: string): WaterMaterial;
  83877. serialize(): any;
  83878. getClassName(): string;
  83879. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  83880. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  83881. }
  83882. }
  83883. declare module BABYLON {
  83884. /** @hidden */
  83885. export var asciiartPixelShader: {
  83886. name: string;
  83887. shader: string;
  83888. };
  83889. }
  83890. declare module BABYLON {
  83891. /**
  83892. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  83893. *
  83894. * It basically takes care rendering the font front the given font size to a texture.
  83895. * This is used later on in the postprocess.
  83896. */
  83897. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  83898. private _font;
  83899. private _text;
  83900. private _charSize;
  83901. /**
  83902. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  83903. */
  83904. get charSize(): number;
  83905. /**
  83906. * Create a new instance of the Ascii Art FontTexture class
  83907. * @param name the name of the texture
  83908. * @param font the font to use, use the W3C CSS notation
  83909. * @param text the caracter set to use in the rendering.
  83910. * @param scene the scene that owns the texture
  83911. */
  83912. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  83913. /**
  83914. * Gets the max char width of a font.
  83915. * @param font the font to use, use the W3C CSS notation
  83916. * @return the max char width
  83917. */
  83918. private getFontWidth;
  83919. /**
  83920. * Gets the max char height of a font.
  83921. * @param font the font to use, use the W3C CSS notation
  83922. * @return the max char height
  83923. */
  83924. private getFontHeight;
  83925. /**
  83926. * Clones the current AsciiArtTexture.
  83927. * @return the clone of the texture.
  83928. */
  83929. clone(): AsciiArtFontTexture;
  83930. /**
  83931. * Parses a json object representing the texture and returns an instance of it.
  83932. * @param source the source JSON representation
  83933. * @param scene the scene to create the texture for
  83934. * @return the parsed texture
  83935. */
  83936. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  83937. }
  83938. /**
  83939. * Option available in the Ascii Art Post Process.
  83940. */
  83941. export interface IAsciiArtPostProcessOptions {
  83942. /**
  83943. * The font to use following the w3c font definition.
  83944. */
  83945. font?: string;
  83946. /**
  83947. * The character set to use in the postprocess.
  83948. */
  83949. characterSet?: string;
  83950. /**
  83951. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  83952. * This number is defined between 0 and 1;
  83953. */
  83954. mixToTile?: number;
  83955. /**
  83956. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  83957. * This number is defined between 0 and 1;
  83958. */
  83959. mixToNormal?: number;
  83960. }
  83961. /**
  83962. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  83963. *
  83964. * Simmply add it to your scene and let the nerd that lives in you have fun.
  83965. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  83966. */
  83967. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  83968. /**
  83969. * The font texture used to render the char in the post process.
  83970. */
  83971. private _asciiArtFontTexture;
  83972. /**
  83973. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  83974. * This number is defined between 0 and 1;
  83975. */
  83976. mixToTile: number;
  83977. /**
  83978. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  83979. * This number is defined between 0 and 1;
  83980. */
  83981. mixToNormal: number;
  83982. /**
  83983. * Instantiates a new Ascii Art Post Process.
  83984. * @param name the name to give to the postprocess
  83985. * @camera the camera to apply the post process to.
  83986. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  83987. */
  83988. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  83989. }
  83990. }
  83991. declare module BABYLON {
  83992. /** @hidden */
  83993. export var digitalrainPixelShader: {
  83994. name: string;
  83995. shader: string;
  83996. };
  83997. }
  83998. declare module BABYLON {
  83999. /**
  84000. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  84001. *
  84002. * It basically takes care rendering the font front the given font size to a texture.
  84003. * This is used later on in the postprocess.
  84004. */
  84005. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  84006. private _font;
  84007. private _text;
  84008. private _charSize;
  84009. /**
  84010. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  84011. */
  84012. get charSize(): number;
  84013. /**
  84014. * Create a new instance of the Digital Rain FontTexture class
  84015. * @param name the name of the texture
  84016. * @param font the font to use, use the W3C CSS notation
  84017. * @param text the caracter set to use in the rendering.
  84018. * @param scene the scene that owns the texture
  84019. */
  84020. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  84021. /**
  84022. * Gets the max char width of a font.
  84023. * @param font the font to use, use the W3C CSS notation
  84024. * @return the max char width
  84025. */
  84026. private getFontWidth;
  84027. /**
  84028. * Gets the max char height of a font.
  84029. * @param font the font to use, use the W3C CSS notation
  84030. * @return the max char height
  84031. */
  84032. private getFontHeight;
  84033. /**
  84034. * Clones the current DigitalRainFontTexture.
  84035. * @return the clone of the texture.
  84036. */
  84037. clone(): DigitalRainFontTexture;
  84038. /**
  84039. * Parses a json object representing the texture and returns an instance of it.
  84040. * @param source the source JSON representation
  84041. * @param scene the scene to create the texture for
  84042. * @return the parsed texture
  84043. */
  84044. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  84045. }
  84046. /**
  84047. * Option available in the Digital Rain Post Process.
  84048. */
  84049. export interface IDigitalRainPostProcessOptions {
  84050. /**
  84051. * The font to use following the w3c font definition.
  84052. */
  84053. font?: string;
  84054. /**
  84055. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  84056. * This number is defined between 0 and 1;
  84057. */
  84058. mixToTile?: number;
  84059. /**
  84060. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  84061. * This number is defined between 0 and 1;
  84062. */
  84063. mixToNormal?: number;
  84064. }
  84065. /**
  84066. * DigitalRainPostProcess helps rendering everithing in digital rain.
  84067. *
  84068. * Simmply add it to your scene and let the nerd that lives in you have fun.
  84069. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  84070. */
  84071. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  84072. /**
  84073. * The font texture used to render the char in the post process.
  84074. */
  84075. private _digitalRainFontTexture;
  84076. /**
  84077. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  84078. * This number is defined between 0 and 1;
  84079. */
  84080. mixToTile: number;
  84081. /**
  84082. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  84083. * This number is defined between 0 and 1;
  84084. */
  84085. mixToNormal: number;
  84086. /**
  84087. * Instantiates a new Digital Rain Post Process.
  84088. * @param name the name to give to the postprocess
  84089. * @camera the camera to apply the post process to.
  84090. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  84091. */
  84092. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  84093. }
  84094. }
  84095. declare module BABYLON {
  84096. /** @hidden */
  84097. export var brickProceduralTexturePixelShader: {
  84098. name: string;
  84099. shader: string;
  84100. };
  84101. }
  84102. declare module BABYLON {
  84103. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  84104. private _numberOfBricksHeight;
  84105. private _numberOfBricksWidth;
  84106. private _jointColor;
  84107. private _brickColor;
  84108. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84109. updateShaderUniforms(): void;
  84110. get numberOfBricksHeight(): number;
  84111. set numberOfBricksHeight(value: number);
  84112. get numberOfBricksWidth(): number;
  84113. set numberOfBricksWidth(value: number);
  84114. get jointColor(): BABYLON.Color3;
  84115. set jointColor(value: BABYLON.Color3);
  84116. get brickColor(): BABYLON.Color3;
  84117. set brickColor(value: BABYLON.Color3);
  84118. /**
  84119. * Serializes this brick procedural texture
  84120. * @returns a serialized brick procedural texture object
  84121. */
  84122. serialize(): any;
  84123. /**
  84124. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  84125. * @param parsedTexture defines parsed texture data
  84126. * @param scene defines the current scene
  84127. * @param rootUrl defines the root URL containing brick procedural texture information
  84128. * @returns a parsed Brick Procedural BABYLON.Texture
  84129. */
  84130. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  84131. }
  84132. }
  84133. declare module BABYLON {
  84134. /** @hidden */
  84135. export var cloudProceduralTexturePixelShader: {
  84136. name: string;
  84137. shader: string;
  84138. };
  84139. }
  84140. declare module BABYLON {
  84141. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  84142. private _skyColor;
  84143. private _cloudColor;
  84144. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84145. updateShaderUniforms(): void;
  84146. get skyColor(): BABYLON.Color4;
  84147. set skyColor(value: BABYLON.Color4);
  84148. get cloudColor(): BABYLON.Color4;
  84149. set cloudColor(value: BABYLON.Color4);
  84150. /**
  84151. * Serializes this cloud procedural texture
  84152. * @returns a serialized cloud procedural texture object
  84153. */
  84154. serialize(): any;
  84155. /**
  84156. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  84157. * @param parsedTexture defines parsed texture data
  84158. * @param scene defines the current scene
  84159. * @param rootUrl defines the root URL containing cloud procedural texture information
  84160. * @returns a parsed Cloud Procedural BABYLON.Texture
  84161. */
  84162. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  84163. }
  84164. }
  84165. declare module BABYLON {
  84166. /** @hidden */
  84167. export var fireProceduralTexturePixelShader: {
  84168. name: string;
  84169. shader: string;
  84170. };
  84171. }
  84172. declare module BABYLON {
  84173. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  84174. private _time;
  84175. private _speed;
  84176. private _autoGenerateTime;
  84177. private _fireColors;
  84178. private _alphaThreshold;
  84179. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84180. updateShaderUniforms(): void;
  84181. render(useCameraPostProcess?: boolean): void;
  84182. static get PurpleFireColors(): BABYLON.Color3[];
  84183. static get GreenFireColors(): BABYLON.Color3[];
  84184. static get RedFireColors(): BABYLON.Color3[];
  84185. static get BlueFireColors(): BABYLON.Color3[];
  84186. get autoGenerateTime(): boolean;
  84187. set autoGenerateTime(value: boolean);
  84188. get fireColors(): BABYLON.Color3[];
  84189. set fireColors(value: BABYLON.Color3[]);
  84190. get time(): number;
  84191. set time(value: number);
  84192. get speed(): BABYLON.Vector2;
  84193. set speed(value: BABYLON.Vector2);
  84194. get alphaThreshold(): number;
  84195. set alphaThreshold(value: number);
  84196. /**
  84197. * Serializes this fire procedural texture
  84198. * @returns a serialized fire procedural texture object
  84199. */
  84200. serialize(): any;
  84201. /**
  84202. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  84203. * @param parsedTexture defines parsed texture data
  84204. * @param scene defines the current scene
  84205. * @param rootUrl defines the root URL containing fire procedural texture information
  84206. * @returns a parsed Fire Procedural BABYLON.Texture
  84207. */
  84208. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  84209. }
  84210. }
  84211. declare module BABYLON {
  84212. /** @hidden */
  84213. export var grassProceduralTexturePixelShader: {
  84214. name: string;
  84215. shader: string;
  84216. };
  84217. }
  84218. declare module BABYLON {
  84219. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  84220. private _grassColors;
  84221. private _groundColor;
  84222. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84223. updateShaderUniforms(): void;
  84224. get grassColors(): BABYLON.Color3[];
  84225. set grassColors(value: BABYLON.Color3[]);
  84226. get groundColor(): BABYLON.Color3;
  84227. set groundColor(value: BABYLON.Color3);
  84228. /**
  84229. * Serializes this grass procedural texture
  84230. * @returns a serialized grass procedural texture object
  84231. */
  84232. serialize(): any;
  84233. /**
  84234. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  84235. * @param parsedTexture defines parsed texture data
  84236. * @param scene defines the current scene
  84237. * @param rootUrl defines the root URL containing grass procedural texture information
  84238. * @returns a parsed Grass Procedural BABYLON.Texture
  84239. */
  84240. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  84241. }
  84242. }
  84243. declare module BABYLON {
  84244. /** @hidden */
  84245. export var marbleProceduralTexturePixelShader: {
  84246. name: string;
  84247. shader: string;
  84248. };
  84249. }
  84250. declare module BABYLON {
  84251. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  84252. private _numberOfTilesHeight;
  84253. private _numberOfTilesWidth;
  84254. private _amplitude;
  84255. private _jointColor;
  84256. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84257. updateShaderUniforms(): void;
  84258. get numberOfTilesHeight(): number;
  84259. set numberOfTilesHeight(value: number);
  84260. get amplitude(): number;
  84261. set amplitude(value: number);
  84262. get numberOfTilesWidth(): number;
  84263. set numberOfTilesWidth(value: number);
  84264. get jointColor(): BABYLON.Color3;
  84265. set jointColor(value: BABYLON.Color3);
  84266. /**
  84267. * Serializes this marble procedural texture
  84268. * @returns a serialized marble procedural texture object
  84269. */
  84270. serialize(): any;
  84271. /**
  84272. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  84273. * @param parsedTexture defines parsed texture data
  84274. * @param scene defines the current scene
  84275. * @param rootUrl defines the root URL containing marble procedural texture information
  84276. * @returns a parsed Marble Procedural BABYLON.Texture
  84277. */
  84278. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  84279. }
  84280. }
  84281. declare module BABYLON {
  84282. /** @hidden */
  84283. export var normalMapProceduralTexturePixelShader: {
  84284. name: string;
  84285. shader: string;
  84286. };
  84287. }
  84288. declare module BABYLON {
  84289. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  84290. private _baseTexture;
  84291. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84292. updateShaderUniforms(): void;
  84293. render(useCameraPostProcess?: boolean): void;
  84294. resize(size: any, generateMipMaps: any): void;
  84295. get baseTexture(): BABYLON.Texture;
  84296. set baseTexture(texture: BABYLON.Texture);
  84297. /**
  84298. * Serializes this normal map procedural texture
  84299. * @returns a serialized normal map procedural texture object
  84300. */
  84301. serialize(): any;
  84302. /**
  84303. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  84304. * @param parsedTexture defines parsed texture data
  84305. * @param scene defines the current scene
  84306. * @param rootUrl defines the root URL containing normal map procedural texture information
  84307. * @returns a parsed Normal Map Procedural BABYLON.Texture
  84308. */
  84309. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  84310. }
  84311. }
  84312. declare module BABYLON {
  84313. /** @hidden */
  84314. export var perlinNoiseProceduralTexturePixelShader: {
  84315. name: string;
  84316. shader: string;
  84317. };
  84318. }
  84319. declare module BABYLON {
  84320. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  84321. time: number;
  84322. timeScale: number;
  84323. translationSpeed: number;
  84324. private _currentTranslation;
  84325. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84326. updateShaderUniforms(): void;
  84327. render(useCameraPostProcess?: boolean): void;
  84328. resize(size: any, generateMipMaps: any): void;
  84329. /**
  84330. * Serializes this perlin noise procedural texture
  84331. * @returns a serialized perlin noise procedural texture object
  84332. */
  84333. serialize(): any;
  84334. /**
  84335. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  84336. * @param parsedTexture defines parsed texture data
  84337. * @param scene defines the current scene
  84338. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  84339. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  84340. */
  84341. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  84342. }
  84343. }
  84344. declare module BABYLON {
  84345. /** @hidden */
  84346. export var roadProceduralTexturePixelShader: {
  84347. name: string;
  84348. shader: string;
  84349. };
  84350. }
  84351. declare module BABYLON {
  84352. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  84353. private _roadColor;
  84354. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84355. updateShaderUniforms(): void;
  84356. get roadColor(): BABYLON.Color3;
  84357. set roadColor(value: BABYLON.Color3);
  84358. /**
  84359. * Serializes this road procedural texture
  84360. * @returns a serialized road procedural texture object
  84361. */
  84362. serialize(): any;
  84363. /**
  84364. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  84365. * @param parsedTexture defines parsed texture data
  84366. * @param scene defines the current scene
  84367. * @param rootUrl defines the root URL containing road procedural texture information
  84368. * @returns a parsed Road Procedural BABYLON.Texture
  84369. */
  84370. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  84371. }
  84372. }
  84373. declare module BABYLON {
  84374. /** @hidden */
  84375. export var starfieldProceduralTexturePixelShader: {
  84376. name: string;
  84377. shader: string;
  84378. };
  84379. }
  84380. declare module BABYLON {
  84381. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  84382. private _time;
  84383. private _alpha;
  84384. private _beta;
  84385. private _zoom;
  84386. private _formuparam;
  84387. private _stepsize;
  84388. private _tile;
  84389. private _brightness;
  84390. private _darkmatter;
  84391. private _distfading;
  84392. private _saturation;
  84393. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84394. updateShaderUniforms(): void;
  84395. get time(): number;
  84396. set time(value: number);
  84397. get alpha(): number;
  84398. set alpha(value: number);
  84399. get beta(): number;
  84400. set beta(value: number);
  84401. get formuparam(): number;
  84402. set formuparam(value: number);
  84403. get stepsize(): number;
  84404. set stepsize(value: number);
  84405. get zoom(): number;
  84406. set zoom(value: number);
  84407. get tile(): number;
  84408. set tile(value: number);
  84409. get brightness(): number;
  84410. set brightness(value: number);
  84411. get darkmatter(): number;
  84412. set darkmatter(value: number);
  84413. get distfading(): number;
  84414. set distfading(value: number);
  84415. get saturation(): number;
  84416. set saturation(value: number);
  84417. /**
  84418. * Serializes this starfield procedural texture
  84419. * @returns a serialized starfield procedural texture object
  84420. */
  84421. serialize(): any;
  84422. /**
  84423. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  84424. * @param parsedTexture defines parsed texture data
  84425. * @param scene defines the current scene
  84426. * @param rootUrl defines the root URL containing startfield procedural texture information
  84427. * @returns a parsed Starfield Procedural BABYLON.Texture
  84428. */
  84429. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  84430. }
  84431. }
  84432. declare module BABYLON {
  84433. /** @hidden */
  84434. export var woodProceduralTexturePixelShader: {
  84435. name: string;
  84436. shader: string;
  84437. };
  84438. }
  84439. declare module BABYLON {
  84440. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  84441. private _ampScale;
  84442. private _woodColor;
  84443. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84444. updateShaderUniforms(): void;
  84445. get ampScale(): number;
  84446. set ampScale(value: number);
  84447. get woodColor(): BABYLON.Color3;
  84448. set woodColor(value: BABYLON.Color3);
  84449. /**
  84450. * Serializes this wood procedural texture
  84451. * @returns a serialized wood procedural texture object
  84452. */
  84453. serialize(): any;
  84454. /**
  84455. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  84456. * @param parsedTexture defines parsed texture data
  84457. * @param scene defines the current scene
  84458. * @param rootUrl defines the root URL containing wood procedural texture information
  84459. * @returns a parsed Wood Procedural BABYLON.Texture
  84460. */
  84461. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  84462. }
  84463. }